#diamond_invoice-upcoming

1 messages ยท Page 1 of 1 (latest)

vital sleetBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ 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.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— 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/1280998734770995372

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

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.

ember fulcrum
#

Hii

idle plume
#

Can you copy/paste the exact code you're using to retrieve the upcoming Invoice?

ember fulcrum
#
#
      customer: customerId,
      subscription: subscriptionId,
      subscription_items: [
        {
          id: subItemId,
          price: newPriceId,
        },
      ],
      discounts: [
        {
          coupon: couponCode,
        },
      ],
      subscription_proration_behavior: "create_prorations", // Calculate prorations
    });```
#

it's changing again and again

idle plume
#

Can you be more specific? What's the exact payload you get from the response?

#

For context, I cannot access your Workbench links, so it's best to send object IDs instead

ember fulcrum
#

req_XZ3nfgoLIlfsN5

#

total saying 8094 but it's wrong

idle plume
#

What are you actually trying to do? Like, you're simulating an upgrade by creating this mock-up of what the Invoice will be, but what do you want to happen?

#

In other words, what should the Invoice look like to you?

ember fulcrum
#

I have current plan 29.99$ right now which i bought today
Now i am upgrading to 59.99$ but before that i want ask user to apply code. after apply. after entring promo code how much user will need to pay. I want to show that amount.

idle plume
#

What do you want the discount to apply to? Just the $59.99 amount?

ember fulcrum
#

Yes so if discount is 10% thet amount should be 59.99 - unused 29.99 - 10% of 59.99 so it's 6 = 23.99

idle plume
#

So you need to pass in the Discount coupon here instead: https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-subscription_details-items-discounts

Right now you're passing the coupon such that it applies to the whole invoice. So, start by doing that, then post the payload again and I can take a look at it

ember fulcrum
#

You may only specify one of these parameters: subscription_details, subscription_items.

#

getting this error

idle plume
#

Remove subscription_items. That parameter is deprecated and will be removed in future API versions

ember fulcrum
#

{
customer: customerId,
subscription: subscriptionId,
subscription_details: {
items: [{ discounts: [{ coupon: couponCode }] }],
},
subscription_items: [
{
id: subItemId,
price: newPriceId,
},
],
}

#

can you update this payload?

idle plume
#

Use subscription_details in place of subscription_items

ember fulcrum
#

where i can add this details
{
id: subItemId,
price: newPriceId,
},

idle plume
#

Have you looked through the other parameters for subscription_details to see if anything fits price and id?

ember fulcrum
#

{
customer: customerId,
subscription: subscriptionId,
subscription_details: {
items: [
{
discounts: [{ coupon: couponCode }],
id: subItemId,
price: newPriceId,
},
],
},
}

#

req_D96Kti5Ff6OJmh

#

check this one still giving 86.93 $

idle plume
#

Okay, so what you need to do now is (instead of updating the existing Subscription Item with the new Price) add the new Price as its own item. Right now your code is telling Stripe to take the existing 29.99 and change it to 59.99, rather than leaving the 29.99 alone, which would allow it to pick up the proration credit.

So change your code to this:
customer: customerId, subscription: subscriptionId, subscription_proration_behavior: "create_prorations", subscription_details: { items: [ { discounts: [{ coupon: couponCode }], price: newPriceId, }, ], }, }

ember fulcrum
#

now it saying 143.32 $

#

req_717D8trtkcWrRv

idle plume
#

Not sure why it's saying 143.32, but let's proceed anyway. I believe the last step is to delete the existing item for 29.99. So try:

customer: customerId, subscription: subscriptionId, subscription_proration_behavior: "create_prorations", subscription_details: { items: [ { id: subItemId, deleted: 'true' }, { discounts: [{ coupon: couponCode }], price: newPriceId, }, ], }, }

ember fulcrum
#

req_Q33OskIxRukPop

idle plume
#

Can you copy/paste the payload?

ember fulcrum
#

correct amount is not coming

#

{
"customer": "cus_Qmw6FasRc6z7KX",
"subscription": "sub_1PvPJlGXQ7blAdt6U6pDSLw4",
"subscription_details": {
"items": {
"0": {
"id": "si_QmzI9uAAlZyODF",
"deleted": "true"
},
"1": {
"discounts": {
"0": {
"coupon": "DONTUSE"
}
},
"price": "price_1NdmVGGXQ7blAdt6QR0pdVbC"
}
},
"proration_behavior": "create_prorations"
}
}

#

{
customer: customerId,
subscription: subscriptionId,

  subscription_details: {
    proration_behavior: "create_prorations",
    items: [
      {
        id: subItemId,
        deleted: "true",
      },
      {
        discounts: [{ coupon: couponCode }],
        price: newPriceId,
      },
    ],
  },
})
idle plume
#

That's the code. I need the payload from the response

ember fulcrum
idle plume
#

Try always_invoice instead of create_prorations

vital sleetBOT
supple mantle
#

diamond_invoice-upcoming