带有运费和错误的 Paypal Express 结帐

Posted

技术标签:

【中文标题】带有运费和错误的 Paypal Express 结帐【英文标题】:Paypal Express checkout with shipping cost and error 【发布时间】:2012-01-07 00:25:01 【问题描述】:

我正在向贝宝请求的数据 (SetExpressCheckout)

[METHOD] => SetExpressCheckout

[ENDPOINT] => https://api-3t.sandbox.paypal.com/nvp
[USER] => ***
[PWD] => ***
[SIGNATURE] => ***
[VERSION] => 84.0
[TOKEN] => 
[CURRENCYCODE] => GBP
[RETURNURL] => http://experiment.loc/
[CANCELURL] => http://experiment.loc/?action=cancel
[SHIPPINGAMT] => 2.21
[SOLUTIONTYPE] => Sole
[LANDINGPAGE] => Billing
[L_ITEMCATEGORY0] => Physical
[L_QTY0] => 4
[L_AMT0] => 2.20
[L_DESC0] => ZajÄ…czek 1
[L_NAME0] => ZajÄ…czek 1
[L_CURRENCYCODE0] => GBP
[L_ITEMCATEGORY1] => Physical
[L_QTY1] => 1
[L_AMT1] => 3.20
[L_DESC1] => ZajÄ…czek 2
[L_NAME1] => ZajÄ…czek 2
[L_CURRENCYCODE1] => GBP
[PAYMENTREQUEST_PAYMENTACTION] => Sale
[PAYMENTREQUEST_ITEMAMT] => 12
[PAYMENTREQUEST_AMT] => 14.21
[AMT] => 14.21

但我总是遇到错误:

[TIMESTAMP] => 2011-11-26T18:37:33Z
[CORRELATIONID] => 465d809d95153
[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

我在向请求中添加运费时做错了什么??

【问题讨论】:

您的问题解决了吗? 【参考方案1】:
[PAYMENTREQUEST_PAYMENTACTION] => Sale
[PAYMENTREQUEST_ITEMAMT] => 12
[PAYMENTREQUEST_AMT] => 14.21

应该是:

[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[PAYMENTREQUEST_0_ITEMAMT] => 12
[PAYMENTREQUEST_0_AMT] => 14.21

此外,您的金额不会相加。您设置的最大值为 14.21,但所有值加起来只有 7.41

L_AMTm(实际上应该是 L_PAYMENTREQUEST_0_AMTm)是特定于项目的。 PAYMENTREQUEST_0_ITEMAMT 是所有项目的小计 PAYMENTREQUEST_0_AMT 应该是所有内容的总和。

例如

[SOLUTIONTYPE] => Sole
[LANDINGPAGE] => Billing
[L_PAYMENTREQUEST_0_ITEMCATEGORY0] => Physical
[L_PAYMENTREQUEST_0_QTY0] => 4
[L_PAYMENTREQUEST_0_AMT0] => 2.20
[L_PAYMENTREQUEST_0_DESC0] => ZajÄ…czek 1
[L_PAYMENTREQUEST_0_NAME0] => ZajÄ…czek 1
[L_PAYMENTREQUEST_0_CURRENCYCODE0] => GBP
[L_PAYMENTREQUEST_0_ITEMCATEGORY1] => Physical
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_AMT1] => 3.20
[L_PAYMENTREQUEST_0_DESC1] => ZajÄ…czek 2
[L_PAYMENTREQUEST_0_NAME1] => ZajÄ…czek 2
[L_PAYMENTREQUEST_0_CURRENCYCODE1] => GBP
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[PAYMENTREQUEST_0_SHIPPINGAMT] => 2.21
[PAYMENTREQUEST_0_ITEMAMT] => 5.40
[PAYMENTREQUEST_0_AMT] => 7.61

或者official PayPal example:

&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  

【讨论】:

[L_SHORTMESSAGE0] => 由于参数无效,交易被拒绝。有关详细信息,请参阅其他错误消息。 [L_LONGMESSAGE0] => 购物车商品总金额与订单金额不符。 @PayPal_Robert 如何使用折扣? 我已回复您的电子邮件。基本上,您会传递一个负的订单项金额并确保总金额匹配。 IE。 L_PAYMENTREQUEST_0_AMT0=-2.00 获得 2 美元的“折扣”。

以上是关于带有运费和错误的 Paypal Express 结帐的主要内容,如果未能解决你的问题,请参考以下文章

使用 cURL 计算 Paypal Express Checkout 运费

PayPal Express Checkout 在调用 SetExpressCheckout 后应用运费

运费总额和即时更新 API 的 PayPal 错误

OpenCart 1.5.6 附带的 PayPal Checkout Express 模块是不是适合您?

Paypal Express Checkout:应用订单折扣

PayPal Rest API Express Checkout 工作流程