#AlexFitFlow-react-products
1 messages ยท Page 1 of 1 (latest)
Hi there
I'm a bit confused
So you are passing the products selected from the frontend to backend, but when you create your Checkout Session (and then redirect to it) you aren't seeing those same products in the actual Checkout Session UI?
Is that the issue?
AlexFitFlow-react-products
Yes that is the issue
For the product id passed in line items that is only a temporary
That ID is for a product I created from the stripe website
I want to pass the data from the cart so the price and quantity are what shows up @jovial mesa
@ancient vortex
Hi ๐ your third screenshot seems to show a fixed string being provided as the price parameter when creating the Checkout Session. Is that the Price that you are seeing in the Checkout Sessions that you have been creating?
I believe that is the same one? Im not sure what line was passed. I was advised to do so but either way it brings up a price of a product I created on the Stripe website
My goal is to get the users cart items total price and quantity to show
It looks to me like your Checkout Session creation request has that hard coded Price, so it will always create a Checkout Session for the same thing.
How are you passing the details of your customer's cart from your frontend to your backend code?
This is my checkout.jsx page which I use redux for the cart. I store the cart details in the state
I set products to equal to state then I passed products in the data
@ancient vortex @jovial mesa
Sorry, I'm not too well versed in React, does that mean the data is available to your server-side code? Can you read the details of your customers cart from within your server.js file?
I have a console log in my server.js so it lets me know that the items have been read
The data seems to be available in my server side
Okay, so you'll need to adjust your code that creates the Checkout Session to use that data. Currently you're passing one entry in the line_items array, and you're passing a static value for its price parameter.
You'll need to include enough entries in the line_items array to map to the number of items you need to include.
Since you're not using existing Prices, you'll want to use price_data instead of price to provide the necessary details for the Checkout Session to build Prices:
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data
However, I would strongly encourage you test your flow and see if you can manipulate the value of your cart directly via your browser's dev tools. We typically recommend using Prices and referencing them by ID to avoid scenarios where savvy users manipulate the javascript on your page and change how much they pay.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.