#diamond_invoice-upcoming
1 messages ยท Page 1 of 1 (latest)
๐ 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.
- thirddiamond_api, 24 minutes ago, 20 messages
- thirddiamond_api, 8 hours ago, 16 messages
Hii
Can you copy/paste the exact code you're using to retrieve the upcoming Invoice?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
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
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
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?
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.
What do you want the discount to apply to? Just the $59.99 amount?
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
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You may only specify one of these parameters: subscription_details, subscription_items.
getting this error
Remove subscription_items. That parameter is deprecated and will be removed in future API versions
{
customer: customerId,
subscription: subscriptionId,
subscription_details: {
items: [{ discounts: [{ coupon: couponCode }] }],
},
subscription_items: [
{
id: subItemId,
price: newPriceId,
},
],
}
can you update this payload?
Use subscription_details in place of subscription_items
where i can add this details
{
id: subItemId,
price: newPriceId,
},
Have you looked through the other parameters for subscription_details to see if anything fits price and id?
{
customer: customerId,
subscription: subscriptionId,
subscription_details: {
items: [
{
discounts: [{ coupon: couponCode }],
id: subItemId,
price: newPriceId,
},
],
},
}
req_D96Kti5Ff6OJmh
check this one still giving 86.93 $
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, }, ], }, }
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, }, ], }, }
req_Q33OskIxRukPop
Can you copy/paste the payload?
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,
},
],
},
})
That's the code. I need the payload from the response
Try always_invoice instead of create_prorations
diamond_invoice-upcoming