gpt4 book ai didi

php - 运费总额和即时更新 API 的 PayPal 错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:11:47 25 4
gpt4 key购买 nike

我正在尝试调用 ExpressCheckout 并执行即时更新 API,但无论我做什么,它似乎都会返回一个无效的总运费错误。我知道在实时运行时需要使用 SSL,但是我正在尝试针对沙箱进行测试,但仍然出现这些错误。

我的简单 HTML 测试页:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Express Checkout with Callback API - PayPal</title>
</head>
<body>
<h1 align="center"> Express Checkout with Callback API </h1>
<h3 align="center"> PayPal </h3>
<form method=post action=https://api-3t.sandbox.paypal.com/nvp>
<input type=hidden name=USER value=xxxxxxxxxxx>
<input type=hidden name=PWD value=xxxxxxxx>
<input type=hidden name=SIGNATURE value=xxxxxxxxxxxxxxxxxxxxxxx>
<input type=hidden name=VERSION value=63.0>
<input type=hidden name=PAYMENTREQUEST_0_PAYMENTACTION value=Sale>
<input name=PAYMENTREQUEST_0_AMT value=19.95>
<input type=hidden name=RETURNURL value=https://www.YourReturnURL.com>
<input type=hidden name=CANCELURL value=https://www.YourCancelURL.com>
<input type=hidden name=MAXAMT value=100.00>
<input type=hidden name=callback value=....../callback.php>
<input type=hidden name= callbacktimeout value=5>
<input type=hidden name= l_shippingoptionisdefault0 value=true>
<input type=hidden name= l_shippingoptionname0 value=Ground>
<input type=hidden name= l_shippingoptionlabel0 value=5 Days>
<input type=hidden name= l_shippingoptionamount0 value=10.00>
<input type=hidden name= shippingamt value=10.00>
<input type=submit name=METHOD value=SetExpressCheckout>
</form>
</body>
</html>

托管在我的服务器上的我的 callback.php 脚本:

<?php
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req = "&$key=$value";
}

//Build string
$method = $_POST['METHOD'];
$version = $_POST['CALLBACKVERSION'];
$token = $_POST['TOKEN'];
$currencycode = $_POST['CURRENCYCODE'];
$localecode = $_POST['LOCALECODE'];
$street = $_POST['SHIPTOSTREET'];
$street2 = $_POST['SHIPTOSTREET2'];
$city = $_POST['SHIPTOCITY'];
$state = $_POST['SHIPTOSTATE'];
$country = $_POST['SHIPTOCOUNTRY'];
$zip = $_POST['SHIPTOZIP'];

//If PayPal acocunt has US address
if ($country=="US") {
echo "METHOD=CallbackResponse&L_SHIPPINGOPTIONNAME0=Ground&L_SHIPPINGOPTIONLABEL0=5 to 7 Days&L_SHIPPINGOPTIONAMOUNT0=10.00&L_SHIPPINGOPTIONISDEFAULT0=true";
}

//If PayPal account has a non-US address
else {
echo "METHOD=CallbackResponse&L_SHIPPINGOPTIONNAME0=Next Day Air&L_SHIPPINGOPTIONLABEL0=7 to 14 Days&L_SHIPPINGOPTIONAMOUNT0=20.00&L_SHIPPINGOPTIONISDEFAULT0=true";
}
?>

我已经从代码中删除了一些敏感信息,并将所有运输值更改了 100 次,所以如果有一些愚蠢的错误,请原谅。任何帮助将不胜感激,谢谢!

最佳答案

根据 Paypal's Developer Guide (第 58 页)声称 CURRENCYCODE 是必需的。尽管在我的测试中,情况似乎并非如此。但值得一试。

此外,对您的值进行 url 编码也可能会发生这种情况...因此请将您的空格变成 +s。

我已将其用作有效的测试响应:L_INSURANCEAMOUNT1=1.35&L_SHIPPINGOPTIONISDEFAULT2=false&L_SHIPPINGOPTIONNAME0=1%3A+&L_SHIPPINGOPTIONNAME1=2%3A+&L_SHIPPINGOPTIONLABEL0=asdf&L_SHIPPINGOPTIONLABEL1=UPS+Express+2+Days&OFFERINSURANCEOPTION=true& CURRENCYCODE=USD&L_INSURANCEAMOUNT2=1.28&L_TAXAMT0=2.20&L_SHIPPINGOPTIONAMOUNT1=10.00&L_SHIPPINGOPTIONAMOUNT0=20.00&L_SHIPPINGOPTIONAMOUNT2=9.99&L_SHIPPINGOPTIONAMOUNT1=9.99&L_SHIPPINGOPTIONAMOUNT1 =true&L_SHIPPINGOPTIONISDEFAULT0=false&L_SHIPPINGOPTIONNAME2=3%3A+&L_SHIPPINGOPTIONLABEL2=UPS+Ground+2+to+7+Days&L_TAXAMT1=2.00&METHOD=CallbackResponse&L_INSURANCEAMOUNT0=1.35&L_TAXAMT2=1.99

关于php - 运费总额和即时更新 API 的 PayPal 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11633641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com