#dineshgarg-_code

1 messages ¡ Page 1 of 1 (latest)

sinful crystalBOT
#

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

sharp belfryBOT
#

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.

torpid palm
blissful aurora
#

Currently facing two problems:

  1. If user update his plan from 5$ to 15$ then transaction occurs with 10.01$ amount rather than 10$?
  2. 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 ?

torpid palm
#

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?

Learn about prorations.

blissful aurora