#dineshgarg-_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
âąď¸ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
đ 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/1212668567623966730
đ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
â˛ď¸ 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. Thank you for your patience!
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.
- dineshgarg-_code, 16 hours ago, 7 messages
To update the subscription, here's the guide: https://docs.stripe.com/billing/subscriptions/upgrade-downgrade
Stripe will prorate for you for the amount differences
Currently facing two problems:
- If user update his plan from 5$ to 15$ then transaction occurs with 10.01$ amount rather than 10$?
- If user again want to update his plan from 15$ to 25$ then this time is not working ?
I am following the same guide which you shared. I am using below code
if (subscriptionId) {
const currentSubscription = await stripe.subscriptions.retrieve(
subscriptionId
);
const newPlan = await stripe.prices.retrieve(priceId);
const priceDifference =
newPlan.unit_amount - currentSubscription.items.data[0].price.unit_amount;
if (priceDifference > 0) {
const updatedSubscription = await stripe.subscriptions.update(
subscriptionId,
{
items: [
{
id: currentSubscription.items.data[0].id,
price: priceId,
},
],
expand: ['latest_invoice.payment_intent'],
}
);
return res.status(201).json({
status: true,
url: updatedSubscription.latest_invoice.hosted_invoice_url,
subscriptionId: updatedSubscription.id,
});
}
return res.status(201).json({
status: true,
currentSubscription,
newPlan,
url: '',
subscriptionId: '',
});
}
but getting above mentioned two issued could you guide on this please ?
If user update his plan from 5$ to 15$ then transaction occurs with 10.01$ amount rather than 10$?
Stripe will prorate based on when the subscription is updated and how much the existing plan has been used. You can check how proration is calculated here: https://docs.stripe.com/billing/subscriptions/prorations
If user again want to update his plan from 15$ to 25$ then this time is not working ?
What is not working?
This time transaction does not occur in stripe and no error displays also