PayPal billing agreements REST API - how to start immediately

后端 未结 5 1139
抹茶落季
抹茶落季 2021-02-08 07:23

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 .../payment
相关标签:
5条回答
  • 2021-02-08 07:24

    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.

    0 讨论(0)
  • 2021-02-08 07:24

    First payment for agreements will be billed right on specified start_date. The subsequent amounts are also taken automatically by PP. You need to work with the BillOutstandingAmount calls only if PP failed to pick the payment on the renewal date.

    The problem I faced when developing with their RestAPI was specifying a wrong timezone. Maybe this is the same for you. Make sure the proper timezone is specified in your start_date (with all dates given to 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 being valid, just add a few seconds to it.

    Let's 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);
    }
    
    0 讨论(0)
  • 2021-02-08 07:24

    It looks like the payments just process based on the date being before or after 07:00 UTC of the current date.

    For example. The current date time is 2017-05-04T04:50:00.00Z I set my start date to be the current UTC date time plus 30 seconds. Because the agreement date is set to a value greater then the current date time the API doesn't throw an error, but it DOESN'T set your time to be what you specified. Instead it sets it to 2017-05-04T07:00:00Z.

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

    So it seems like these just process everyday at 07:00 UTC and you can't specify anything but the date.

    0 讨论(0)
  • 2021-02-08 07:29

    I can't replicate, actually. I stumbled on this thread when getting the error due to setting it to moment.now(). But setting it to even 5 seconds in the future works a-ok. I'm using JavaScript, "start_date": moment().add({seconds:5}).format() and that checks out fine. Moment.js will set TZ to UTC when formatting as such, so it's gotta be a timezone thing on your end?

    0 讨论(0)
  • 2021-02-08 07:35

    I used this date format working.

      $time = time();
      $startDate = date('Y-m-d\\TH:i:s\\Z', $time);
    
    0 讨论(0)
提交回复
热议问题