#Robin020

1 messages · Page 1 of 1 (latest)

tiny hazelBOT
fathom bane
#

👋 happy to help

#

would you mind sharing the IDs (coupon, checkout)?

drifting temple
#

Yes

#

NRKitQnJ (works)
ivQuHHTm (doesnt)
zcNTNsaR (doesnt)

#

Front end: onChange={(e) => setCoupon(e.target.value)}

#

Back end:

  const { prod, id, email, startDatum, coupon } = req.body;
  console.log("Create checkout session...");

  const couponEdit = coupon.toLowerCase().trim();
  let activeCoupon;

  switch (couponEdit) {
    case "first50":
      activeCoupon = prod ? "NRKitQnJ" : "123456";
      break;
    case "welkom50":
      console.log("Welkom50");
      activeCoupon = "ivQuHHTm";
      console.log(activeCoupon);
      break;
    case "welkom40":
      activeCoupon = "zcNTNsaR";
      break;
    case "welkom30":
      activeCoupon = "DWp4nBcr";
      break;
    case "first100":
      activeCoupon = "first100";
      break;
    default:
      break;
  }

  try {
    const YOUR_DOMAIN = prod
      ? "https://hulpmethuren.nl/activeren"
      : "http://127.0.0.1:5173/activeren";
    const SUCCESS = prod
      ? "https://hulpmethuren.nl/welkom"
      : "http://127.0.0.1:5173/welkom";

    const customer = await stripe.customers.create({
      metadata: {
        id,
        email,
        startDatum,
      },
    });

    const session = await stripe.checkout.sessions.create({
      billing_address_collection: "auto",
      line_items: [
        {
          price: prod
            ? "price_1MQme0FM0KvL0X1JsXhSJlJU"
            : "price_1MQZowFM0KvL0X1Ju1THqKR8",
          // For metered billing, do not pass quantity
          quantity: 1,
        },
      ],
      subscription_data: {
        trial_period_days: 7,
      },
      discounts: [
        {
          coupon: activeCoupon,
        },
fathom bane
#

would you mind sharing your account ID?

drifting temple
#

I need to save that one

#

let me check

#

acct_1MLPloFM0KvL0X1J

fathom bane
#

ok will take a look shortly

drifting temple
#

thanks

fathom bane
#

what is the checkout session ID or request ID where the coupon is not working?