Test clocks. They're made for exactly this.
- Create a test clock (Dashboard > Billing > Test clocks, or
stripe.testHelpers.testClocks.create({ frozen_time })). - Create a customer attached to the clock (
test_clock: clock.id) and a subscription for them with your real monthly price. - Advance the clock by a month. Stripe generates the renewal invoice, attempts payment, and fires
invoice.created,invoice.paid,customer.subscription.updated, same as in real life.
Use the 4000 0000 0000 0341 test card (attaches fine, fails on charge) to test the failed renewal path too.
One gotcha: when you advance, events arrive in a burst. If your handler assumes order, you'll find out here, which is a good thing.
billing_reason === 'subscription_cycle'now. tuan_ng · editedbilling_reasonis so useful, thanks for posting the follow-up bug. marco_py · edited