#linhwin

1 messages ยท Page 1 of 1 (latest)

shut heartBOT
#

Hello! We'll be with you shortly. 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.

  • linhwin, 15 minutes ago, 2 messages
drifting storm
#

curl https://api.stripe.com/v1/subscription_schedules
-u sk_t547fgu6u6u6urt6u32322:
-d from_subscription="{EXISTING_SUBSCRIPTION_ID}"
-X POST

That's the curl I'm using to set a subscription schedule to the subscription after a successful payment comes through.

drifting pebble
#

Hello again ๐Ÿ‘‹ did you happen to see my earlier message on the thread I created previously? I'll need more context on how you're currently trying to approach this, and what behavior/errors you're running into.

#

You should roll that secret key now that it has been shared publicly.

drifting storm
#

I'll roll it right now

drifting pebble
#

๐Ÿ‘ and so what's the problem that you're running into with the Subscription Schedule flow? It is expected that you'll need to make two requests for that process, one to create the Subscription Schedule from the Subscription, and then a second to update the newly created Subscription.

drifting storm
#

I cant seem to modify the current phase after creating the subscription schedule

#

the api wont let me

#

I tried another way too like this to end the current phase and start a new one immediately and it didnt work either

curl https://api.stripe.com/v1/subscription_schedules/<SCHEDULE_ID>
-u <YOUR_SECRET_KEY>:
-d phases[0][items][0][price]=<CURRENT_PRICE_ID>
-d phases[0][items][0][quantity]=<CURRENT_QUANTITY>
-d phases[0][end_date]="now"
-d phases[1][items][0][price]=<NEW_PRICE_ID>
-d phases[1][items][0][quantity]=<NEW_QUANTITY>
-d phases[1][iterations]=<NUMBER_OF_ITERATIONS>
-d phases[1][start_date]="now"
-X POST

drifting pebble
#

What do you mean by "it didn't work"? Did you receive an error? If so, what did it say? Or did the request complete successfully but didn't do what you were hoping?

drifting storm
#

I'm stuck on the updating the subscription schedule part. I dont care how we do it, I just want to be able to control the number of iterations it suns

#

In the example above, I got this error:

"message": "The subscription schedule update is missing at least one phase with a start_date to anchor end dates to.",

drifting pebble
#

Can you share the ID of the request (req_) that returned that request to you? So I can actually see what your code is doing/passing to us.
https://support.stripe.com/questions/finding-the-id-for-an-api-request

drifting storm
#

sure one min

#

req_xwZ6DCfEwCx7dB?t=1702484874

drifting pebble
#

Thank you, I think I see what's happening. It looks like the system didn't detect enough timestamps to know how to bound the schedule's phases. It's a little silly, because I'm pretty sure we won't let you update the start date of phase[0] (the current phase) but still expect you to provide it.

Can you try making that request again, but this time pass in phases[0][start_date] and set it to the same timestamp that's currently set to on the Subscription Schedule?

drifting storm
#

let me try

#

it finally worked

#

Since it is ending the current phase and starting a new one immediately, will the customer get charged twice? How does it work on that end?

drifting pebble
#

Do you see the customer getting charged again in your testing? If you aren't making a change that pushes the Subscription into its next billing period, then I'm pretty sure you won't see them charged when you update the Subscription Schedule.

drifting storm
#

nope I dont see them get charged

shut heartBOT
drifting storm
#

so theoritically, if I do all of this on the same day, nothing changes on the customer end, other than the fact that their subscription have an end time now instead of running indefinitely?

#

doing all of this on the same day meaning charging a subscription via stripe checkout and then converting it into a subscription schedule with an end date

drifting pebble
#

Yes, that sounds right, but I'd recommend testing to ensure. There are a lot of settings that can be used to change the behavior of Subscriptions, and it's hard to talk through every possible one and how it's currenlty set up for your account/integration.

I would recommend using our Test Clocks, which allow you to create Subscriptions inside of sandboxes where you can advance time, to test the full lifecycle of the approach you're using and make sure it behaves exactly as you're hoping:
https://stripe.com/docs/billing/testing/test-clocks

Learn how to move Billing objects through time in test mode.

drifting storm
#

that's a good idea, thank you toby