#stilo01
1 messages · Page 1 of 1 (latest)
You can add additional price IDs in the line_items array if you want to sell multiple items
I have this page but there is only one /create-checkout-session request
<!DOCTYPE html>
<html>
<head>
<title>Buy cool new product</title>
<link rel="stylesheet" href="style.css">
<script src="https://js.stripe.com/v3/"></script>
</head>
<body>
<section>
<div class="product">
<img src="https://i.imgur.com/EHyR2nP.png" alt="The cover of Stubborn Attachments" />
<div class="description">
<h3>Stubborn Attachments</h3>
<h5>$20.00</h5>
</div>
</div>
<form action="/create-checkout-session" method="POST">
<button type="submit" id="checkout-button">Checkout</button>
</form>
</section>
</body>
</html>
Not sure I fully grasp your question. Server-side code creates checkout session and that's where you also pass in the line items.
So one /create-checkout-session request shouldn't matter
how does the server know what is the product youre trying to buy
You control that. Ideally, when you send a POST request to your server, you'd send along the information about the product(s) being purchased. Then figure out what the appropriate price ID is for that product and create checkout session with that
I mean: the class product is the name of the product?
The quickstart example doesn't actually pass any product information to the server-side. It uses a static (predefined) price ID on the server-side.
What you're asking about is basic client-server communication with JS. Nothing specific to Stripe APIs. You need to look up resources on how you can send information to your server-side logic using POST requests
that is my problem (sorry for the ignorance), I don't know if I have to create a request (in the backend) for any product I want to sell
and why does it import https://js.stripe.com/v3/
Have you looked at this guide instead?
https://stripe.com/docs/payments/accept-a-payment
It walks you through the process step by step
and why does it import https://js.stripe.com/v3/
I believe you can ignore that, you don't need to import stripe.js to work with Checkout Sessions