#M.Mixalis-checkout
1 messages · Page 1 of 1 (latest)
Hi! What do you mean by dd a discount amount directly to the session? You want to add the code using the API, or on the Checkout Session page direclty?
checkout session page directly. without using the api for promo codes etc
Got it, then you should use allow_promotion_codes https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-allow_promotion_codes
i have a lot of clients with custom pricings..
soma, i dont want to use promo codes in stripe's checkout session. I already have a checkout form on my website. i want to just redirect the user to stripe's checkout to pay. The customer may already used promo codes OR (important) have already discounts applied in his cart using custom pricing rules from my website.
Sorry I'm not sure I understand. For Checkout Session, you have two options to use coupons:
- Use
allow_promotion_codesto let your customer enter a promo code on the Checkout page - Use
discountto dynamically pass a promo code with the API that will change the price customer will have to pay
What exactly are you trying to achieve?
i do not want to use promo_code. i want the line_item base_price on the checkout to be shown as strike-through and the actual payable amount next to it.
So you would like to add a discount of specific line items.
flat price discount on line_item is what i'm trying to achieve.
unit_amount field holds the final price right? i would like a base_unit_amount that would hold the base price for that line item.
ex. customer A has custom pricing -10% to a product category. (no other customer has that pricing). This pricing is not applied via promo_code. It is applied automatically when the customer logged in.
I think what you could do here is:
- Create a coupon that applies only to one (or a few) specific product(s) with
applies_tohttps://stripe.com/docs/api/coupons/create#create_coupon-applies_to - And then dynamically pass that coupon to the Checkout Session using
discount. So only the line item(s) corresponding to the specific product(s) will have the discount
Would that work?
that is what i thought of, but i was hoping that i could pass params like line_items.data.discounts like shown here https://stripe.com/docs/api/checkout/sessions/object
but this seems to be the return of the session. not while creating it.
line_items.data.discounts.amount
Unfortunately, when creating the Checkout Session, there's no line_items.data.discounts https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Another option would be to not use discounts at all, and directly change the line_items.price_data with the correct price. And maybe use line_items.price_data.product_data.name or line_items.price_data.product_data.description to explicitely mention that there is a discount applied on the price.
btw, this is exceptional support. thank you.