#neha_unexpected
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/1215380272166473799
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- neha_best-practices, 14 hours ago, 47 messages
Hello! It's possible the Subscription is using a Product you haven't specified in the configuration as being something that can be managed using the Portal, or the Subscription can't be canceled via the portal due to it's current state.
Did you specify the Product the Subscription is using?
how do i add the product to the portal without allowing the user to upgrade/downgrade
because that i need to do manually via the subscription schedule api
i stil want to use the portal for cancellations even if i can't use it for upgrade/downgrade
Ah, that's probably the issue. Have a look here: https://docs.stripe.com/customer-management#customer-portal-limitations
Customers can’t update or cancel subscriptions that currently have an update scheduled with a subscription schedule.
i don't have an update scheduled
i'm in test mode
but okay this makes no sense 🤦♀️ i had another ticket open last night
So the Subscription in question doesn't have a Subscription Schedule associated with it?
i basically want:
upgrade behavior - pro-rate
downgrade behavior - downgrade at end of period
i was using the customer portal for flexible upgrade/downgrade
now i'm moving away from tht
but the user should still be able to cancel?
You can't do that with the Portal. Upgrades and downgrades can't have different behavior like that. You can either invoice for the change immediately or you can invoice at the end of the current period for both upgrades and downgrades.
i know i can't do the upgrade/downgrade part with portal
but why can't i do the cancel part?
Does the Subscription have a Subscription Schedule?
Looking...
Hm, looks like this should show up in the Portal and be cancelable as long as you've configured the Portal to allow that.
How are you creating the Portal Session?
return null;
}
const portalSession = await this.stripe.billingPortal.sessions.create({
customer: customerId,
return_url: RETURN_URL,
});
return portalSession.url;
nothing crazy
Can you log customerId and make sure it's the same Customer?
Or can you give me the Portal Session ID?
um i don't have that, i just tried wiping my db so i could start over, let me see if that fixes it
Ah, I think I found it in your logs. Looks like the Customer ID doesn't match the one on the Subscription.
ok i think yeah some data was borked
but while i have you can i ask another question
i've been having an ongoing issues where users start their subscription, pay in full, but my database isn't updated
here's one example: sub_1OqzR0BZ8IchjqOeSMpAGjj1
when i got the "customer.subscription.created" hook the status was incomplete
so that's what i had in my DB - incomplete
but then she paid, and either "customer.subscription.updated' wasn't called or it still said "incomplete"
i've noticed it happens to like 1 every 100 users
Yep, that was the initial status when the Subscription was intially created. Three seconds later the Invoice was paid and the Subscription's status changed. There was a customer.subscription.updated Event for it: evt_1OqzR4BZ8IchjqOe9KkxHu1K
You can see in that Event the status is active and the status in previous_attributes was incomplete.
It sounds like you might be getting the Events out of order, which can happen. If you got the updated Event before the created Event and aren't handling that properly that could cause the issue you're describing.
See here for more details: https://docs.stripe.com/webhooks#event-ordering
oh i guess that would make sese
if it's only happening once in a while
is there a recommendation on how to handle this?
linked section just says "it can happen" not "how to deal with it"
these are the ones i listen to:
checkout.session.completed
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted
It depends on your integration -- you might find it appropriate to queue events for processing, but we do mention one approach: using the event as a signal to retrieve the corresponding objects from the API
So instead of looking at the event subscription object, you retrieve that subcription by its id to get the latest status
hm but "checkout.session.completed" is the only one that returns my internal user ID (client_reference_id)
so that's sort of a pre-req
You can pass that through to the subscription too via metadata if you need that on the subscription object:
https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ah okay... just an arbitrary k/v
okay i'll give it a try thanks
and wait so... if the subscription metadata has the customer id, do i even need to listen to the checkout event?
i was only listening to it for that customer reference id
const data = event.data.object;
const { client_reference_id, customer } = data;
if (client_reference_id && typeof customer === "string") {
await userService.updateUser(client_reference_id, {
stripeCustomerId: customer,
});
}
break;
}```