#imheretolearnbro_api
1 messages ยท Page 1 of 1 (latest)
๐ 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/1293327054762414143
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello! There isn't really the concept of a "resubscription" in Stripe. Once a Subscription is canceled that's it, it's over, and it can't be reactivated. For the "resubscription" you would just create a new Subscription for them.
But the problem with that is that it would charge them immediately. But they already payed for the current month.
And I tried creating a new Stripe Checkout Session and changing the billing date to a month ahead but it threw an error saying that goes against the "natural billing date".
So im just stuck thinking what I should do
Wait, maybe I'm misunderstanding. When they cancel the first Subscription you don't refund them?
Nope
So you want their Subscription to remain active for the current period, then cancel after that?
Yes so if they pay on October 8
Their session lasts from October 8 to November 8
But on November 8 they will lose access unless they pay again
Okay, it sounds like when they "cancel" the Subscription you actually want to set cancel_at_period_end to true on the Subscription: https://docs.stripe.com/api/subscriptions/update#update_subscription-cancel_at_period_end
And then if they "un-cancel" you can set that to false.
Ohhh so thats what you do
Would that work for your use case?
I think I get it
And how can I provide a link to the user to view their subscription hosted by Stripe so they can do stuff like cancel, change payment info, etc
Because right now I'm going into my Stripe dashboard / Subscriptions / Subscription / Cancel Subscription
But I want a link the user can use to go to a site hosted by Stripe to do it themselves you know
You can send them to the Customer Portal: https://docs.stripe.com/customer-management
I don't see how this would work for the customer side
Like say I have a customer_id
customer_id = cus_QzgfLRhjPV1234
How can I input this customer_id into the Stripe API to return a link I provide the use to navigate to update the information from the "Customer Portal"
I found it !
stripe.billing_portal.Session.create(
customer="cus_NciAYcXfLnqBoz",
return_url="https://example.com/account",
)
Yep, that's it!
Your amazing now I have a new problem
A user has two options when it comes to updating a subscription payment
They can click on "Cancel plan" or "Renew plan". My question is that both are recognized as "customer.subscription.updated". How do I differentiate between the two?
A successful "Cancel plan" and a successful "Renew plan" so I can do some logic for ecah
All of our *.updated Events have a previous_atrributes property showing what changed: https://docs.stripe.com/api/events/object#event_object-data-previous_attributes
It's there.
Sorry
"previous_attributes": {
"cancel_at": null,
"cancel_at_period_end": false,
"canceled_at": null,
"cancellation_details": {
"reason": null
}
}