使用PayPal Express Checkout进行多次授权

时间:2016-10-27 12:30:10

标签: paypal paypal-nvp

我的结帐流程需要多次授权和捕获,如https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECRelatedAPIOps/#authorization-payment-action-for-express-checkout

所述

我需要制作单独的身份验证和捕获,因为订单包含多个可以单独发货的商品。

首先,我通过SetExpressCheckout的动作拨打Authorization

cancelUrl=xxxxxxx&
PAYMENTREQUEST_0_PAYMENTACTION=Authorization&
PAYMENTREQUEST_0_CURRENCYCODE=USD&
L_BILLINGAGREEMENTDESCRIPTION0=ClubUsage&
VERSION=204&
PAYMENTREQUEST_0_AMT=30.00&
L_BILLINGTYPE0=MerchantInitiatedBilling&
METHOD=SetExpressCheckout&
USER=xxxxxxx&
PWD=xxxxxxx&
returnUrl=xxxxxxx&
SIGNATURE=xxxxxxx

我收到一个带有令牌的回复;

TOKEN=EC-2EP3671xxxxxxxx&
TIMESTAMP=xxxxxxx&
CORRELATIONID=xxxxxxx&
ACK=Success&
VERSION=204&
BUILD=xxxxxxx

接下来,我将用户重定向到paypal登录并同意。当他们返回时,我打电话来创建一个账单协议,因为我将在以后进行参考交易。这很好用。接下来我进行第一次授权呼叫;

PAYMENTREQUEST_0_PAYMENTACTION=Authorization&
PAYMENTREQUEST_0_PAYMENTREQUESTID=200001&
PAYERID=xxxxxxx&
VERSION=204&
PAYMENTREQUEST_0_AMT=25.00&
METHOD=DoExpressCheckoutPayment&
USER=xxxxxxx&
PWD=xxxxxxx&
SIGNATURE=xxxxxxx&
TOKEN=EC-2EP3671xxxxxxx

我得到了成功的回复;

TOKEN=EC-2EP3671xxxxxxx&
SUCCESSPAGEREDIRECTREQUESTED=false&
TIMESTAMP=xxxxxxx&
CORRELATIONID=xxxxxxx&
ACK=Success&
VERSION=204&
BUILD=26126731&
INSURANCEOPTIONSELECTED=false&
SHIPPINGOPTIONISDEFAULT=false&
PAYMENTINFO_0_TRANSACTIONID=0J23486xxxxxxx&
PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&
PAYMENTINFO_0_PAYMENTTYPE=instant&
PAYMENTINFO_0_ORDERTIME=xxxxxxx&
PAYMENTINFO_0_AMT=25.00&
PAYMENTINFO_0_TAXAMT=0.00&
PAYMENTINFO_0_CURRENCYCODE=USD&
PAYMENTINFO_0_PAYMENTSTATUS=Pending&
PAYMENTINFO_0_PENDINGREASON=authorization&
PAYMENTINFO_0_REASONCODE=None&
PAYMENTINFO_0_PROTECTIONELIGIBILITY=Eligible&
PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=ItemNotReceivedEligible,UnauthorizedPaymentEligible&
PAYMENTINFO_0_SELLERPAYPALACCOUNTID=xxxxxxx&
PAYMENTINFO_0_SECUREMERCHANTACCOUNTID=xxxxxxx&
PAYMENTINFO_0_PAYMENTREQUESTID=200001&
PAYMENTINFO_0_ERRORCODE=0&
PAYMENTINFO_0_ACK=Success

到目前为止一切都很好。但我现在需要做第二次认证;

PAYMENTREQUEST_0_PAYMENTACTION=Authorization&
PAYMENTREQUEST_0_PAYMENTREQUESTID=200002&
PAYERID=xxxxxxx&
VERSION=204&
PAYMENTREQUEST_0_AMT=5.00&
METHOD=DoExpressCheckoutPayment&
USER=xxxxxxx&
PWD=xxxxxxx&
SIGNATURE=xxxxxxx&
TOKEN=EC-2EP3671xxxxxxx

..但PayPal似乎认为它不是第一个身份验证的副本;而不是执行身份验证;

TOKEN=EC-2EP3671xxxxxxx&
SUCCESSPAGEREDIRECTREQUESTED=false&
TIMESTAMP=xxxxxxx&
CORRELATIONID=xxxxxxx&
ACK=SuccessWithWarning&
VERSION=204&
BUILD=26126731&
L_ERRORCODE0=11607&
L_SHORTMESSAGE0=Duplicate Request&
L_LONGMESSAGE0=A successful transaction has already been completed for this token.&
L_SEVERITYCODE0=Warning&
INSURANCEOPTIONSELECTED=false&
SHIPPINGOPTIONISDEFAULT=false&
PAYMENTINFO_0_TRANSACTIONID=0J23486xxxxxxx&
PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&
PAYMENTINFO_0_PAYMENTTYPE=instant&
PAYMENTINFO_0_ORDERTIME=xxxxxxx&
PAYMENTINFO_0_AMT=25.00&
PAYMENTINFO_0_TAXAMT=0.00&
PAYMENTINFO_0_CURRENCYCODE=USD&
PAYMENTINFO_0_PAYMENTSTATUS=Pending&
PAYMENTINFO_0_PENDINGREASON=authorization&
PAYMENTINFO_0_REASONCODE=None&
PAYMENTINFO_0_PROTECTIONELIGIBILITY=Eligible&
PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=ItemNotReceivedEligible,UnauthorizedPaymentEligible&
PAYMENTINFO_0_SELLERPAYPALACCOUNTID=xxxxxxx&
PAYMENTINFO_0_SECUREMERCHANTACCOUNTID=xxxxxxx&
PAYMENTINFO_0_PAYMENTREQUESTID=200001&
PAYMENTINFO_0_ERRORCODE=0&
PAYMENTINFO_0_ACK=Success

交易ID和金额与第一个身份验证的响应中的相同。如何在没有PayPal的情况下进行多次授权,认为他们重复同一次?我对流量的理解不正确吗?如果是, 必要的流程是什么?

1 个答案:

答案 0 :(得分:1)

您不能使用相同的令牌多次调用DoExpressCheckoutPayment。您必须使用SetExpressCheckout再次启动整个流程以获取新令牌。

但是,真的,这听起来像你所追求的是“订单”。使用Order,而不是使用授权的付款操作。当使用PayPal完成“订单”时,您可以使用DoAuthorization和DoCapture运行多个身份验证和捕获。

有关详细信息,请参阅PayPal的How to Create and Process an Order Using Express Checkout文档。

您在结算协议中所做的是参考交易。如果用户通过授权您已经设置了计费协议,则可以随时运行DoReferenceTransaction以处理该人员所需的任何金额而无需进一步批准。这通常用于“自动送货”系统或“一键结账”类型的系统,其中保存了人的账单信息,因此他们无需在每次订购时再次输入。如果需要,您还可以使用此方法构建定期付款系统。

根据您的说法,听起来您不需要结算协议。您只需要执行快速结账订单。