#aooa1009

1 messages · Page 1 of 1 (latest)

astral hedgeBOT
past idol
#

Hi there

polar ledge
#

Hi!

past idol
#

Customer IDs are unique per-Customer object.

#

They will not change once created.

#

But we also don't prevent duplicates from being created.

polar ledge
#

Okay
I'm kind of stuck here

past idol
#

So it mostly depends on how you are creating Customers right now

polar ledge
#

could you spare some time to hear my case

past idol
#

Assuming you are a developer then yep that's what we are here for.

polar ledge
#

Yep

#

It successfully worked

#

Now I want to add Credits to my product

#

Credits are not recurring, they're bought by the user when they run out of credits or just want to buy more

#

its a one-time buy

#

they enter in how many credits they want

#

and then I followed the same step as in the above video

#

except, with a few changes, new StripePriceId, changing mode from subscription to payment, etc

#

but now, when I click "Buy Credits"

#

it takes me to

#

To the subscription plan management page

past idol
#

Hmmm

polar ledge
#

its a package pricing model

past idol
#

It sounds to me like your code is redirecting to Customer Portal on your "buy credits" button

polar ledge
#

Let me show you

#

one moment

past idol
#

What does that code look like?

polar ledge
#

yep

#

one moment

#

how can i share the code easily

#

its too long for discord

#

one moment

past idol
#

I don't want your whole code please

#

Just the relevant part for your "buy credits" button

#

And you can put that in 3 backticks like this

polar ledge
#

cool

#

one min

#

I'm beat as to what's wrong

#

let me guide you through it quickly

past idol
#

Screenshots of code are really hard for us to work with. In the future copy the relevant part into text and put it in backticks.

polar ledge
#

Oh, okay
I thought you could see it in color here

#

I'll do that

polar ledge
polar ledge
polar ledge
past idol
#

So yeah

#

In your manageSubscriptionActionCredits function you are creating a Customer Portal Session

polar ledge
# polar ledge

at line 14, I used the old code, from where I get the user's current Monthly Subscription plan - as the cost of one credit is determined based on what plan they're currently on, their stripeCustomerId and if they're currently subscribed

past idol
#

It sounds like you want to be sending them to Checkout instead, no?

polar ledge
#

yeah

polar ledge
past idol
#

Right

#

So that is the code you need to fix

#

You want to send them to Checkout, not the Customer Portal

polar ledge
#

see

#

what am i doing wrong ;-;

#

Any additional details I can give you, please lmk

past idol
#

I can't debug your code for you

#

What you want to do is add logs throughout your code to understand what is happening

#

So like why is it hitting your code that is creating a customer portal session

#

That is what you want to figure out

polar ledge
#

When does it go to customer portal session

past idol
#

In your manageSubscription_ActionCredits function

#

Where you return the Portal Session URL

polar ledge
#

mhm

#

oh

#

okk

#

another question!

#

where can I find everything in the stripeSession object

polar ledge
#

if (isSubscribed && stripeCustomerId && isCurrentPlan) { const stripeSession = await stripe.billingPortal.sessions.create({ customer: stripeCustomerId, return_url: billingUrl, }); return { url: stripeSession.url }; }

What does this code do, I'm confused a little

#

once I commented it, it worked