Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal-node-SDK `Subscription start date should be greater than current date` always occurs after 12 am

I live in Hong Kong and I always get this sandbox paypal transaction error after midnight from paypal.billingAgreement.execute(). The error goes away in the afternoon, probably because the place where paypal server is located finally gets past the 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 problem with the sandbox environment but I can't figure out how to solve it.

My billing agreement is created as per the example in 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 have set the TZ environment variable in nodes to utc;

The time zone setting of the sandbox account I use to log in and subscribe:

enter image description here

I've also tried different zones like Eastern Time but it has no effects.

like image 528
RedGiant Avatar asked Oct 29 '22 21:10

RedGiant


1 Answers

As per PayPal Docs, StartDate should be UTC, looks Setting Process Time Zone

 process.env.TZ = 'utc';

has no effect in your code(some time it might be cashed), can you check the date variable value is in UTC?

I would suggest to change

var isoDate = new Date();

to

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

Hope it helps!

like image 69
H. Mahida Avatar answered Nov 03 '22 12:11

H. Mahida