#tyler_code

1 messages ยท Page 1 of 1 (latest)

upper mountainBOT
#

๐Ÿ‘‹ 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.

wanton olive
#
      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 ?
untold cape
#

Right, gotcha. And the coupon you're providing is effectively a free month?

wanton olive
#

yeah ``` discounts: [{ coupon: "Yh0ycabZ" }],

untold cape
#

And there are other promo codes your customers will be able to use at (/in) Checkout?

wanton olive
#

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

untold cape
#

Very clear, gotcha. As it stands, it sounds like you can't use those two things together.

wanton olive
#

ahh no way to do it huh?

untold cape
#

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

wanton olive
#

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

untold cape
#

Ok, gotcha.

#

One sec.

wanton olive
#

sure thing

untold cape
#

So your actual logic is something like:

If they have a 3-free-month coupon, they get 3 free months

Ya?

wanton olive
#

Right if they have the coupon and apply it they get 3 months instead of 1 free month

upper mountainBOT
wanton olive
#

Desired Flow:

  1. 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.

  2. 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).

untold cape
#

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)

wanton olive
#
  1. Default behavior: All users will automatically have a 1-month free coupon applied during checkout.

  2. 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.

upper mountainBOT
untold cape
#

...Ya but StripeBot is not my supervisor ๐Ÿคช

#

Cool. Your words are impossible to implement with Stripe Checkout, mine are not. ๐Ÿ™‚

wanton olive
#

sorry?

untold cape
#

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)

wanton olive
#

I see handle the logic on the client side before passing info to the api