2013-01-11 1 views
0

J'essaie de intégrer payapl à travers bac à sable pour mon site Web.Panier large coût d'expédition pour l'intégration avec le code d'erreur: 10413

Je peux envoyer plusieurs articles à paypal et cela fonctionne bien. cependant je veux placer CART-WIDE coût d'expédition et l'envoyer à paypal.

Je reçois le code d'erreur:

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 

Je suis en train les variables suivantes et je ne sais pas ce que je fais mal.

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; 

Voici la requête qui obtient à envoyer paypal

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 

Je pense que je suis mauvaise variable de coût assigne de livraison pour l'ensemble de panier.

Répondre

1

Vous avez quelques erreurs ici. Tout d'abord, certains des paramètres de requête que vous utilisez ne sont pas corrects. HANDLING_CART n'est pas un paramètre de requête valide. Je pense que ce que vous cherchez là est HANDLINGAMT (qui serait en fait PAYMENTREQUEST_0_HANDLINGAMT).

Pour chaque paiement, le total de ITEMAMT + SHIPPINGAMT + HANDLINGAMT + TAXAMT doit être égal à AMT. Dans votre cas, PayPal ne tient pas compte du paramètre non valide que vous envoyez, il finit par voir ce qui suit ...

PAYMENTREQUEST_0_ITEMAMT = 14,99 PAYMENTREQUEST_0_AMT = 20,94

Il est de ne pas voir le montant de votre traitement parce que ce paramètre est invalide, par conséquent, les totaux ne correspondent pas en fonction de ce qu'ils voient. Vous avez juste besoin de changer HANDLING_CART à PAYMENTREQUEST_0_HANDLINGAMT et cela devrait résoudre votre problème.

Voici un échantillon d'une requête SetExpressCheckout de travail avec plusieurs éléments et quelques options supplémentaires inclus ...

[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

you rock homme ... .vous ma journée ... j'espérais que quelqu'un un jour effectivement voir ma question et soin de répondre ... J'aime la façon dont vous avez expliqué ... +1 –