#Meldin
1 messages · Page 1 of 1 (latest)
How are you implementing this?
PaymentIntents, for example don't take coupons. Are you using your own logic to manage discounts?
Yes I do
Actualy, I made a coupon on Stripe dashbord and then I grab the coupon id and paste it in sanity as a product field
then on the backend I check if the coupon is valid and if it is then I push that coupon in discounts array
what discounts array
Are you using Checkout Sessions?
How are you accepting payments?
Here: const params = {
submit_type: "pay",
mode: "payment",
discounts: discounts,
payment_method_types: [
"card",
"klarna",
"afterpay_clearpay",
Yes then I pass this params object to the checkout session
On stripe docs they said that there is only one coupon supported by session
Ah yes
That's correct. Only 1 coupon can be used in a checkout session currently
To make sure it applies to all items in the checkout session and not just 1 of them you need to make sure the coupon can apply to all items
coupons have an applies_to field that will restrict this: https://stripe.com/docs/api/coupons/create#create_coupon-applies_to
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So you think I can solve my issue by creating the coupon like on docs but not using Dashbord
You should be able to do it via the dashboard too
Just don't restrict which products it applies to to only one of the products
With Checkout, you can only add 1 coupon
So your model of having a coupon for each product won't work if your customer needs to add multiple of these products and hence multiple of these coupons
The only way to handle this in Stripe Checkout if you need them to be able to add multiple products is to have 1 coupon that applies to all the products