Testing subscription renewals on Stripe
Asked Answered
H

3

20

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.

Hamulus answered 27/7, 2017 at 0:4 Comment(0)
F
13

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.

Ferromagnetism answered 30/6, 2021 at 9:13 Comment(0)
M
1

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.

Misprize answered 15/4, 2022 at 12:36 Comment(0)
L
0

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

Lionel answered 9/3, 2021 at 18:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.