#nt_unexpected
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/1289141168931864677
๐ 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.
- nt_docs, 3 days ago, 5 messages
Hello, no a recurring one.
Here's a subscription that was added the coupon later: sub_1Q3JXZD8MRRUQEjful0H0lnG
And one that was created with a coupon: sub_1Q3JcUD8MRRUQEjf6aLaKk0M
And here's how I preview an upcoming invoice:
params = {
customer: "cus_Qv9rscjETSsNcY",
subscription: "sub_1Q3JXZD8MRRUQEjful0H0lnG",
discounts: "",
subscription_details: {
items: [{
id: "si_Qv9svdnsHbvfXo",
price_data: {
product: "prod_LxYG6NjewhGxMA",
recurring: {
interval: "month"
},
unit_amount: 32400,
currency: "USD"
},
quantity: 1
}, {
price_data: {
product: "prod_PbrhyafaLRTtGt",
recurring: {
interval: "month"
},
unit_amount: 5400,
currency: "USD"
},
quantity: 1
}],
proration_date: 1727537017,
default_tax_rates: ["txr_1Q3DXdD8MRRUQEjfL1ReoNYK"]
}
}
::Stripe::Invoice.upcoming(params)
I believe the difference is that for the discount with the coupon applied after creation, the proration calculates the unused time with this description "Unused time on Standard Recruiting after 28 Sep 2024"
But with the discount with the coupon applied on creation, the description is this "Unused time on Standard Recruiting (with 50.0% off) after 28 Sep 2024".
For some reason, stripe does not take into account the discount, if an invoice hasn;t been paid with that discount active...
I recall that you might need to re-apply the Coupon in the upcoming Invoice parameters.
But I don't want the discount to be applied in the upcoming invoice. I just need the proration to calculate that I paid the discounted mount of the current subscription price and not the full one.
And calculate the remaining amount. Which again if the coupon code is applied on subscription creation, the calculation is correct.
Okay, I understand. Yes, this might be the reason. Since if you applied the coupon after the creation, it should only be active from the next billing period.
Yes but this is not normal behavior. I prorate a customer and stripe thinks the customer has already paid 300 while they have paid 150... Is there any alternatives for my scenario?
Could you please share the response that you get for the upcoming invoice request? We don't save GET responses internally.
This is for the subscription with the coupon applied after creation:
This is for the one created with a coupon:
The line items is the part were I have the issue.
"amount": -33600,
"description": "Unused time on Standard Recruiting after 28 Sep 2024"
How can the unused amount be 336$ if the subscription price is 360$ with a 50% discount applied and the customer has paid us 180$. This does not make sense
Hey! Taking over for my colleague. Let me catch up.
sorry for the late reply
"discountable":false
that's because you are using proration and coupon on the upcomming invoice which is not supported
It's confusing I agree, but this is the current behavior of the upcoming invoice API
I think if you are using Test clock and you advance time with that update, the proration will take into account the discount
Yes I know. But this is not just a test case this is a scenario that will happen in prod.
Also, in the upcoming invoice for the subscription with the coupon applied on creation, the discountable is also false:
"amount":-16800,"amount_excluding_tax":-16800,"currency":"usd","description":"Unused time on Standard Recruiting (with 50.0% off) after 28 Sep 2024","discount_amounts":[],"discountable":false,"discounts":[],
But again the discount is taken into account during proration. can I somehow backdate the discount? Or what are my other alternatives?
Yes I know. But this is not just a test case this is a scenario that will happen in prod.
Yes I agree, what I wanted to say is this is a limitation on the upcoming invoice API.
I see. What are my options here? Maybe create a new subscription from scratch?
No need to create another Subscription, the upcoming invoice will have the correct amount.
It's just the upcoming invoice API limitation.
That's why I suggested to use test clock and advance time to see that the proration and the discounts works as expected when the target time comes
Can you make a quick tests please using the Test Clock to see if that's what you are looking for or not ?
Yes please! Thanks!
Yes I will perform a testcase. There may be a drawback that if I advance it to +1 month, the discount may be expired although it shouldn't as I preview it for the upcoming month where it is still active
No actually, you need to make the Subscription Update before advancing the time.
Hey, so this will not probably work because the subscription update also has the issue with the proration, not just upcoming invoice.
Hey, so this will not probably work because the subscription update also has the issue with the proration
Do you have a sample request Id ?
Yes one sec to create the flow.
req_3fLDZ7aTvbqYxY
subscription_id = sub_1Q3amyD8MRRUQEjfEbaTawYu
As you can see the subscription was 360 with 50% discount. The customer had paid 180$.
I updated the subscription to include 2 items one with price 324$ and the scond with price 54$.
The updated subscription price was 378 without discount. The customer was asked to pay 17.40 instead of about 191.40 -> 378 - 180 = 198. 198*29/30 = 191.40
The same example if done with a coupon code that exists since creation, updates the subscription and charges the customer with the correct amount.
๐ taking over for my colleague. Let me catch up.
sorry it's taking me some time but I'm trying to look at the generated invoice to understand what's happening here
hi! I'm taking over this thread. give me a few minutes to catchup.
if I understand correctly, the issue is this invoice? in_1Q3awqD8MRRUQEjfYUditweV
you were expecting the user to pay more there, around $190?
Hello sorry for the delay yes exactly. It seems that a prorated invoice before a recurring one when in the current billing cycle a discount is activated, does not take into account the discounted amount but accepts that the customer has paid the subscription price in full
yes, I believe that's a known quirk of how our proration works. The workarounds would be to add your own invocie items(positive or negative) to make the total end up what you want instead
That is not at all ideal as the customer would not know why extra items appear on their invoice..
yep, there are lots of quirks and edge cases with how proration works today and how it interacts with discounts, unfortuantely
Are there any alternative solutions right now that I could take advantage of?