#D4reDev1l.
1 messages · Page 1 of 1 (latest)
Hi, are you asking if you can apply both the coupon and the promo to a subscription? Or something else?
You can update the Promotion code via this endpoint: https://stripe.com/docs/api/promotion_codes/update#update_promotion_code-active
I want to migrate from apply coupon to apply promo code to subscription
and I want to make promo code active in the coupon dashboard
You should be able to switch the promo to active: https://stripe.com/docs/api/promotion_codes/update#update_promotion_code-active
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I make it active now
but how to apply promo code to subscription?
How are you integrated? Are you using Stripe Checkout or something else? If you use Stripe Checkout, you can use https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-allow_promotion_codes to allow promotion code.
I am using Stripe.Subscription and add coupon id to coupon field with stripe.subscription.update()
like this
I think you're looking for this: https://stripe.com/docs/api/subscriptions/update#update_subscription-promotion_code
On that update call, you can pass promotion_code
yeap
maybe I need to handle if promo code is invalid
currently I use this
based on stripe error handle doc
Hhm, are you just talking out loud or is there a question for me here?
Yeah, that is handled by stripe. Like if the promotion code does not exist on your account, it will error out. You should try sending a non valid promo code and see the error it returns.
Here is a list of our error codes: https://stripe.com/docs/error-codes but I'm unsure what you mean with 'error type for all stripe types?'
Can you add more clarity here?
I define type StripeCustomer = Stripe.Customer in typescript, is there a way to do it with errors?
What do you mean by this? Do what?
Did you try passing an invalid promo code to the above subscription update request? Do you not see an error?
I should use stripe error handling, I am think it wrong. I thought I should handle errors.
my bad
From what you're looking yes, when you pass an invalid coupon Stripe will send an error.
if using stripe error handling and send 404 from backend to frontend. it will show 404 in the browser console. is it ok?
I see what you're asking, we document that here: https://stripe.com/docs/error-handling?lang=node#catch-exceptions
let me see it
that's it
thank you sir
^_^