2012-04-17 120 views
15

我正在使用paypal express checkout API,並且在設置數量方面存在問題。以下是我的URI參數:Paypal API:購物車項目金額的總計與訂單金額不匹配

$params = array(
    'METHOD' => 'SetExpressCheckout', 
    'PAYMENTREQUEST_0_SHIPPINGAMT' => '0', 
    'PAYMENTREQUEST_0_TAXAMT' => '0', 
    'PAYMENTREQUEST_0_HANDLINGAMT' => '0', 
    'PAYMENTREQUEST_0_AMT' => "50.00", 
    'RETURNURL' => $this->_returnUri, 
    'CANCELURL' => $this->_cancelUri, 
    'HDRIMG' => $this->_logoUri, 
    'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP', 
    'L_PAYMENTREQUEST_0_DESC0' => 'Product description', 
    'L_PAYMENTREQUEST_0_NAME0' => 'Product name', 
    'L_PAYMENTREQUEST_0_AMT0' => "50.00", 
    'L_PAYMENTREQUEST_0_QTY0' => "2" 
); 

如果L_PAYMENTREQUEST_0_QTY0設置爲1,則表示進程正常。然而,將其改爲2和添加「PAYMENTREQUEST_0_ITEMAMT」 =>「100.00」到陣列給我以下錯誤:

TIMESTAMP: 2012-04-17T12:11:16Z 
CORRELATIONID: da43f6c91254 
ACK: Failure 
VERSION: 88.0 
BUILD: 2808426 
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 

我曾嘗試了幾個小時就結束脩復它和已經放棄。有人可以強調我需要做些什麼才能使其發揮作用?

+0

您是否嘗試過做'L_PAYMENTREQUEST_0_QTY0 = 2'和''L_PAYMENTREQUEST_0_AMT0 '=>「100.00」'while''PAYMENTREQUEST_0_AMT'=>「100.00」'?也許paypal不會計算2x50.00,而只是尋找每條LINE的TOTAL。我只是在這裏做出假設。 – Jakub 2012-04-17 12:36:11

+0

唉,那沒用。 – Rijndael 2012-04-17 16:49:18

+0

我不知道這是否有幫助,但也許所有的美元值應格式正確'0.00' – thescientist 2012-04-18 13:23:35

回答

24

您錯過了ITEMAMT。另請參見Paypal Express checkout with shipping cost and error中的我的回答,其中包含多個數量的工作示例。

&L_PAYMENTREQUEST_0_NAME0=10% Decaf Kona Blend Coffee 
&L_PAYMENTREQUEST_0_NUMBER0=623083 
&L_PAYMENTREQUEST_0_DESC0=Size: 8.8-oz 
&L_PAYMENTREQUEST_0_AMT0=9.95 
&L_PAYMENTREQUEST_0_QTY0=2 
&L_PAYMENTREQUEST_0_NAME1=Coffee Filter bags 
&L_PAYMENTREQUEST_0_NUMBER1=623084 
&L_PAYMENTREQUEST_0_DESC1=Size: Two 24-piece boxes 
&L_PAYMENTREQUEST_0_AMT1=39.70 
&L_PAYMENTREQUEST_0_QTY1=2 
&PAYMENTREQUEST_0_ITEMAMT=99.30 
&PAYMENTREQUEST_0_TAXAMT=2.58 
&PAYMENTREQUEST_0_SHIPPINGAMT=3.00 
&PAYMENTREQUEST_0_HANDLINGAMT=2.99 
&PAYMENTREQUEST_0_SHIPDISCAMT=-3.00 
&PAYMENTREQUEST_0_INSURANCEAMT=1.00 
&PAYMENTREQUEST_0_AMT=105.87 
&PAYMENTREQUEST_0_CURRENCYCODE=USD 
+2

0down vote 這固定我「我增加了運費,爲什麼它壞了?」題。 貝寶文檔應該真的只是鏈接到這個網站... – 2012-05-23 21:23:36

+0

有誰知道我可以添加兩個或更多的產品?...關於這個很好的例子?謝謝。 – 2013-09-07 15:59:44

2

直接相關的問題,但因爲這由錯誤信息搜索時第一次出現在谷歌這可能是誰收到此錯誤別人有用。

如果某些字段未設置(空白/空白),您可能會收到此錯誤。

例如,在我的情況下,它是(增加了清晰度換行符):

PAYMENTREQUEST_0_PAYMENTACTION=Sale 
    &REQCONFIRMSHIPPING=0 
    &RETURNURL=some_url 
    &CANCELURL=some_other_url 
    &BRANDNAME=Brand 
    &L_PAYMENTREQUEST_0_NAME0= 
    &L_PAYMENTREQUEST_0_AMT0=1.00 
    &L_PAYMENTREQUEST_0_QTY0=1 
    &PAYMENTREQUEST_0_AMT=1.00 
    &PAYMENTREQUEST_0_CURRENCYCODE=USD 

,這是給我同樣的錯誤,即使數額的罰款。 我認爲這是一個問題的解析,因爲如果你L_PAYMENTREQUEST_0_NAME0後插入甚至空間=在

&L_PAYMENTREQUEST_0_NAME0=&L_PAYMENTREQUEST_0_AMT0=1.00 

它工作正常。

所以我的猜測是,在PayPal的結束,它只是分配「& L_PAYMENTREQUEST_0_AMT0 = 1.00」到L_PAYMENTREQUEST_0_NAME0,從而有效地從消息中移除,並因此觸發這個錯誤,因爲沒有該行的金額加起來不確實。

0

我有同樣的煩惱,並通過功能number_format爲參數L_PAYMENTREQUEST_0_AMT $ K的的foreach在格式化的價格解決它

例子:

$items_amount = 0; 
foreach ($products as $k => $product) { 
    $params["L_PAYMENTREQUEST_0_NAME$k"] = $product['name']; 
    $params["L_PAYMENTREQUEST_0_DESC$k"] = $product['desc']; 
    $params["L_PAYMENTREQUEST_0_AMT$k"] = number_format($product['priceIVA'], 2); 
    $params["L_PAYMENTREQUEST_0_QTY$k"] = $product['count']; 
    $items_amount += (floatval($product['priceIVA']) * $product['count']); 
} 

$params['PAYMENTREQUEST_0_AMT'] = $params['PAYMENTREQUEST_0_ITEMAMT'] = number_format($items_amount, 2); 
相關問題