Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 475
Greeso Avatar asked Jul 27 '17 00:07

Greeso


People also ask

Can I use Stripe for testing?

Testing paymentsYou can issue cards and simulate purchases using your own Stripe integration in test mode. This allows you to test your integration before you go live without having to make real purchases. You can only use these cards for testing within your Stripe account and not for external purchases.

How do you do test payments on Stripe?

Viewing Test Transactions in Your Stripe Account To begin, you'll need to log in to your Stripe account. Then click on Payments in the menu at the top of the screen. Next, near the top right corner of the screen, toggle on the Test Mode option.

How do I know if my Stripe subscription is active?

To your actual question, to find any active subscriptions on that customer, you can look at the subscriptions property on the customer response (https://stripe.com/docs/api#customer_object).


1 Answers

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.

like image 113
Marc Avatar answered Sep 20 '22 08:09

Marc