如何在 Paypal 中设置定期付款和一次性付款的混合
Posted
技术标签:
【中文标题】如何在 Paypal 中设置定期付款和一次性付款的混合【英文标题】:How to set mixture of recurring and one time payment in Paypal 【发布时间】:2014-11-17 18:36:44 【问题描述】:我正在使用 Paypal REST API 来收取订阅费用。 我的交易包括一次性购买和定期付款的混合。一次购买将向用户收取 X 金额,并且定期付款应创建定期资料,该资料每年将向用户收取 Y 金额。
这就是我所拥有的。首先我使用以下参数调用SetExpressCheckoutPayment
:
$orderParams = array(
'PAYMENTREQUEST_0_AMT' => "10",
'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP',
'PAYMENTREQUEST_0_ITEMAMT' => "10",
'LOGOIMG'=>"http://mywebsite.com/a.jpg",
"MAXAMT"=>"100",
"NOSHIPPING"=>"1",
"ALLOWNOTE"=>"0",
"BRANDNAME"=>"My website",
"GIFTRECEIPTENABLE"=>"0",
"GIFTMESSAGEENABLE"=>"0"
);
$item = array(
'L_PAYMENTREQUEST_0_NAME0' => 'Subscription',
'L_PAYMENTREQUEST_0_DESC0' => 'Subscription bla bla bla',
'L_PAYMENTREQUEST_0_AMT0' => "10",
'L_PAYMENTREQUEST_0_QTY0' => '1',
);
$recurringPayment=array();
$recurringPayment=array(
"L_BILLINGTYPE0"=>"RecurringPayments",
"L_BILLINGAGREEMENTDESCRIPTION0"=>""
);
在上面的代码中我不知道的是如何设置循环付款的金额 Y 与一次性付款的金额 X 不同?
在执行SetExpressCheckoutPayment
之后,我执行DoExpressCheckoutPayment
,然后我调用CreateRecurringPaymentsProfile
并使用以下参数:
$requestParams=array(
"TOKEN"=>$token,
"PROFILESTARTDATE"=>date("Y-m-d\TH:i:s\Z"),
"DESC"=>"My Subscription",
"BILLINGPERIOD"=>"Year",
"BILLINGFREQUENCY"=>"1",
"AMT"=>"94",
"CURRENCYCODE"=>"GBP",
"L_PAYMENTREQUEST_0_ITEMCATEGORY0"=>"Digital",
"L_PAYMENTREQUEST_0_NAME0"=>"Subscription",
"L_PAYMENTREQUEST_0_AMT0"=>"10",
"L_PAYMENTREQUEST_0_QTY0"=>"1",
);
$response=$paypal->request("CreateRecurringPaymentsProfile",$requestParams);
创建了定期配置文件,但会向用户收取 X 的费用,我不希望这样。
以下是回复:
来自SetExpressCheckout
的回复
array (size=50)
'TOKEN' => string 'EC-0G8072749' (length=20)
'BILLINGAGREEMENTACCEPTEDSTATUS' => string '1' (length=1)
'CHECKOUTSTATUS' => string 'PaymentActionNotInitiated' (length=25)
'TIMESTAMP' => string '2014-09-23T16:57:24Z' (length=20)
'CORRELATIONID' => string 'c0b0e1a38cd36' (length=13)
'ACK' => string 'Success' (length=7)
'VERSION' => string '74.0' (length=4)
'BUILD' => string '12932421' (length=8)
'EMAIL' => string 'customer-sandbox@dwa.ca' (length=27)
'PAYERID' => string 'KKBJKUR86XT8L' (length=13)
'PAYERSTATUS' => string 'verified' (length=8)
'FIRSTNAME' => string 'John' (length=4)
'LASTNAME' => string 'Doe' (length=3)
'COUNTRYCODE' => string 'GB' (length=2)
'CURRENCYCODE' => string 'GBP' (length=3)
'AMT' => string '94.00' (length=5)
'ITEMAMT' => string '94.00' (length=5)
'SHIPPINGAMT' => string '0.00' (length=4)
'HANDLINGAMT' => string '0.00' (length=4)
'TAXAMT' => string '0.00' (length=4)
'INSURANCEAMT' => string '0.00' (length=4)
'SHIPDISCAMT' => string '0.00' (length=4)
'L_NAME0' => string 'My Subscription' (length=27)
'L_QTY0' => string '1' (length=1)
'L_TAXAMT0' => string '0.00' (length=4)
'L_AMT0' => string '94.00' (length=5)
'L_DESC0' => string 'My Subscription' (length=34)
'L_ITEMWEIGHTVALUE0' => string ' 0.00000' (length=10)
'L_ITEMLENGTHVALUE0' => string ' 0.00000' (length=10)
'L_ITEMWIDTHVALUE0' => string ' 0.00000' (length=10)
'L_ITEMHEIGHTVALUE0' => string ' 0.00000' (length=10)
'PAYMENTREQUEST_0_CURRENCYCODE' => string 'GBP' (length=3)
'PAYMENTREQUEST_0_AMT' => string '94.00' (length=5)
'PAYMENTREQUEST_0_ITEMAMT' => string '94.00' (length=5)
'PAYMENTREQUEST_0_SHIPPINGAMT' => string '0.00' (length=4)
'PAYMENTREQUEST_0_HANDLINGAMT' => string '0.00' (length=4)
'PAYMENTREQUEST_0_TAXAMT' => string '0.00' (length=4)
'PAYMENTREQUEST_0_INSURANCEAMT' => string '0.00' (length=4)
'PAYMENTREQUEST_0_SHIPDISCAMT' => string '0.00' (length=4)
'PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED' => string 'false' (length=5)
'L_PAYMENTREQUEST_0_NAME0' => string 'My Subscription' (length=27)
'L_PAYMENTREQUEST_0_QTY0' => string '1' (length=1)
'L_PAYMENTREQUEST_0_TAXAMT0' => string '0.00' (length=4)
'L_PAYMENTREQUEST_0_AMT0' => string '94.00' (length=5)
'L_PAYMENTREQUEST_0_DESC0' => string 'My Subscription' (length=34)
'L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0' => string ' 0.00000' (length=10)
'L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0' => string ' 0.00000' (length=10)
'L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0' => string ' 0.00000' (length=10)
'L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0' => string ' 0.00000' (length=10)
'PAYMENTREQUESTINFO_0_ERRORCODE' => string '0' (length=1)
GetExpressCheckoutDetails
的回复
array (size=25)
'TOKEN' => string 'EC-0G807275JM0847749' (length=20)
'SUCCESSPAGEREDIRECTREQUESTED' => string 'false' (length=5)
'TIMESTAMP' => string '2014-09-23T16:57:27Z' (length=20)
'CORRELATIONID' => string '5b9de22225c55' (length=13)
'ACK' => string 'Success' (length=7)
'VERSION' => string '74.0' (length=4)
'BUILD' => string '12932421' (length=8)
'INSURANCEOPTIONSELECTED' => string 'false' (length=5)
'SHIPPINGOPTIONISDEFAULT' => string 'false' (length=5)
'PAYMENTINFO_0_TRANSACTIONID' => string '1SV99367CG387745H' (length=17)
'PAYMENTINFO_0_TRANSACTIONTYPE' => string 'expresscheckout' (length=15)
'PAYMENTINFO_0_PAYMENTTYPE' => string 'instant' (length=7)
'PAYMENTINFO_0_ORDERTIME' => string '2014-09-23T16:57:26Z' (length=20)
'PAYMENTINFO_0_AMT' => string '94.00' (length=5)
'PAYMENTINFO_0_FEEAMT' => string '3.40' (length=4)
'PAYMENTINFO_0_TAXAMT' => string '0.00' (length=4)
'PAYMENTINFO_0_CURRENCYCODE' => string 'GBP' (length=3)
'PAYMENTINFO_0_PAYMENTSTATUS' => string 'Completed' (length=9)
'PAYMENTINFO_0_PENDINGREASON' => string 'None' (length=4)
'PAYMENTINFO_0_REASONCODE' => string 'None' (length=4)
'PAYMENTINFO_0_PROTECTIONELIGIBILITY' => string 'Ineligible' (length=10)
'PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE' => string 'None' (length=4)
'PAYMENTINFO_0_SECUREMERCHANTACCOUNTID' => string 'EW93XTSE5SR4G' (length=13)
'PAYMENTINFO_0_ERRORCODE' => string '0' (length=1)
'PAYMENTINFO_0_ACK' => string 'Success' (length=7)
来自CreateRecurringPayment
的回复
array (size=9)
'TIMESTAMP' => string '2014-09-23T16:57:28Z' (length=20)
'CORRELATIONID' => string 'dd1f80a935b65' (length=13)
'ACK' => string 'Failure' (length=7)
'VERSION' => string '74.0' (length=4)
'BUILD' => string '12932421' (length=8)
'L_ERRORCODE0' => string '10004' (length=5)
'L_SHORTMESSAGE0' => string 'Cart item calculation mismatch.' (length=31)
'L_LONGMESSAGE0' => string 'Cart item calculation mismatch. The regular non-trial billing period amount is different than the sum of the amounts for each item in the cart.' (length=143)
'L_SEVERITYCODE0' => string 'Error' (length=5)
谢谢!
【问题讨论】:
【参考方案1】:您必须在“CreateRecurringPaymentsProfile”API 中指定的经常性金额,您在“SetExpressCheckoutPayment”和“DoExpressCheckoutPayment”中设置的金额是一次性付款。
因此,经常性金额始终需要在“CreateRecurringPaymentsProfile”API 中传递。
【讨论】:
是的,但是这个金额应该不同于一次性付款。如果一次性付款为 X,则经常性金额应为 Y。当我将经常性金额设置为 Y 时,我收到以下消息:“购物车项目计算不匹配。常规非试用计费期金额与金额总和不同购物车中的每件商品。” 您能否在此处粘贴完整的 PayPal 响应以了解该错误? 所以在本例中您的一次性付款是 94 美元,而定期付款是 50 美元? 是的,我只想向用户收取 94 美元的费用,然后创建定期配置文件,每年向用户收取 50 美元的费用。 任何想法都会很有帮助!以上是关于如何在 Paypal 中设置定期付款和一次性付款的混合的主要内容,如果未能解决你的问题,请参考以下文章