#Eben-DeleteCoupon
1 messages · Page 1 of 1 (latest)
Hi, taking a look here
Can you share the event id with me?
I was able to test this on my end and can confirm that even if the coupon is deleted, the amount_off to show how much was discounted is on the events. It sits under the discount object.
"discount": {
"amount_off": 2000,..
}
If you can share the specific where you're not seeing this behavior, I'm happy to further investigate
Sorry, stepped away…taking a look
Sure, I've even looked at customer.subscription.updated Event to be sure and I see the 'amount_off' as well
The amount_off represents a flat discount defined on the coupon, and the percent_off represents a percentage discount defined on the coupon. Those values are always included in the coupon object. The issue is that both amount_off and percent_off may only apply to specific products. Without the list of products it applies to, there's no way to use those values to compute the accurate discount amount.
For instance, 50% off Product Foo with a price of $100 yields $50 off, even if the subscription contains several products totaling $250.
But without knowing the coupon only applies to Product Foo, I'd be left incorrectly computing a $125 discount.
What's missing in the discount object is either a) the applies_to optional field on the coupon hash, or b) a computed discount amount as it applies to the subscription.
When you create the coupon, are you setting them to a specific product?
Yes
I'll give you an example…just a second
sub_GgHf1UmYC6AB03
More specifically, see this subscription.update event: evt_1Lf90eDJ1uFWlBkUSGIsdCPq
Testing this on my end with multiple products and a percent discount, thank you for your patience
Ah, sorry, it's a bad example because in this case the coupon didn't apply to a single item. I've recreated this in test mode, though.
Here's an event that shows the issue: evt_1LfsJvDJ1uFWlBkUsX4KUaum
I see the same thins as you are. Would not you look at the line items from the Event to see what the total amounts paid were?
👋 stepping in as pgskc needs to step away
If you want to calculate this info ahead of the invoice then you would need to store the applies_to in your own database for deleted coupons.
I think it is fair feedback that it would be nice to have applies_to on the discount object
I'll file feedback internally about that
But wouldn't expect it to be added any time soon
I don't think the event includes info for the total amount, does it?
If the subscription gave totals it wouldn't be an issue, but it only provides the products and their prices, not any computed total amounts/discounts
How does the Stripe dashboard show the correct applied discount after the coupon containing that info is deleted?
Are you talking about for the upcoming invoice?
Which is a good point — that would be another way to figure this out. You should be able to use https://stripe.com/docs/api/invoices/upcoming