我的自定义贝宝购物车上的总数有问题。使用 PHP NVP API 我得到:
TIMESTAMP: 2012-01-18T07:27:10Z
CORRELATIONID: d1fac4fa784ef
ACK: Failure
VERSION: 84.0
BUILD: 2271164
L_ERRORCODE0: 10413
L_SHORTMESSAGE0: Transaction refused because of an invalid argument. See additional error messages for details.
L_LONGMESSAGE0: The totals of the cart item amounts do not match order amounts.
L_SEVERITYCODE0: Error
但是,我知道我的总数应该是正确的。这是PHP:
$count = sizeof($cartItem);
$subtotal = 0;
$itmStr = '';
foreach($cartItem as $k = $ci)
{
$sub = $ci['cart_amt']*$ci['cart_price'];
$subtotal = $sub + $subtotal;
$itmStr .= '&L_PAYMENTREQUEST_'.$k.'_NUMBER0='.$ci['cart_id'].'&L_PAYMENTREQUEST_'.$k.'_NAME0='.$ci['cart_item'].'&L_PAYMENTREQUEST_'.$k.'_AMT0='.$ci['cart_price'].'&L_PAYMENTREQUEST_'.$k.'_QTY0='.$ci['cart_amt'].'&L_PAYMENTREQUEST_'.$k.'_DESC0='.truncate($ci['cart_desc'], 25);
}
$subtotal = (float) $subtotal;
if(round($subtotal) < 25)
{
$ups_rate = (float) 9.95;
$usps_rate = (float) 7.50;
}
$ups_rate = number_format($ups_rate, 2, '.', '');
$usps_rate = number_format($usps_rate, 2, '.', '');
$_SESSION['ups_rate'] = $ups_rate;
$_SESSION['usps_rate'] = $usps_rate;
$ups_tot = $ups_rate + $subtotal;
$usps_tot = $usps_rate + $subtotal;
$_SESSION['ups_tot'] = $ups_tot;
$_SESSION['usps_tot'] = $usps_tot;
$_SESSION['subtotal'] = $subtotal;
$base_total = $subtotal+$usps_rate;
$handling = number_format((float) ($base_total*0.029) + .30, 2, '.', '');
$total = number_format($handling+$base_total, 2, '.', '');
$returnURL = append_sid("{$url}cart.php", 'mode=paypal_transaction¤cyCodeType='.urlencode($currencyCodeType).'&paymentType='.urlencode($paymentType));
$cancelURL = append_sid("{$url}cart.php", 'paymentType='.urlencode($paymentType));
$nvpstr = "";
$shiptoAddress = "&PAYMENTREQUEST_0_SHIPTONAME=$personName&PAYMENTREQUEST_0_SHIPTOSTREET=$SHIPTOSTREET&PAYMENTREQUEST_0_SHIPTOCITY=$SHIPTOCITY&PAYMENTREQUEST_0_SHIPTOSTATE=$SHIPTOSTATE&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=$SHIPTOCOUNTRYCODE&PAYMENTREQUEST_0_SHIPTOZIP=$SHIPTOZIP";
$nvpstr = '&ADDRESSOVERRIDE=1'.$shiptoAddress.'&MAXAMT='.(string)$total."&PAYMENTREQUEST_0_AMT=".(string)$total."&PAYMENTREQUEST_0_ITEMAMT=".(string)$subtotal.'&CALLBACKTIMEOUT=4&PAYMENTRREQUEST_0_HANDLINGAMT='.$handling.'&PAYMENTREQUEST_0_SHIPPINGAMT='.$usps_rate.'&ReturnUrl='.$returnURL.'&CANCELURL='.$cancelURL.'&PAYMENTINFO_0_CURRENCYCODE='.$currencyCodeType.'&PAYMENTREQUEST_0_PAYMENTACTION='.$paymentType.$itmStr;
使用上面的代码,我使用以下参数调用 SetExpressCheckout:
&ADDRESSOVERRIDE=1&PAYMENTREQUEST_0_SHIPTONAME=test user&PAYMENTREQUEST_0_SHIPTOSTREET=123 somewhere st&PAYMENTREQUEST_0_SHIPTOCITY=mytown&PAYMENTREQUEST_0_SHIPTOSTATE=NC&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=US&PAYMENTREQUEST_0_SHIPTOZIP=12345&MAXAMT=64.71&PAYMENTREQUEST_0_AMT=64.71&PAYMENTREQUEST_0_ITEMAMT=50.64&CALLBACKTIMEOUT=4&PAYMENTRREQUEST_0_HANDLINGAMT=2.12&PAYMENTREQUEST_0_SHIPPINGAMT=11.95&ReturnUrl=http://xxxx/cart.php?mode=paypal_transaction&sid=XXX&CANCELURL=http://therealmsofwickedry.com/cart.php?mode=paypal_transaction&sid=XXX&PAYMENTINFO_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_PAYMENTACTION=Sale&L_PAYMENTREQUEST_0_NUMBER0=3320&L_PAYMENTREQUEST_0_NAME0=ITem number 1&L_PAYMENTREQUEST_0_AMT0=47.32&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_DESC0=No description available&L_PAYMENTREQUEST_1_NUMBER0=4605&L_PAYMENTREQUEST_1_NAME0=Item number 2&L_PAYMENTREQUEST_1_AMT0=3.32&L_PAYMENTREQUEST_1_QTY0=1&L_PAYMENTREQUEST_1_DESC0=No description available
我没有传递参数吗?我是否以某种方式对它们进行了错误编码?任何指针将不胜感激!