• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Stripe Checkout session with total price and not unit_price

Resolved: Stripe Checkout session with total price and not unit_price

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I’m working on a project currently. and I’m making use of stripe, the stripe.checkout.session.create function works perfectly.


but the only issue i have is it receives only unit price.
but i want a field where i can pass only total Price, cause in my code , if the users applys a discount to a product , it deducts it from the product total price meanwhile the unit price for each product is stable.
My question is basically is there a field where i can pass total price.

Answer:

Short answer is that you can’t. You need to use the line_items parameter and either pass a Price object ID (price_xxx) or use ad-hoc pricing with the price_data parameter. Checkout will then compute the total from all line items, factoring in any discounts that you provide.
You have a couple of options to achieve the behaviour you want:
  • Re-calculate the price_data.unit_amount value to reflect the discount applied by your customers.
  • Utilise Stripe coupons to apply to the Checkout Session which will take care of the dedication for you.

If you have better answer, please add a comment about this, thank you!

node.js stripe-payments
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How do I use SetWindowText with Unicode in Win32 using PowerShell?

01/04/2023

Resolved: Shopware 400 Status Error “This value is too long. It should have 255 character or less.” When I Try Updating Database Table

01/04/2023

Resolved: Using AWK to count multiple patterns in a file

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.