PayPal API REST Billing Agreements - Get Started Right Away

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

Here is what I have so far.

  • Create a tariff plan (POST ... / payments / billing-plans /)
  • Make it active (PATCH ... / payments / billing-plans /)
  • Create billing aggregation (POST ... / payments / billing agreements /)
  • Send user approval url, user approves, redirects to return url
  • Fulfill agreement (POST ... / payments / billing agreements // agreement-fulfill)

It all works, but I want to charge the user right now and every month in the future. If I set start_date in step 3, I get an error, it should be in the future. If I install it in the future, the user will not be charged.

Do I need to “Set Amounts of Unpaid Agreements” and then “Debt under a cashless agreement” for the initial payment?

In addition, with regard to monthly payments, do they need some action or do they just happen, as indicated in the Invoicing Plan?


Update

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

If I send start_date as the current UTC time, in step 2 an error message will appear, which should be in the future.

If I send the current date +30 seconds or +2 hours, I will go to step 5, which returns a 400 response: UNKNOWN_ERROR "An unknown error has occurred"

If I send the current date +4 hours, everything will work. The current UTC time is 8pm, so adding 4 hours means start_date will be tomorrow.

Does this mean that I can’t charge the user today? Should start_date be the next day or even the next business day?

+8
paypal
source share
4 answers

I spoke with a PayPal representative and found that start_date should be tomorrow or later. They are going to add this to the documents.

If you want to start the monthly newsletter immediately, you can do this by setting a start date of one month and charging a setup fee to cover the first month. I have not tested this since this is not what I want.

+6
source share

The first payment under agreements will be set only at the specified start_date. Subsequent amounts are also automatically accepted by the PP. You need to work with BillOutstandingAmount calls only if PP was unable to select a payment on the renewal date.

The problem I encountered while developing using RestAPI indicated the wrong time zone. Perhaps this is the same for you. Make sure the correct time zone is in your start_date (with all dates provided by PP in fact)

Dates should be in this format: yyyy-MM-ddTHH: mm: ssZ

ex. start_date = 2014-09-16T09: 20: 00 -0400

IF you want to make sure Paypal accepts the date as valid, just add a few seconds to it.

Say you are in Java, you can do something like:

 private String getPaypalDate() { DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); // Add 30 seconds to make sure Paypal accept the agreement date Date rightNow = new Date(new Date().getTime() + 30000); return df.format(rightNow); } 
+2
source share

In fact, I can not replicate. I came across this thread when I received an error due to setting it to moment.now() . But installation for 5 seconds in the future works a-ok. I am using JavaScript, "start_date": moment().add({seconds:5}).format() and this checks perfectly. Moment.js will set TZ to UTC when formatting as such, so should it be the time zone at your end?

0
source share

It appears that only the payment process is based on a date before or after 07:00 UTC of the current date.

For example. The current time is 2017-05-04T04: 50: 00.00Z. I set the start date for the current UTC time and 30 seconds. Since the agreement date is set to a value greater than the current time when the API does not throw an error, but does not set the time that you specified. Instead, he sets it at 2017-05-04T07: 00: 00Z.

Now, if you have the same time with the date 2017-05-04T04: 50: 00.00Z, and instead of adding 30 seconds you add 24 hours, you think that your time will be set to 2017-05-05T04: 50: 00.00 Z. But no, the time will be set on 2017-05-05T07: 00: 00Z.

So it looks like they are just being processed every day at 07:00 UTC, and you cannot specify anything other than a date.

0
source share

All Articles