#neha_unexpected

1 messages · Page 1 of 1 (latest)

swift echoBOT
#

👋 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.

buoyant tangleBOT
#

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.

tough beacon
#

here's what the preview shows

#

but the "cancel plan" button isn't there irl

fickle sinew
#

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?

tough beacon
#

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

fickle sinew
#

Customers can’t update or cancel subscriptions that currently have an update scheduled with a subscription schedule.

tough beacon
#

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

fickle sinew
#

So the Subscription in question doesn't have a Subscription Schedule associated with it?

tough beacon
#

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?

fickle sinew
#

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.

tough beacon
#

i know i can't do the upgrade/downgrade part with portal

#

but why can't i do the cancel part?

fickle sinew
#

Does the Subscription have a Subscription Schedule?

tough beacon
#

sub_1OMvXzBZ8IchjqOeSgIrw5WX

#

no

#

it's in test mode, that's the id

fickle sinew
#

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?

tough beacon
#
      return null;
    }
    const portalSession = await this.stripe.billingPortal.sessions.create({
      customer: customerId,
      return_url: RETURN_URL,
    });
    return portalSession.url;

#

nothing crazy

fickle sinew
#

Can you log customerId and make sure it's the same Customer?

#

Or can you give me the Portal Session ID?

fickle sinew
#

Ah, no, I need the ID of the session. It starts with bps_

tough beacon
#

um i don't have that, i just tried wiping my db so i could start over, let me see if that fixes it

fickle sinew
#

Ah, I think I found it in your logs. Looks like the Customer ID doesn't match the one on the Subscription.

swift echoBOT
tough beacon
#

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

fickle sinew
#

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.

tough beacon
#

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

nimble finch
#

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

tough beacon
#

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

nimble finch
tough beacon
#

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;
      }```
nimble finch
#

Possibly not!

#

Depends on what else you were using it for, if anything

tough beacon
#

no that was it

#

wow

#

and the checkout session doesn't return the line items by default right