#Vishakvkt
1 messages · Page 1 of 1 (latest)
Hi 👋 can you elaborate on the full desired behavior you're looking for is?
Sure. Here is an example:
On the 14th of April 2023, say a customer purchases a subscription which costs $100.
This subscription needs to be renewed on the 31st of December 2023.
Irrespective of what date of the year the customer purchases the subscription, their renewal date will always be 31st December 2023 and the cost will be $100.
In stripe, I have created a price with a yearly renewal of $100.
As it stands, If I set the billing_cycle_anchor to the 31st of Dec 2023, the subscription generates an invoice with a prorata payment of ~$72. We don't want that. It should be $100
Gotcha, I think you'll want to use a Subscription Schedule to accomplish that. They allow you to schedule future changes to your Subscriptions.
So what you can do is create your subscription without using the billing cycle anchor parameter - this will generate and process a full price Invoice
Once the Subscription is created you can create a Subscription Schedule from it.
You can then update the Subscription Schedule, and add a new phase to it - that new phase can be used to change the billing cycle anchor when you want (in this case Dec).
Adding a Subscription Schedule to an existing Subscription:
https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#existing-subscription
Actually, this approach that uses a Subscription Schedule to create the Subscription and schedule the billing cycle anchor change is simpler:
https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#resetting-anchor
Amazing thanks. Will have a proper read through and get back to you
I have briefly tested both options. But it looks like I am running into some kind of race condition on stripe's end/some misconfiguration on my side
The current setup works as follows:
- Customer adds the subscription product to their cart
- On the server, create the stripe customer
- Use
stripe.Subscriptions.createto create a new subscription - Grab the subscription id from the previous response to create a
SubscriptionSchedule. This create schedule fails with aninvalid subscription id - If I attempt to attach the subscription schedule to the customer, i get an
invalid customer iderror
Can you share the IDs of requests where you encountered those errors?
,"message":"No such subscription: 'sub_1MwnEpCgZIPthjuHcS28tsMZ'","param":"from_subscription","requestId":"req_1QvuMTeQLUfQDm","request_log_url":"https://dashboard.stripe.com/test/logs/req_1QvuMTeQLUfQDm?t=1681481072"
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
The request to create the Subscription Schedule came from a different account that the one that created the Subscription, so that error is expected as you cannot interact with objects that don't belong to the account making the request.
Nice. That was my bad! I can make the api calls now. But looks like I can only create a schedule from the subscription after the customer has paid and the subscription is active