Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal billing agreements REST API - how to start immediately

Tags:

paypal

How can I start charging a user the user immediately for a PayPal billing agreement?

Here's what I've got so far.

  1. Create a Billing Plan (POST .../payments/billing-plans/)
  2. Make it active (PATCH .../payments/billing-plans/)
  3. Create a Billing Aggreement (POST .../payments/billing-agreements/)
  4. Send user to approval_url, user approves, redirected to return url
  5. Execute agreement (POST .../payments/billing-agreements//agreement-execute)

This all seems to work, but I want to charge the user right now and every month in the future. If I set start_date to now in step 3 I get an error, it must be in the future. If I set it in the future the user is not charged.

Do I need to 'Set outstanding agreement amounts' then 'Bill outstanding agreement amounts' for the initial payment?

Also, what about monthly payments, do they require some action or do they just happen as specified in the Billing Plan?


Update

I'm testing this around 2014-09-16T20:06:30+0000

If I send start_date as the current UTC time it get an error at step 2 telling me it must be in the future.

If I send the current date +30 secs or +2 hours I get through to step 5 which returns a 400 response: UNKNOWN_ERROR "An unknown error has occurred"

If I send the current date +4 hours it all works. The current UTC time is 8pm so adding 4 hours means the start_date is tomorrow.

Does this mean I can't charge the user today? Does the start_date have to be in next day or even the next business day?

like image 950
Jake Avatar asked Sep 16 '14 00:09

Jake


People also ask

How do I set up PayPal REST API?

To get started with the PayPal REST API, first create a developer account on the Developer Dashboard. From there you can generate your credentials, authentication token and sandbox accounts.

Where is the billing agreement link in PayPal?

Finding the PayPal billing IDLog in to PayPal. In the top right corner, click the gear icon. Click PAYMENTS. Click Manage automatic payments.


2 Answers

I used this date format working.

  $time = time();
  $startDate = date('Y-m-d\\TH:i:s\\Z', $time);
like image 72
Harendra Singh Avatar answered Oct 14 '22 21:10

Harendra Singh


I've talked to a PayPal rep and found that start_date must be tomorrow or later. They are going to add this to the docs.

If you want to start monthly billing immediately you might be able to do it by setting the start date to be in one months time and charging a setup fee to cover the first month. I haven't tested this as it's not what I want.

like image 27
Jake Avatar answered Oct 14 '22 22:10

Jake