Background
I have a script that creates subscriptions for customers using the Node.js Stripe API.
Code
After reading the documentation on how to create subscriptions I have arrived at the following code:
var stripe = require( "stripe" )( "my_TestKey" );
stripe.subscriptions.create({
"customer":"myCustomer",
"billing":"charge_automatically",
"trial_end":"1509186774",
"items": [ {"plan":"mySubscription"} ]
})
.then( console.log )
.catch( console.error );
Problem
However, this subscription fails with the following error:
"error":{"type":"StripeInvalidRequestError","stack":"Error: Invalid timestamp: must be an integer Unix timestamp in the future.\n at Constructor._Error ...
What I tried
So, I assumed that my error was in the trial_end field, and so I double checked the timestamp in the following websites:
Which both convert it successfully to a date. I also tried making the request with the date in milliseconds but then it obviously didn't work.
Question
- What am I missing? Why is stripe considering that field a non-valid one?
The timestamp
1509186774is for Saturday, 28 October 2017. Thetrial_endparameter must for a date in the future — maybe you meant to use 28 October 2018, which is1540722774.