PayPal Express Checkout API - 有没有办法使用方法CreateRecurringPaymentsProfile在一个会话中处理定期付款?

时间:2015-09-14 12:47:09

标签: php paypal express-checkout recurring

我尝试使用方法CreateRecurringPaymentsProfile在一个会话中处理两个定期付款。以下是我的行动的年表:

首先我设置方法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'

在使用SetExpressCheckout方法成功响应后,使用CreateRecurringPaymentsProfile方法成功执行第一次定期付款 。这是参数:

'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'

在CreateRecurringPaymentsProfile方法成功回复后,我尝试使用类似的参数创建另一个定期付款(不幸但没有成功),并再次创建CreateRecurringPaymentsProfile方法:

'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'

不幸的是,无论我做了哪些更改,此方法始终返回相同的错误:

  

个人资料说明无效,L_ERRORCODE0 = 11581。

当我更改定期付款订单时,首次定期付款时出现同样的错误,标题为“管理服务8小时 - 仅需0.01美元”!问题是每次第二次重复都会返回相同的错误 - “配置文件描述无效,L_ERRORCODE0 = 11581。”

我怎样才能使这个工作?

2 个答案:

答案 0 :(得分:1)

您只能在一个会话中调用CreateRecurringPaymentsProfile一次(一个令牌)。你应该调用SetExpressCheckout来获取另一个令牌。

答案 1 :(得分:1)

最后,在PayPal支持的帮助下,我找到了在单个Express Checkout会话中创建多个重复配置文件的解决方案:

  • 首先,您必须在SetExpressCheckout方法中传递两个配置文件(首先 我的例子中的方法),例如:
  

L_BILLINGTYPE0 = RecurringPayments

     

L_BILLINGAGREEMENTDESCRIPTION0 =第1层

和第二个产品

  

L_BILLINGTYPE1 = RecurringPayments

     

L_BILLINGAGREEMENTDESCRIPTION1 =管理服务

  • 然后,在买家同意批准PayPal后,您需要两次调用CreateRecurringPaymentsProfile

一个发送值为“Tier 1”的“DESC”,另一个发送值为“Management Services”的“DESC”

Also check this