#tyler_code
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/1342550796641898506
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- tyler_code, 6 days ago, 30 messages
customer: customerId,
payment_method_types: ["card"],
line_items: [
{
price: priceId,
quantity: 1,
},
],
metadata: {
companyId,
userEmail,
},
mode: "subscription",
billing_address_collection: "required",
customer_update: {
name: "auto",
address: "auto",
},
success_url: `${process.env.NEXTAUTH_URL}/payments/success`,
cancel_url: `${process.env.NEXTAUTH_URL}/payments/cancel`,
allow_promotion_codes: true,
discounts: [{ coupon: "Yh0ycabZ" }],
});```
Having ``` allow_promotion_codes: true,
discounts: [{ coupon: "Yh0ycabZ" }],``` Both of these causes the error "Stripe subscription error: StripeInvalidRequestError: You may only specify one of these parameters: allow_promotion_codes, discounts." Is it not possible to have a automaic code apply and a option to manually input another coupon code that would be used instead ?
Right, gotcha. And the coupon you're providing is effectively a free month?
yeah ``` discounts: [{ coupon: "Yh0ycabZ" }],
And there are other promo codes your customers will be able to use at (/in) Checkout?
Yeah there is a 3 month promo code i want customers be able to use at checkout if they know
``` This works only if ``` discounts: [{ coupon: "Yh0ycabZ" }],
``` is not also in the code so its not letting me have both
Stripe subscription error: StripeInvalidRequestError: You may only specify one of these parameters: allow_promotion_codes, discounts. error
Very clear, gotcha. As it stands, it sounds like you can't use those two things together.
ahh no way to do it huh?
Is the logic you're trying to accomplish something like this?
If they don't have their own coupon, use this one for a 1 month free
The logic is The user clicks subscribe button => They get taken to Chckout Portal => There is a automaic 100 percent coupon 1 month free applied => after 1 month they will get billed monthy
But
if they have the 3Month free promo code they can type it in the promo input and apply it
and they will instead get 3 months free instead of the automatic 1 month that everyone gets by default
thats what im aiming for
sure thing
So your actual logic is something like:
If they have a 3-free-month coupon, they get 3 free months
Ya?
Right if they have the coupon and apply it they get 3 months instead of 1 free month
Desired Flow:
-
Auto-applied coupon: A coupon should automatically apply for all customers, offering a fixed discount (e.g., 1 month free) to all users who are being charged for a subscription.
-
User input for promotion codes: In addition to the auto-applied coupon, I would like to give customers the ability to enter their own promo code at checkout, which would override the existing discount if valid (e.g., a special code for 3 months free).
Hold on.
Your desired flow is to give everyone the first month off, except for those who have a 3-month off coupon.
(aka let's take a step back)
-
Default behavior: All users will automatically have a 1-month free coupon applied during checkout.
-
Override with promo code: Users who have a valid 3-month promo code can enter it, and it should replace the 1-month auto-applied coupon with a 3-month free subscription.
...Ya but StripeBot is not my supervisor ๐คช
Cool. Your words are impossible to implement with Stripe Checkout, mine are not. ๐
sorry?
Your words, which are very specifc, are not compatible with Checkout - as you have discovered - so you need to find a different way to do item 1.
Or, a different way to deal with deciding between 1 and 2, before you get to Checkout Session creation.
(i.e., you know the correct promo before you create the session because you asked them if they had a promo code before you sent them to Checkout, and if they did, you used that, and if they didn't, you used the base one)
I see handle the logic on the client side before passing info to the api