#mochihealth
1 messages · Page 1 of 1 (latest)
hello! can you explain a bit more? we have test mode if you want to test that your criteria works as per what you expect
so i can attach a coupon to preview an invoice and it will return the updated price for the subscription but lets say that I have a restriction that a promo code is only good for first time buyers it will only throw an error currently when I actually try to create the subscription and not when i am previewing the invoice. I want to know if there is any way to do that validation when I preview the invoice
ah, i'm afraid I can't think of any other workarounds other than you implementing that logic yourself to validate if the customer has made other payments (or subscribed) to your products before unfortunately
what is the best webhook to listen to if i want to know what discount was used to create a subscription
probably any of the customer.subscription.* related events should have it. If you share an Subscription id that has a discount / promo code applied to it, i can take a quick look
sub_1NKu9nBPM36OC3gXci1x8dhF
hrm, because this was a first time use discount, it looks like the discount won't show on the Subscription related events. So what you would want to use instead is the invoice.paid event and check the billing_reason : https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason for subscription_create to ensure it's the first invoice for a subscription. I can see a discount code listed in the invoice for that event: https://dashboard.stripe.com/test/events/evt_1NKuA6BPM36OC3gXgKdwaqhA