#yasin-gzeldal_api

1 messages ¡ Page 1 of 1 (latest)

verbal ospreyBOT
#

👋 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/1275413114321375232

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

carmine shoal
#

Hi! if I'm understanding your question correctly, toay we don't support item-level discounts in Checkout, only one discount across the Session

pine plinth
#

we managed to discount items but we create a product in stripe and reference the checkout session with the product. and of course the coupon applies only to the product ins tripe

carmine shoal
#

can you share some code and specific errors you're facing?

pine plinth
#

sure

#

      if (requestData.productKey === "addReport") {
       checkoutSessionLineItems.push({
          price_data: {
            currency: "eur",
            unit_amount: 100 * product.pricing.price.total,
            
            product_data: {
              images: [
                `https://gentastic.io/_next/image?url=/reportImages/${
                  requestData.reportKeys?.[0] ?? "cholin"
                }.jpg&w=640&q=75`,
              ],
              name: "Bericht Nachkaufen",
              description: requestData.reportKeys?.join(", ") ?? "",
              tax_code: "txcd_10000000",
              metadata: {
                reportKeys: requestData.reportKeys?.join(",") ?? "",
                "lookup-key": "addReport",
              },
            },
          },
          quantity: 1,
        });
      } else
        checkoutSessionLineItems.push({
          price: product.pricing.price.stripeReference.price[env],
          quantity: 1,
        });
#

so, when we add the line item with price_data it is not referenced to the product in stripe. in the else case it is reference through product.pricing.price.stripeReference.price[env]. in this case we have all the correct product ids set for test and prod envs

#

in the else case it can apply coupons, which apply only to one product, in checkout. the other ones it cannot

carmine shoal
#

that seems normal though right? Like you're saying you created a Coupon/PromotionCode that is limited to a specific Product (via applies_to ), so naturally you can't use that coupon when you're using a different Product(like this ad-hoc one you create)?

pine plinth
#

exactly

#

but what options do I have when I want to apply a coupon only to the addReport products

#

btw, I tried setting the lookup key but it did not work either. seems like the product needs to be referenced

#

so th equestion is how can I reference a product but change image and description, and the meta data

carmine shoal
#

so th equestion is how can I reference a product but change image and description, and the meta data
you can't; you'd create a new Product(which is what you're doing)

#

there isn't really a magic workaround here unfortunately; the only realy option here is using a different Product+Coupon

pine plinth
#

okay, thank you for the direction. I guess this would work, we only need to check if the coupon is applied directly or the user needs to enter the coupon code. because we are working with partners who get coupon codes and the customers need to enter the coupon manually

carmine shoal
#

if you pass `discounts[][coupon] = <coupon ID> it's applied directly, it's not a promo code that the user has to enter

pine plinth
#

there is also discounts.promotion_code maybe this will work

#

or is that one also applied directly

carmine shoal
#

it's applied directly. Is that not what you want? Or do you just want the user to be able to enter a promo code on the Checkout page?

pine plinth
#

yes, otherwise every customer would get the discount