#stilo01

1 messages · Page 1 of 1 (latest)

haughty urchinBOT
sour cargo
#

You can add additional price IDs in the line_items array if you want to sell multiple items

lyric scarab
#

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>
sour cargo
#

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

lyric scarab
#

how does the server know what is the product youre trying to buy

sour cargo
#

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

lyric scarab
#

I mean: the class product is the name of the product?

sour cargo
#

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

lyric scarab
#

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/

sour cargo