#Celsian
1 messages · Page 1 of 1 (latest)
Where is the coupon being entered?
The coupon code is entered on the page and validated by our backend.
If you're using a JS function call to the server for the coupon submit, you can put something like this in the function
async function handleSubmit(e) { e.preventDefault(); }
Ok let me step back,
When users go to our checkout page there is an incomplete subscription generated. Once they enter their info and submit the billing is applied and the subscription status becomes active.
If a user enters a coupon code, the page refreshes to generate another incomplete subscription, this time with the coupon code applied.
We must be going about this in the wrong way. I guess I'm not sure how we're supposed to apply coupons to a subscription.
You should just update the existing Subscription with the Coupon instead: https://stripe.com/docs/api/subscriptions/update#update_subscription-coupon
You can do this using fetch(), which triggers a server-side Update Subscription API call. Once the Subscription is updated, you can merge the updates with the existing Payment Element using the Stripe JS method --> https://stripe.com/docs/js/elements_object/fetch_updates
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.