#pastyghost_best-practices
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1326936173708443659
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
You can't restrict a coupon to a customer, but you can set duration to once: https://docs.stripe.com/api/coupons/create#create_coupon-duration and apply it to a set of products: https://docs.stripe.com/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'd need to restrict by customer on your end
Or only share coupon with a specific customer
Gotcha - so "once" just really means "once per purchase"?
It means it can only be used once period
Per customer or across my entire store?
OK - so does that mean every customer can use it only once, or that it can only ever be used once?
Oh sorry I linked the wrong param
https://docs.stripe.com/api/coupons/create#create_coupon-max_redemptions is what you'd need to set to 1
^ would mean it can only ever be used once
So you'd create 1 coupon per each customer
Okay, I think we're talking past each other here. What I'd like to do is create 1 coupon that can only be used once per purchase.
Any number of customers can use it, but only once per purchase.
Are these one-time or subscription purchases?
Because duration does do this but only for subscription
If one-time, then I think what you could do is create 1 coupon. Then, you can create a promo code under that coupon for each customer, specifying max_redemptions to 1: https://docs.stripe.com/api/promotion_codes/create#create_promotion_code-max_redemptions
And if this needs to be for a first time purchase only, then there's an easier way to restrict it via: https://docs.stripe.com/api/promotion_codes/create#create_promotion_code-restrictions-first_time_transaction
They're one-time purchases.
I just don't know how many customers I'm going to have, and I just want to have one code to give out.
Do you only want the coupon to be used for a customer's first time purchase? Or is it a possibility that they've paid before without the coupon and you want them to be able to use it on their 3rd purchase, for example?
First time purchase.
Yeah so all you need to do is create 1 coupon and 1 promo code and set that param: #1326936173708443659 message
Gotcha, thank you!
I have a follow-on question about applying that coupon via the API. Should I create a separate thread for that?
No you can ask in here
How are you accepting payments?
But it looks like this:
params := &stripe.CheckoutSessionParams{
PaymentMethodTypes: stripe.StringSlice([]string{
"card",
}),
LineItems: []*stripe.CheckoutSessionLineItemParams{
&stripe.CheckoutSessionLineItemParams{
Price: stripe.String("{{PRICE_ID}}"),
Quantity: stripe.Int64(1),
},
},
Mode: stripe.String("subscription"),
Discounts: []*stripe.CheckoutSessionDiscountParams{
&stripe.CheckoutSessionDiscountParams{
Coupon: stripe.String("{{COUPON_ID}}"),
},
},
SuccessURL: stripe.String("https://example.com/success"),
CancelURL: stripe.String("https://example.com/cancel"),
}
auto applies it.
CheckoutSessions.
Yeah don't pass it there
One sec
You want to set this to true: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-allow_promotion_codes
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
The will allow them to enter the promo code
Note coupon represents the discount in Stripe
Promo code represents the code the customer enters
You need to create a promo code for a coupon
And the promo code is what they'll enter
And that is what will have the first time purchase restriction
Gotcha, thank you!
No problem
So this is my code:
if (lineItems.ShippingID == "") {
params = &stripe.CheckoutSessionParams{
UIMode: stripe.String("embedded"),
ReturnURL: stripe.String(domain + "/success?session_id={CHECKOUT_SESSION_ID}"),
LineItems: []*stripe.CheckoutSessionLineItemParams{
{
Price: stripe.String((lineItems.ItemID)),
Quantity: stripe.Int64(1),
},
},
Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)},
AllowPromotionCodes: stripe.Bool(true),
}
} else {
params = &stripe.CheckoutSessionParams{
UIMode: stripe.String("embedded"),
ReturnURL: stripe.String(domain + "/success?session_id={CHECKOUT_SESSION_ID}"),
LineItems: []*stripe.CheckoutSessionLineItemParams{
{
Price: stripe.String((lineItems.ItemID)),
Quantity: stripe.Int64(1),
},
},
ShippingOptions: []*stripe.CheckoutSessionShippingOptionParams{
{
ShippingRate: &lineItems.ShippingID,
},
},
Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)},
AllowPromotionCodes: stripe.Bool(true),
}
}
But I'm not seeing a field to enter my promotion code.
ope, nvm
looking in the wrong place.