2013-01-11 31 views
0

我想整合payapl通過沙箱爲我的網站。購物車寬運費與集成錯誤代碼:10413

我可以發送多個項目貝寶它工作正常。但我想設置CART-WIDE運費,並將其發送到paypal

我得到錯誤代碼:

10413 ("ErrorCode=10413&Desc=Transaction refused because of an invalid argument. See additional error messages for details.& Desc2=The totals of the cart item amounts do not match order amounts.")

My CART: 
Item: Mens Jackets 
Price: 14.99 
DESC: "SAMPLE" 
QTY: 1 
ITEM TOTAL: 14.99 
SHIPPING: 5.99 

CART TOTAL: 20.94 

我設置以下變量,我不知道我做錯了。

NVPCodec encoder = new NVPCodec(); 
         encoder["METHOD"] = "SetExpressCheckout"; 
         encoder["RETURNURL"] = returnURL; 
         encoder["CANCELURL"] = cancelURL; 
         encoder["BRANDNAME"] = "Mountain Warehouse Sample Application"; 
         encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale"; 
         encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "GBP"; 

         // Get the Shopping Cart Products 
         int i = 0; 
         Decimal totalItemAmt = 0.00M; 
         string cartShippingAmt = ""; 
         foreach (BasketItem item in basket.Items) 
         { 
            if (item.OrderItemType == OrderItemType.Product) 
            { 
               encoder["L_PAYMENTREQUEST_0_NAME" + i] = item.Name.ToString(); 
               encoder["L_PAYMENTREQUEST_0_AMT" + i] = item.Price.ToString("0.00"); 
               encoder["L_PAYMENTREQUEST_0_QTY" + i] = item.Quantity.ToString(); 
               i++; 
               totalItemAmt += Convert.ToDecimal(item.Price.ToString("0.00")); 
            } 

            if (item.OrderItemType == OrderItemType.Shipping) 
            { 
               cartShippingAmt = item.Price.ToString("0.00"); 
            } 
         } 

         encoder["PAYMENTREQUEST_0_ITEMAMT"] = totalItemAmt.ToString(); 
         encoder["PAYMENTREQUEST_0_AMT"] = amt; 
         encoder["HANDLING_CART"] = cartShippingAmt; 

這裏是獲取發送到貝寶

METHOD=SetExpressCheckout& 
RETURNURL=http%3a%2f%2flocalhost%3a1234%2fCheckout%2fCheckoutReview.aspx& 
CANCELURL=http%3a%2f%2flocalhost%3a1234%2fCheckout%2fCheckoutCancel.aspx& 
BRANDNAME=Sample+Application& 
PAYMENTREQUEST_0_PAYMENTACTION=Sale& 
PAYMENTREQUEST_0_CURRENCYCODE=GBP& 
L_PAYMENTREQUEST_0_NAME0=MENS+JACKETS& 
L_PAYMENTREQUEST_0_AMT0=14.99& 
L_PAYMENTREQUEST_0_QTY0=1& 
PAYMENTREQUEST_0_ITEMAMT=14.99& 
HANDLING_CART=5.95& 
PAYMENTREQUEST_0_AMT=20.94 

我覺得我對整個車分配錯誤的變量運費查詢。

回答

1

這裏有一些錯誤。

首先,您使用的一些請求參數不正確。 HANDLING_CART不是有效的請求參數。我認爲你要找的是HANDLINGAMT(實際上是PAYMENTREQUEST_0_HANDLINGAMT)。

在每次付款中,ITEMAMT + SHIPPINGAMT + HANDLINGAMT + TAXAMT的總和需要等於AMT。在你的情況,貝寶是忽略你發送無效參數,所以它最終看到下面...

PAYMENTREQUEST_0_ITEMAMT = 14.99 PAYMENTREQUEST_0_AMT = 20.94

這不是看到你的操作數量,因爲這一參數是因此,總數根據他們所看到的不匹配。您只需將HANDLING_CART更改爲PAYMENTREQUEST_0_HANDLINGAMT即可解決問題。

這裏有多個項目,其中包括一些額外的選項的工作SetExpressCheckout請求的樣本...

[USER] => **** 
[PWD] => **** 
[VERSION] => 97.0 
[BUTTONSOURCE] => AngellEYE_PHPClass 
[SIGNATURE] => **** 
[METHOD] => SetExpressCheckout 
[MAXAMT] => 200.00 
[RETURNURL] => http://paypal.angelleye.com/standard/samples/DoExpressCheckoutPayment.php 
[CANCELURL] => http://paypal.angelleye.com/paypal/class/cancel.php 
[ALLOWNOTE] => 1 
[HDRIMG] => http://paypal.angelleye.com/images/hdrimg.jpg 
[SOLUTIONTYPE] => Sole 
[LANDINGPAGE] => Billing 
[BRANDNAME] => Angell EYE 
[CUSTOMERSERVICENUMBER] => 555-555-5555 
[GIFTMESSAGEENABLE] => 1 
[GIFTRECEIPTENABLE] => 1 
[GIFTWRAPENABLE] => 1 
[GIFTWRAPNAME] => Box with Ribbon 
[GIFTWRAPAMOUNT] => 2.50 
[BUYEREMAILOPTIONENABLE] => 1 
[SURVEYQUESTION] => Did you like this checkout? 
[SURVEYENABLE] => 1 
[BUYERREGISTRATIONDATE] => 2012-07-14T00:00:00Z 
[L_SURVEYCHOICE0] => Yes 
[L_SURVEYCHOICE1] => No 
[PAYMENTREQUEST_0_AMT] => 100.00 
[PAYMENTREQUEST_0_CURRENCYCODE] => USD 
[PAYMENTREQUEST_0_ITEMAMT] => 80.00 
[PAYMENTREQUEST_0_SHIPPINGAMT] => 15.00 
[PAYMENTREQUEST_0_TAXAMT] => 5.00 
[PAYMENTREQUEST_0_DESC] => This is a test order. 
[PAYMENTREQUEST_0_NOTETEXT] => This is a test note before ever having left the web site. 
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale 
[L_PAYMENTREQUEST_0_NAME0] => Widget 123 
[L_PAYMENTREQUEST_0_DESC0] => Widget 123 
[L_PAYMENTREQUEST_0_AMT0] => 40.00 
[L_PAYMENTREQUEST_0_NUMBER0] => 123 
[L_PAYMENTREQUEST_0_QTY0] => 1 
[L_PAYMENTREQUEST_0_ITEMURL0] => http://www.angelleye.com/products/123.php 
[L_PAYMENTREQUEST_0_NAME1] => Widget 456 
[L_PAYMENTREQUEST_0_DESC1] => Widget 456 
[L_PAYMENTREQUEST_0_AMT1] => 40.00 
[L_PAYMENTREQUEST_0_NUMBER1] => 456 
[L_PAYMENTREQUEST_0_QTY1] => 1 
[L_PAYMENTREQUEST_0_ITEMURL1] => http://www.angelleye.com/products/456.php 
+0

你搖滾的人...。你讓我很快樂...我希望有人總有一天會實際上看到我的問題和關心回答...我喜歡你解釋的方式...... +1 –