#nstripe0_best-practices

1 messages ¡ Page 1 of 1 (latest)

gusty shuttleBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1265064849189376062

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

glossy geodeBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

gusty shuttleBOT
lucid breach
#

Hi there

#

You can create a Test Clock and create a Customer and Subscription within that "parent" clock. You can then advance the time on that Test Clock to see the objects (Invoices, PaymentIntents) and Events created when the Subscription cycles

idle flume
#

Hi roadrunner

If I try that with an existing subscription, would my subscription be deleted at the end of that test clock usage?

I think I tried that before and was surprised about that.

#

It looks like creating the Test Clock first is what is recommended, which seems like it implies the application would need to be modified to understand the concept of a test clock running when the customer and subscription are created?

lucid breach
#

the application would need to be modified to understand the concept of a test clock running when the customer and subscription are created?
What do you mean by this exactly?

idle flume
#

Our application's integration creates Stripe Customers and Stripe Subscriptions as part of users signing up and subscribing.

In order to create these associated to a test clock, it seems like our application integration code needs to be modified to understand that it is running under a Test Clock simulation?

#

This guide seems to assume that we would be simulating directly on the Stripe Dashboard, rather than our application.

lucid breach
#

In step 1, you should see "Dashboard" and "API" tabs; select "API" in this case

#

it seems like our application integration code needs to be modified to understand that it is running under a Test Clock simulation?
Yes, you'll need to create a Test Clock first: https://docs.stripe.com/api/test_clocks/create
Then create a Customer and pass a value for test_clock: https://docs.stripe.com/api/customers/create#create_customer-test_clock
Lastly, create a Subscription for that Customer

It's not possible to programmatically update an existing Customer (or Subscription) to use a Test Clock.

idle flume
#

I think that's what I tried before on an existing Subscription.

lucid breach
#

I see, okay. But yes, Test Clocks are the way to go here. The page you shared is specifically for Dashboard testing

idle flume
#

Ok, I think when I tried that before, my Stripe Subscription and Stripe Customer ended up being deleted after running a simulation. That was the part that surprised me.

I'll give it a try again to see if I can better understand how to use this.

lucid breach
#

Got it. Yes, if you click "Finish simulation", the Customer and Subscription objects will be deleted

idle flume
#

Is there a way to finish a simulation without having it delete the objects?

lucid breach
#

You don't have to click "finish a simulation". Leaving the simulation in a frozen time/state doesn't hurt anything and you can always come back to those objects (within the 90 day retention period) or delete them manually

#

Or you can mark a test mode Subscription exempt from retention

idle flume
#

I see, that's helpful, thank you.

lucid breach
#

Happy to help!