参考:https://stackoverflow.com/a/25730860/2735734
如何告诉PayPal自动处理每月付款?
这是PayPal回复:
CreateAgreement结果:
array (
'name' => 'my name',
'description' => 'my description',
'plan' =>
array (
'id' => 'P-95307423V8719480UI4T4SGG',
'state' => 'ACTIVE',
'name' => 'title here',
'description' => 'description here',
'type' => 'INFINITE',
'payment_definitions' =>
array (
0 =>
array (
'id' => 'PD-140035022V340531AI4T4SGG',
'name' => 'Regular Payments',
'type' => 'REGULAR',
'frequency' => 'Month',
'amount' =>
array (
'currency' => 'USD',
'value' => '15.5',
),
'cycles' => '0',
'charge_models' =>
array (
0 =>
array (
'id' => 'CHM-9G272533RU378412KI4T4SGG',
'type' => 'TAX',
'amount' =>
array (
'currency' => 'USD',
'value' => '1',
),
),
),
'frequency_interval' => '1',
),
),
'merchant_preferences' =>
array (
'setup_fee' =>
array (
'currency' => 'USD',
'value' => '0',
),
'max_fail_attempts' => '0',
'return_url' => 'http://example.com/ok',
'cancel_url' => 'http://example.com/cancel',
'auto_bill_amount' => 'YES',
'initial_fail_amount_action' => 'CONTINUE',
),
),
'links' =>
array (
0 =>
array (
'href' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-4N736816FP8632455',
'rel' => 'approval_url',
'method' => 'REDIRECT',
),
1 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/EC-4N736816FP8632455/agreement-execute',
'rel' => 'execute',
'method' => 'POST',
),
),
'start_date' => '2014-10-25T11:54:20-00:00',
)
在客户批准后。
ExecuteAgreement结果:
array (
'id' => 'I-CD3VD66KJKXX',
'state' => 'Active',
'description' => 'my description',
'plan' =>
array (
'payment_definitions' =>
array (
0 =>
array (
'type' => 'REGULAR',
'frequency' => 'Month',
'amount' =>
array (
'currency' => 'USD',
'value' => '15.50',
),
'cycles' => '0',
'charge_models' =>
array (
0 =>
array (
'type' => 'TAX',
'amount' =>
array (
'currency' => 'USD',
'value' => '1.00',
),
),
1 =>
array (
'type' => 'SHIPPING',
'amount' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
),
),
'frequency_interval' => '1',
),
),
'merchant_preferences' =>
array (
'setup_fee' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
'max_fail_attempts' => '0',
'auto_bill_amount' => 'YES',
),
),
'links' =>
array (
0 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/suspend',
'rel' => 'suspend',
'method' => 'POST',
),
1 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/re-activate',
'rel' => 're_activate',
'method' => 'POST',
),
2 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/cancel',
'rel' => 'cancel',
'method' => 'POST',
),
3 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/bill-balance',
'rel' => 'self',
'method' => 'POST',
),
4 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/set-balance',
'rel' => 'self',
'method' => 'POST',
),
),
'start_date' => '2014-10-25T07:00:00Z',
'agreement_details' =>
array (
'outstanding_balance' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
'cycles_remaining' => '0',
'cycles_completed' => '0',
'next_billing_date' => '2014-10-25T10:00:00Z',
'final_payment_date' => '1970-01-01T00:00:00Z',
'failed_payment_count' => '0',
),
)
请注意第一个响应的start_date到第二个...
第一笔付款还没有......(我不知道另一个,我今天每天都要付钱......我现在要等...... )
在沙盒帐户的预批准区域中,处于有效状态并正确通知下一个结算。
答案 0 :(得分:1)
用户完成并提交您创建的订阅购买页面后,订阅将开始,并将在您选择的任何时间间隔内自动重新生成客户的帐户。你不需要做任何事情。
更新:REST API还会自动处理订阅。您不必每月重新提交。 PayPal沙箱于今年7月更新,使您能够测试和处理订阅。开发社区没有关于这个问题的报道没有问题,所以我怀疑它是你的一面。
如果你还没有。请查看:
https://developer.paypal.com/docs/integration/direct/test-the-api/
有结算方案和结算订阅部分。如果您仍有问题,请发布您的结算方案代码和您收到的回复。