Ad
Stripe Create Usage Record Error - Timestamp Must Be Before The Subscription's Current Period End Time - Date.now()?
I'm trying to create a stripe usage record for a customer on a metered plan.
When I'm using timestamp Date.now() in my request. The error I'm receiving is
"Cannot create the usage record with this timestamp because timestamps must be before the subscription's current period end time"
This seems self-explanatory. But given the subscription's current period end time isn't for another 14 days, how can Date.now() not be before this.
await stripe.usageRecords.create(
'si_EwzQ....',
{
quantity: 2,
timestamp: Date.now(),
action: 'set'
}
)
Is this because the current subscription period is a trial? Or have I misunderstood something here?
Ad
Answer
They're using a slightly different timestamp here. You must divide it by 1000.
So Date.now() / 1000
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad