Reputation: 1853
I'd like to be able to test locally that the correct actions are taken when the trial period for a user ends.
I set up the Stripe CLI, and start listening:
stripe listen --forward-to http://localhost:8000/api/stripe-webhook
When a trial comes to an end, the customer.subscription.updated
event will occur.
I trigger this event using the Stripe CLI:
stripe trigger customer.subscription.updated
On my server side I can see that payload['data']['previous_attributes']
contains a metadata array with foo = null
. When a trial ends, we should get previous_attributes
containing something like: { "status": "trialing"...
I'm wondering if it's possible to trigger an event using the Stripe CLI that mimics a user trial ending (or maybe even just a way to set the previous_attributes
to similar values that'd occur in a live environment when a trial ends)? If it's possible to do that then it'd be a little easier to test locally that the appropriate action occurs when a trial ends without pushing to a prod-like environment.
Upvotes: 1
Views: 1576
Reputation: 7198
The easiest way is probably to just use trial_end
to set a very short trial period either when creating a subscription, or on an existing subscription, and wait a couple of minutes for it to end, at which point it will generate the appropriate events.
stripe subscriptions update sub_HpOl9vDMzIEfGf --trial-end=`date -v +5M +%s`
https://stripe.com/docs/billing/testing#trials
https://stripe.com/docs/api/subscriptions/update#update_subscription-trial_end
Upvotes: 5