PayPal Express Checkout API - Is there a way to process both recurring payment in one session using method CreateRecurringPaymentsProfile?

一曲冷凌霜 提交于 2019-12-29 08:10:10

问题


I tried to process two recurring payment in one session using method CreateRecurringPaymentsProfile. Here is the chronology of my actions:

First I set method SetExpressCheckout:

'METHOD'                        => 'SetExpressCheckout',
'RETURNURL'                     => $this->paypalreturnurl,
'CANCELURL'                     => $this->paypalcancelurl,
'PAYMENTREQUEST_0_CURRENCYCODE' => $this->paypalcurrencycode,
'PAYMENTREQUEST_0_PAYMENTACTION'=> 'SALE',
'L_BILLINGTYPE0'                => 'RecurringPayments',
'L_BILLINGAGREEMENTDESCRIPTION0'=> 'Tier 1 + Management Services',
'PAYMENTREQUEST_0_DESC'         => 'Tier 1 + Management Services',
'L_PAYMENTREQUEST_0_NAME0'      => 'Tier 1',
'L_PAYMENTREQUEST_0_NUMBER0'    => '10101',
'L_PAYMENTREQUEST_0_QTY0'       => '1',
'L_PAYMENTREQUEST_0_AMT0'       => '0.02',
'L_PAYMENTREQUEST_0_DESC0'      => 'Description of Tier 1',
'L_PAYMENTREQUEST_0_NAME1'      => 'Management Services 8 hours - for $0.01',
'L_PAYMENTREQUEST_0_NUMBER1'    => '212121',
'L_PAYMENTREQUEST_0_QTY1'       => '1',
'L_PAYMENTREQUEST_0_AMT1'       => '0.01',
'L_PAYMENTREQUEST_0_DESC1'      => 'Description of Management Services 8 hours - for $0.01',
'PAYMENTREQUEST_0_ITEMAMT'      => '0.03',
'PAYMENTREQUEST_0_AMT'          => '0.03'

After successful response from SetExpressCheckout method, the first recurring payment is executed successfully using CreateRecurringPaymentsProfile method. Here is the parameters:

'L_PAYMENTREQUEST_0_NAME0'      => 'Management Services 8 hours - for $0.01',
'PROFILEREFERENCE'              => 'RPInvoice1234',
'PROFILESTARTDATE'              => date('Y-m-d') . 'T' . date('H:i:s').'Z',
'SUBSCRIBERNAME'                => 'Mr Sub Scriber',
'TOKEN'                         => urlencode($token),
'DESC'                          => 'Tier 1 + Management Services',
'AMT'                           => '0.01',
'BILLINGPERIOD'                 => 'Month',
'BILLINGFREQUENCY'              => '1',
'TOTALBILLINGCYCLES'            => '12',
'REGULARTOTALBILLINGCYCLES'     => '1',
'VERSION'                       => '74.0',
'MAXFAILEDPAYMENTS'             => '1',
'L_PAYMENTREQUEST_0_AMT0'       => '0.01',
'INITAMT'                       => '0.01',
'L_PAYMENTREQUEST_0_NUMBER0'    => '212121',
'L_PAYMENTREQUEST_0_QTY0'       => '1',
'L_BILLINGTYPE0'                => 'RecurringPayments',
'L_BILLINGAGREEMENTDESCRIPTION0'=> 'Tier 1 + Management Services',
'L_PAYMENTREQUEST_0_ITEMCATEGORY0'=> 'Digital'

After the successful response from CreateRecurringPaymentsProfile method, I tried to create another recurring payment ( unfortunately without success ) using similar parameters and again CreateRecurringPaymentsProfile method:

'L_PAYMENTREQUEST_0_NAME0'      => 'Hosted Saas Tier 1',
'PROFILEREFERENCE'              => 'RPInvoice123',
'PROFILESTARTDATE'              => date('Y-m-d') . 'T' . date('H:i:s').'Z',
'SUBSCRIBERNAME'                => 'Mr Sub Scriber 2',
'TOKEN'                         => urlencode($token),
'DESC'                          => 'Hosted Saas Tier 1 + Community Management Services',
'AMT'                           => '0.02',
'BILLINGPERIOD'                 => 'Month',
'BILLINGFREQUENCY'              => '1',
'TOTALBILLINGCYCLES'            => '12',
'REGULARTOTALBILLINGCYCLES'     => '1',
'VERSION'                       => '74.0',
'MAXFAILEDPAYMENTS'             => '1',
'L_PAYMENTREQUEST_0_AMT0'       => '0.02',
'INITAMT'                       => '0.02',
'L_PAYMENTREQUEST_0_NUMBER0'    => '10101',
'L_PAYMENTREQUEST_0_QTY0'       => '1',
'L_BILLINGTYPE0'                => 'RecurringPayments',
'L_BILLINGAGREEMENTDESCRIPTION0'=> 'Hosted Saas Tier 1 + Community Management Services',
'L_PAYMENTREQUEST_0_ITEMCATEGORY0'=> 'Digital'

Unfortunately this method always return the same error, regardless the changes I made:

Profile description is invalid, L_ERRORCODE0 = 11581.

When I change the recurring payments order the same error appears for the first recurring payment with title "Management Services 8 hours - for $0.01" !? The problem is that every time second recurring returns the same error - "Profile description is invalid, L_ERRORCODE0 = 11581."

How can I get this working?


回答1:


You can only call CreateRecurringPaymentsProfile only one time in one session(one token). you should call SetExpressCheckout to get another token.




回答2:


Finally, with a little help from the PayPal support, I find a solution to create multiple recurring profiles in a single Express Checkout session:

  • First you must Pass both Profiles in SetExpressCheckout method (first method in my example), for example:

L_BILLINGTYPE0=RecurringPayments

L_BILLINGAGREEMENTDESCRIPTION0=Tier 1

and second product

L_BILLINGTYPE1=RecurringPayments

L_BILLINGAGREEMENTDESCRIPTION1=Management Services

  • And then, after buyer has approved both in PayPal, you need to call CreateRecurringPaymentsProfile twice:

One sending "DESC" with the value "Tier 1" and another one sending "DESC" with the value "Management Services"

Also check this



来源:https://stackoverflow.com/questions/32565213/paypal-express-checkout-api-is-there-a-way-to-process-both-recurring-payment-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!