#_purplefloyd
1 messages · Page 1 of 1 (latest)
Hi, let me help you with this.
Okay thanks
"change my price to a different price id" where you mean?
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
How is the button tied to the price_id exactly?
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);
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.
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)?
"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.
yes, that makes sense
I don't know how you generate Customer Portal Sessions and if the code is related to this in any way.
But you don't update any existing Subscriptions if you create a new Checkout Session.
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
What's important is how you generate the Customer Portal in your backend.
Where does config.stripe.portalLink come from?
Im not positive, I can double check, but i think I took it from the UI
I can't go over your code, sorry. But these 2 functions should not impact each other.
Ok, so it's static.
Existing customer Subscriptions shouldn't be impacted when you create Checkout Sessions.
Happy to help.