#_purplefloyd

1 messages · Page 1 of 1 (latest)

spare mantleBOT
hallow finch
#

Hi, let me help you with this.

storm needle
#

Okay thanks

hallow finch
#

"change my price to a different price id" where you mean?

storm needle
#

in my code

#

so when the user clicks the button on my site, that button is tied to a price_id

#

I want to change the price, and (therefore) change the price_id

#

and I am wondering if that might cause problems with any of the customers that have already paid accessing their portals

hallow finch
#

How is the button tied to the price_id exactly?

storm needle
#

its in the post request

#

let sessionConfig = {
mode,
allow_promotion_codes: true,
client_reference_id: clientReferenceId,
line_items: [{ price: priceId, quantity: 1 }],
discounts: couponId ? [{ coupon: couponId }] : [],
success_url: successUrl,
cancel_url: cancelUrl,
...extraParams,
};

if (trialDays && trialDays > 2) {
const trialEndTimestamp = getTrialEndTimestamp(trialDays);
sessionConfig.subscription_data = { trial_end: trialEndTimestamp };
}

const stripeSession = await stripe.checkout.sessions.create(sessionConfig);

hallow finch
#

That's not a Customer Portal, but a Checkout Session, which is a completely different product.

#

This code will create a new Checkout Session. Still not sure what you mean by your initial question.

storm needle
#

I'm asking: if I change my code to use a different price_id in this checkout session, and therefore a new price for customers who come to the site, is that going to have any effect on my existing customers' portals (where they can manage thier subscriptions)?

hallow finch
#

"If I change my price to a different price id do I need to update the portal link as well"
For every payment you need to generate a new Checkout Session, if you change the price ID in the code, you will generate a new Checkout Session with a different Price.

storm needle
#

yes, that makes sense

hallow finch
storm needle
#

okay let me look at my code real quick

#

I set this up a couple months ago so I'm not that sharp on it right now

#

portalLink: //right now there is only one portal link because there is only one price.
process.env.NODE_ENV === "development" //not sure if you need a separate portal link if you have a bunch of prices or what.
? "https://billing.stripe.com/p/login/test_14" //dev
: "https://billing.stripe.com/p/login/00g", //prod

// Create multiple plans in your Stripe dashboard, then add them here. You can add as many plans as you want, just make sure to add the priceId
plans: [
  {
    // REQUIRED — we use this to find the plan in the webhook (for instance if you want to update the user's credits based on the plan)
    priceId:
      process.env.NODE_ENV === "development"
        ? "price_1O" //this is where the payment link comes from for dev
        : "price_1OUai", // for prod
#

const renderActionButton = () => {
switch (accessStatus) {
case 'pending':
// Return nothing if the status is pending
return null;
case 'granted':
// Return a button to manage subscription if the user has access
return (
<button className="btn btn-primary btn-wide" onClick={() => router.push(config.stripe.portalLink)}>
Manage Subscription
</button>
);
case 'denied':
// Return the ButtonGet component if the user does not have access
return <ButtonCheckout priceId={plan.priceId} pay_url={plan.pay_url} mode={plan.mode}/>
default:
// Handle other cases or return null if no other cases are expected
return null;
}
};

#

is that readable? would a photo be easier?

#

im wondering if I need to update that portal link when I update my checkout's to be using a new price, basically

hallow finch
#

What's important is how you generate the Customer Portal in your backend.

storm needle
#

okay interesting

#

what do you mean by that

hallow finch
#

Where does config.stripe.portalLink come from?

storm needle
#

Im not positive, I can double check, but i think I took it from the UI

hallow finch
#

I can't go over your code, sorry. But these 2 functions should not impact each other.

storm needle
#

this is where I got the portal link from

hallow finch
#

Ok, so it's static.

#

Existing customer Subscriptions shouldn't be impacted when you create Checkout Sessions.

storm needle
#

awesome

#

thank you

hallow finch
#

Happy to help.