Paypal Preapproval Start Date Time Zone?

I am setting up the application using Paypal Adaptive Payments.

I am currently making a call to Preapproval, and the specification states that StartDate cannot be until today.

With that in mind ... under which time zone do they check it against?

The SDK API has this in the following example:

$currDate = getdate(); $startDate = $currDate['year'].'-'.$currDate['mon'].'-'.$currDate['mday']; $startDate = strtotime($startDate); $startDate = date('Ym-d', mktime(0,0,0,date('m',$startDate),date('d',$startDate),date('Y',$startDate))); $endDate = add_date($startDate, 1); 

However, this date may vary depending on the time zone of the server sending the request.

Anyone have any ideas on how to ensure no problems?

Change w / Bounty:

As of December 15th, we ran into this as a mistake. We use UTC time, and as soon as it starts a new day in UTC, payments will start to fail.

I use the above code in the following place:

 $preapprovalRequest->startingDate = $startDate; $preapprovalRequest->endingDate = $endDate; 

What do I need to do this job?

Edit 2:

Yes, the time zone is configured as UTC, we did it intentionally so that all time information in our database is stored without a time zone.

Essentially, I'm trying to figure out how to indicate that the date I'm sending to Paypal is in UTC, and not the time zone in which they ended up.

Edit 3:

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APPreapproval

There is an API and it says the following

Source and destination dates can be in eiter Zulu or GMT offset formats. as in the following examples: 2010-09-10Z 2010-09-10T17: 24: 03.874-07: 00

Essentially, I need the code above to output something like this, determining that I am using UTC ...

+6
source share
2 answers

PHP time functions are based on system time ( http://us.php.net/manual/en/intro.datetime.php ). Are you sure your system is set to use UTC time? You can check the following:

 mpurcell@service1 ~/projects/config $ -> date Thu Dec 15 23:29:09 UTC 2011 

Pay attention to UTC in the answer. If your system is configured for some other time zone, this may be your problem, if you need to set the time zone in UTC, try:

 $ rm -f /etc/localtime $ ln -s /usr/share/zoneinfo/UTC /etc/localtime 

Also make sure your system time is corrected using the network time protocol:

 $ ntpdate -b pool.ntp.org 

- Change -

Based on your changes, it looks like they are expecting time in either Zulu (append Z) or GMT with an offset (more complex), try the following:

 $preapprovalRequest->startingDate = $startDate . 'Z'; $preapprovalRequest->endingDate = $endDate . 'Z'; 
+2
source

The api documentation says that it uses GMT or Zulu time by wire and expects it to have a final ā€œZā€ to indicate this (according to ISO 8601).

Additional Notes on PreApproval API Operation

  • The prevailing constraints are additive; thus, for example, if you specify a preapproval that allows payments only on Fridays and on the 13th day of the month, preapproval will be valid only on Friday 13 months during the specified time period.
  • StartDate and endDate can be in eiter Zulu or GMT offset formats. as in the following examples:

2010-09-10Z [NOTE: THIS IS A ZULU]

2010-09-10T17:24:03.874-07:00 [NOTE: 2010-09-10T17:24:03.874-07:00 TIME]

The safest to use is probably the following:

 $startingDate = gmdate('Ymd\Z', $startingDateTimestamp); 

However, you must be absolutely sure that your own server time zone (and time!) Is set correctly. You may also need to set the time zone separately in your PHP application using date_default_timezone_set() .

Finally, there is another wrinkle - I do not know which SDK you are using. Perhaps he is trying to be smart and changing the date when you go through something else. In this case, you need to find out what date translation he is doing and what date he is expecting. (For example, perhaps he expects a date in system local time and changes it to UTC.) Assuming this does not change what you supply, you should be able to use the code above.

+7
source

Source: https://habr.com/ru/post/901335/


All Articles