Hi,
I think the $YOUR_DOMAIN url must be public so that the stripe server can access it.
If you are using valet you can easily create a public url for your dev machine: https://laravel.com/docs/8.x/valet#sharing-sites
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi based on documentation of stripe: https://stripe.com/docs/checkout/integration-builder I have added following to code to test whether it works or not and this is not workig for me. As the per demo I need to redirect to the stripe checkout form and this is not happening.Can you please help me.
step 1:
composer require stripe/stripe-php
step 2: My home.blade.php copied from docs
<!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>.00</h5>
</div>
</div>
<form action="/create-checkout-session" method="POST">@csrf
<button type="submit" id="checkout-button">Checkout</button>
</form>
</section>
</body>
</html>
and step 3
Route::post('/create-checkout-session',function(){
// require 'vendor/autoload.php';
\Stripe\Stripe::setApiKey('sk_test_FfKP0notiUK0s5XOrs7O3MKR');
header('Content-Type: application/json');
$YOUR_DOMAIN = 'http://localhost:8000';
$checkout_session = \Stripe\Checkout\Session::create([
'line_items' => [[
# TODO: replace this with the `price` of the product you want to sell
'price' => 'price_1RaJ35tHwG6zssijf9MneD9SQ',
'quantity' => 1,
]],
'payment_method_types' => [
'card',
],
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/success.html',
'cancel_url' => $YOUR_DOMAIN . '/cancel.html',
]);
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);
});
Please or to participate in this conversation.