#impactfx
1 messages · Page 1 of 1 (latest)
Hello 👋
You can't add a discount to an invoice if it has been finalized already.
Taking a step back, what's the usecase here? Why do you want to apply the discount after the PaymentIntent has been created specifically?
Ok let me explain
The user enters all there information, and is presented with the payment screen to enter there credit card. Inorder to do this we created the payment intent and use the stripe elements
But on that screen we want to show a "Add coupon" UI
We dont want the coupon code to be BEFORE the credit card screen
This is were we are stuck now, because if the invoice is finalized.. we can't do anything
Why can we not create subscription payment intents with a non finalized invoice?
Gotcha.
Why can we not create subscription payment intents with a non finalized invoice?
That's how the underlying API works unfortunately. When you create a subscription, it creates an invoice for the amount underneath.
Thinking of an alternative..
An alternative would be amazing if you have one.
A suggestion long term would be to allow the subscription.create method support a invoice
auto_advance=False method, so the invoice is not finalized. and thus, it could be edited.
One way would be to use webhooks and listen for invoice.created events and set auto_advance to false by calling the Update invoice API
https://stripe.com/docs/api/invoices/update
this becomes a bit of a headache as i wouldnt know if this was a "first" subscription signup or there monthly renewal
There is no other options? how do other people normally do this.. cause adding a coupon before payment is a very common thing
this becomes a bit of a headache as i wouldnt know if this was a "first" subscription signup or there monthly renewal
It should be straightforward as each invoice would have abilling_reasonparameter
https://stripe.com/docs/api/invoices/object?lang=cli#invoice_object-billing_reason
ah ok. And if i set auto advanced
do i manually have to finalize the invoice or will stripe do it again onpayment intent complete?
I believe you'll need to finalize it when you apply the discount
ok, but then i run into an issue if they want to undo the coupon and apply a different one this whole logic becomes a bit of a nightmare
I feel this solution is pretty limited, cause id have to have my webhooks all working locally everytime i wanna test this etc.
Very confused that this is such a headache considering coupons are used alot in the flow we are doing things
Yeah can't think of a better alternative than the above. We are working on an approach where the PaymentElement is decoupled for the PaymentIntent.
https://stripe.com/docs/payments/defer-intent-creation?type=payment
That might help with your usecase
Yeah you'll need to reach out to support for that