gpt4 book ai didi

php - PayPal 在 SetExpressCheckout 上返回 ACK Failure

转载 作者:太空宇宙 更新时间:2023-11-03 15:52:44 24 4
gpt4 key购买 nike

我尝试通过在 PayPal 中提供以下数据来获取 PayPal 的 token :

Array
(
[PAYMENTREQUEST_0_CURRENCYCODE] => EUR
[PAYMENTREQUEST_0_INVNUM] => TLT-GR-1
[RETURNURL] => http://www.mysite.ext/my_app/payment-completed/
[CANCELURL] => http://www.mysite.ext/my_app/payment-canceled/
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[SOLUTIONTYPE] => Sole
[L_PAYMENTREQUEST_0_NAME0] => Product Description
[L_PAYMENTREQUEST_0_AMT0] => 0.38
[L_PAYMENTREQUEST_0_QTY0] => 19.27
[PAYMENTREQUEST_0_AMT] => 7.32
[PAYMENTREQUEST_0_ITEMAMT] => 1
)

这是生成上述数组值的代码:

$data           =   array();

$data['PAYMENTREQUEST_0_CURRENCYCODE'] = $currencyCode;
$data['PAYMENTREQUEST_0_INVNUM'] = $order->ID;
$data['RETURNURL'] = $returnUrl;
$data['CANCELURL'] = $cancelUrl;
$data['PAYMENTREQUEST_0_PAYMENTACTION'] = 'Sale';
$data['SOLUTIONTYPE'] = 'Sole';

$subtotal = 0;
$tax = 0;
$counter = 0;

foreach($products as $product)
{
if($product->Type == 0) // Production is diretion
{
if($product->NightDuration == 0)
{
$price = round($product->Price , 2);
$qty = round($product->Qty , 2);

$data['L_PAYMENTREQUEST_0_NAME' . $counter] = $product->Title;
$data['L_PAYMENTREQUEST_0_AMT' . $counter] = $price;
$data['L_PAYMENTREQUEST_0_NUMBER' . $counter] = ($counter + 1);
$data['L_PAYMENTREQUEST_0_QTY' . $counter] = $qty;
$data['L_PAYMENTREQUEST_0_TAXAMT' . $counter] = round(($qty * $price) * ($taxPercentage / 100), 2);
$data['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $counter] = 'Digital';
$subtotal += $qty * $price;
$tax += ($qty * $price) * ($taxPercentage / 100);
}
else
{

}
}
else
{

}

$counter++;
}

$data['PAYMENTREQUEST_0_AMT'] = round($subtotal + $tax, 2);
$data['PAYMENTREQUEST_0_ITEMAMT'] = 1;
$data['PAYMENTREQUEST_0_TAXAMT'] = round($tax, 2);
echo "<pre>";
print_r($data);
echo "</pre>";
$data = http_build_query($data, '', '&');

$pp = new TaxiBookingPayPal();
$rt = $pp->PPHttpPost('SetExpressCheckout', $data);

echo "<pre>";
print_r($rt);
echo "</pre>";

我从 PayPal 得到以下结果:

Array
(
[TIMESTAMP] => 2013%2d01%2d19T14%3a44%3a25Z
[CORRELATIONID] => bdfce7f34a1db
[ACK] => Failure
[VERSION] => 94
[BUILD] => 4181146
[L_ERRORCODE0] => 10413
[L_SHORTMESSAGE0] => Transaction%20refused%20because%20of%20an%20invalid%20argument%2e%20See%20additional%20error%20messages%20for%20details%2e
[L_LONGMESSAGE0] => The%20totals%20of%20the%20cart%20item%20amounts%20do%20not%20match%20order%20amounts%2e
[L_SEVERITYCODE0] => Error
)

你能看出这段代码有什么问题吗?有没有人可以帮助我?

经过长时间研究我的代码,我发现问题出在我的数字中的小数位上。问题是我不知道小数到底有什么问题:(

谢谢

最佳答案

ITEMAMT + TAXAMT + SHIPPINGAMT + HANDLINGAMT 必须等于 AMT。

ITEMAMT 应该只是项目的小计,但你只在那里传递了 1。

此外,您的数量为 19.27。我从来没有专门测试过他们是否会接受这样的 QTY 值,但即使他们接受,您的 ITEMAMT 也应该是 7.32。

在这种情况下,您没有传递其他值,因此您的 ITEMAMT 和 AMT 将相同。你在那里传递的那个 1 导致了你得到的错误,因为它没有加到你的 AMT 中。

关于php - PayPal 在 SetExpressCheckout 上返回 ACK Failure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14415520/

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