PayPal- node -SDK `Subscription Start Date Must Be Greater Than Current Date" always occurs after 12 a.m.

I live in Hong Kong and I always get this sandbox transactional transaction after midnight from paypal.billingAgreement.execute() . The error goes away during the day, possibly because the place where the PayPal server is located finally ends at midnight.

 { name: 'SUBSCRIPTION_UNMAPPED_ERROR', message: 'Subscription start date should be greater than current date', information_link: 'https://developer.paypal.com/docs/api/payments.billing-agreements#errors', debug_id: 'd2e618eef4162', httpStatusCode: 400 }, 

I know this is a timezone issue in the sandbox environment, but I cannot figure out how to solve it.

My billing agreement is created as an example in the PayPal-node-SDK

 process.env.TZ = 'utc'; var isoDate = new Date(); isoDate.setSeconds(isoDate.getSeconds() + 4); isoDate.toISOString().slice(0, 19) + 'Z'; var billingAgreementAttributes = { "start_date": isoDate, /..../ } 

I set the TZ environment variable in nodes on utc ;

Setting the time zone for the sandbox account that I use to login and sign:

enter image description here

I also tried different zones, such as Eastern Time , but it has no effects.

+5
source share
1 answer

According to the PayPal docs, StartDate should be UTC, the process time zone setting looks like

  process.env.TZ = 'utc'; 

doesn’t affect your code (it can be cashed out for some time), can you check the value of the date variable in UTC format?

I suggest changing

 var isoDate = new Date(); 

to

 var isoDate = new Date().toISOString(); 

Hope this helps!

+2
source

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


All Articles