Tell PayPal to automatically process the monthly p

2019-03-06 18:08发布

ref: https://stackoverflow.com/a/25730860/2735734

How to Tell PayPal to automatically process the monthly payment?

UPDATE 1

here is the PayPal Reponses:

CreateAgreement result:

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

AND after the client approved.

ExecuteAgreement result:

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

note the start_date for the first reponse to the second...

The first payement isn't made... (And I don't know for the other, I've try today with a daily payement... I have to wait now...)

In the Pre-Approved area on the Sandbox Account, is in Active and inform about next billing correctly.

1条回答
Melony?
2楼-- · 2019-03-06 19:06

Once the user completes and submits subscription purchase page you have created, the subscription will begin and will automatically rebill the customer's account on whatever interval you have selected. You do not have to do anything.

Updated: The REST API also automatically processes subscriptions. You do not have to resubmit monthly. The PayPal sandbox was updated in July of this year to enable you to test and process subscriptions. There are no issues being reported in the dev community about this not working, so I suspect it is something on your side.

If you haven't already. please review this:

https://developer.paypal.com/docs/integration/direct/test-the-api/

There are billing plan and billing subscription sections. If you still have a problem, post your billing plan code and the response you are receiving.

查看更多
登录 后发表回答