#Eranga
1 messages ยท Page 1 of 1 (latest)
Hi there, if the coupon's duration is set to once, it can only be applied once for the first charge (i.e., first invoice), and it's not applied in the subsequent invoices (i.e., the preview invoice with new quantity)
Yes, that is true. From the customer's end, the amount we ask to pay is not fair. Because if they did not change the quantity, they would enjoy the discount for the entire billing cycle. But if they increase the quantity, this would remove the discount from the already paid quantity as well
I don't think the discount is removed from the already paid item. What you are previewing is the invoice from next billing cycle, where the discount is no longer applied.
Since I am setting the proration behavior to always invoice, I am previewing the amount the user is supposed to pay now. And since the price is the same, it will show me how much the customer needs to pay for the existing billing cycle, if the change is to happen, right?
Ah, you are setting proration behaviour to always_invoice
Yeah, we have a bit of weird use case which needs to ask the user to pay at the same billing cycle multiple times if they increase something
Then it'll be prorated but without the discount because the coupon is already applied once.
Yeah, the invoice is prorated. But I can see that the amount we ask the user is
10 new quantity (no discount applied, prorated from now) + 10 old quantity (the applied discount is removed, prorated from now)
It would be okay to remove the discount from the new quantity, but the old quantity should retain the discount, right?
The current subscription engine will produce the following invoice items
- Unused time on the original 10x quantity (-)
- Remaining time on the new 20x quantity (+)
- The 20x quantity for the next billing cycle (+)
I believe the misalignment is on the last item ( The 20x quantity for the next billing cycle), you are expecting 10 of them should still be discounted, am I right
Give me a sec to process ๐
Since my proration behavior is always_invoice I would only get 2 invoice items, right? The 1st and the 2nd in your list
My problem is with the 2nd item having no discount.
I would say in the 2nd item:
- we should either provide the discount to all 20 items,
- or we should give the discount to 10 items and the other 10 without discount
Ah, yes I missed the always_invoice again.
The current subscription engine treats the new 20x quantity as a whole, so it won't apply discount for 10 of them.
The workaround here is to set another once coupon when updating the subscription.
Yes, that is what I am thinking as well. So now I need to know if my current subscription has a one-time discount applied. How can I know that programmatically?
There's a discount filed in the subscription object (https://stripe.com/docs/api/subscriptions/object#subscription_object-discount)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That is null in this case
Hmm, that's because the coupon is already applied.
Yes, so when the coupon is applied I can see the discount is being created -> the invoice is also created -> invoice is paid -> the discount is deleted
Then you should check the subscription's latest_invoice and get its discounts array (https://stripe.com/docs/api/invoices/object#invoice_object-discounts)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.