node.js - Stripe API trial_end 10 seconds from now, environment independent -


i'm testing failing recurrent payments stripe api.

to make recurrent payment fail after subscription creation, subscription should have trial period , trial_end on customer creation should time or string 'now'.

it pass string 'now', card charged right on stripe.customers.create(), making fail isn't objective.

instead, tried pass current unix timestamp +10 seconds, seems machine clock set earlier on couple minutes stripe clock.

as result, trial_end 1454753552 , trial_start 1454753109 isn't 10 443 seconds.

is there other way make test environment independent changing system clock?

i'm using moment().unix() + 10 current unix time + 10 secs , nodejs.

i'm not sure there's clean way here. i'd create customer before call , @ created property on customer object. tells clock stripe's servers using. can calculate offset own clock , guess correct timestamp put in trial_end create trial period ends in 10 seconds.

i'd recommend against 10 seconds part because clocks in perfect sync, if call bit slow specific request trial end , prevent testing you're looking for. use 60 seconds delay decrease risk.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -