Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ekrist1's avatar

Laravel and Stripe checkout

According to the Stripe documentation, it's necessary to include stripe.js:

<!DOCTYPE html>
<html>
  <head>
    <title>Buy cool new product</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://polyfill.io/v3/polyfill.min.js?version=3.52.1&features=fetch"></script>
    <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>.00</h5>
        </div>
      </div>
      <form action="/create-checkout-session.php" method="POST">
        <button type="submit" id="checkout-button">Checkout</button>
      </form>
    </section>
  </body>
</html>

If you are using Laravel chachier Stripe to generate the session id, and then perform the redirect to the stripe hosted checkout page, it seems like the stripe.js isn't necessary.

Visit: https://laravel.com/docs/8.x/billing#product-checkouts

Anyone know the purpose to load the stripe.js on the client side, when using Stripe Checkout?

0 likes
3 replies
ekrist1's avatar

@shaungbhone have seen it, but it covers Stripe Elements. I'm fiddling around with Stripe hosted Checkout. The hosted checkout works without including the stripe javascript, but all example code, including Stripe support tell it's mandatory to load the Stripe javascript. I can't see how it´s used.

Visit: https://stripe.com/docs/checkout/integration-builder

martinbean's avatar

@ekrist1 Stripe’s documentation doesn’t say anything about loading the JS SDK when redirecting server-side.

It’s not necessary, but will probably be recommended because having the JS SDK loaded will let Stripe monitor your website usage and look for patterns that’ll it’ll use for fraud detection.

Please or to participate in this conversation.