#mathiashenriksen_92217
1 messages ยท Page 1 of 1 (latest)
Hi there!
How are you creating the Subscription? Checkout Session, tje Subscription endpoint, something else?
Hey! I am using the Node subscription.create endpoint
Got it, so you are using this parameter to set the coupon? https://stripe.com/docs/api/subscriptions/create#create_subscription-coupon
It's this one actually https://stripe.com/docs/api/subscriptions/create#create_subscription-promotion_code
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Got it. Give me a few minutes to try to reproduce.
Indeed, as soon as the invoice is created, the coupon is considered redeemed.
If that's not what you want, then you may want to build your own coupon system.
Ahh I see. Does that also happen in a Checkout Session?
Not sure, having a look
It kinda works:
- If the user opens the Checkout Session and then leave, then the coupon is not redeemed.
- However if the user tries to pay in the Chekcout Session, and it succeeds or fails, then a Subscription is created and the coupon redeemed
Hmm, does the checkout session not use the same API?
I have not tried the checkout session myself, but the problem when using the API is that I cannot render the payment elements until I have a client secret, which comes with the payment intent. And when requesting this payment intent I also redeem the promotion code ๐
I should be able to do something similar to what is happening in the Checkout Session, no?
Hmm, does the checkout session not use the same API?
It does, but the Checkout Session only create the Subscription when the user tries to pay, not before.
is that I cannot render the payment elements until I have a client secret
That was true before, but not anymore. You could use this new flow https://stripe.com/docs/payments/accept-a-payment-deferred?platform=web&type=subscription
Another option is to collect to promotion code before showing the Payment Element.
That is great! I'll try the new flow then ๐ thanks