'Testing subscription renewals on Stripe

I am using Stripe to test how my code would react to recurring subscription renewal payment attempts for a product we are working on (need to test success, failure ...etc.). And it seems that most answers on StackOverflow suggest creating a subscription with a recurring payment of 1 day (which is the minimum recurring payment available at Stripe), and waiting until next day to see how my code would react to the webhook notifications. (By the way, I could not find much documentation on Stripe to suggest testing methodologies for recurring payment).

I do not agree much with this approach, because it stretches the testing of my code to more than a week, maybe even two, but in normal conditions I might finish that testing within a couple of hours.

I think one of the following two approaches would be sufficient to do my coding/testing.

  1. Find a way to make recurring subscription interval happen on shorter custom periods, such as every 15 minutes, or every 10 minutes.

  2. A better solution is to make recurring subscriptions trigger on demand. That is, I create a subscription, and then I would update the date for the next renewal manually to a custom value, such as "1 minute in the future" or "30 seconds in the future" which would trigger the payment attempt.

Is there a way of doing any of those two options in Stripe? If neither is a viable option, how do I test recurring payments efficiently.

Thanks.



Solution 1:[1]

Our solution was to reset the billing cycle of the subscription.

  • open the subscription in Stripe
  • click "Actions" in the upper right
  • select "Update Subscription"
  • be sure to switch off "Prorate changes"
  • scroll down and open "Advanced Options"
  • check "Reset billing cycle"
  • and finally... Update Subscription

This will trigger a new subscription payment and all the associated webhooks.

Solution 2:[2]

So I would start with their testing documentation It walks you through the process.

it seems that you can trigger events on the fly with CLI commands.

Also look at the Webhook Monitor

Solution 3:[3]

Simple method

Definitely @Marc found the great option for arbitrarily subscription renewal. The same action he described in this answer can be done programmatically or with the Stripe CLI:

stripe subscriptions update sub_id \
  --proration-behavior=none \
  --billing-cycle-anchor=now

This command generates the following sequence of events:

charge.succeeded
invoice.finalized
invoice.created
invoice.paid
invoice.payment_succeeded
customer.subscription.updated
payment_intent.succeeded
payment_intent.created

Advanced method

The use of test clock gives more opportunities to verify your system's behavior. It is possible to attach test clock not only to the Subscription object.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marc
Solution 2 Wrenbjor
Solution 3