Integrate Stripe Payment Gateway in Laravel 11

Hello developers! In this guide, we'll see how to integrate a stripe payment gateway in laravel 11 with step by step guide. Here, we'll learn laravel 11 stripe payment gateway integration. we'll use the stripe/stripe-php composer package in laravel 11. 

Stripe is a payment service provider that lets merchants accept credit and debit cards or other payments. Stripe Payments, is best suited for businesses that make most of their sales online.

Also, you can pay via debit card, credit card, and payment links. Stripe supports recurring payments like subscription based modal.

Laravel 11 Stripe Payment Gateway Integration

laravel 11 stripe payment gateway integration


Step 1: Install Laravel 11 Application

In this step, we'll install the laravel 11 application using the following composer command.

composer create-project laravel/laravel example-app


Step 2: Install stripe-php Package

Next, we'll install the stripe package using the following composer command. The Stripe PHP library provides convenient access to the Stripe API from applications written in the PHP language.

composer require stripe/stripe-php



Step 3: Create a Stripe Account

Now, we'll configure the stripe payment gateway as below in the images and code. If you don't have a Stripe account. create an account on Stripe.


Now, open the .env file and add the below code.



Step 4: Create Controller

Then, we'll create a StripePaymentController using the following command and define the login of the Stripe payment gateway.

php artisan make:controller StripePaymentController


namespace App\Http\Controllers;
use Stripe;
use Illuminate\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\RedirectResponse;
class StripePaymentController extends Controller
     * success response method.
     * @return \Illuminate\Http\Response
    public function index(): View
        return view('stripe');
     * success response method.
     * @return \Illuminate\Http\Response
    public function stripe(Request $request): RedirectResponse
        Stripe\Charge::create ([
                "amount" => 10 * 100,
                "currency" => "usd",
                "source" => $request->stripeToken,
                "description" => "Stripe Test Payment" 
        return back()->with('success', 'Payment has been successful');


Step 5: Create Routes

Now, we'll define the route to the web.php file.


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\StripePaymentController;
    Route::get('stripe', 'index');
    Route::post('stripe', 'stripe')->name('');


Step 6: Create Blade File

Then, we'll create a stripe.blade.php file for getting payment from the users. Also, we'll add jQuery code to create a card element.


<!DOCTYPE html>
		<title>Integrate Stripe Payment Gateway in Laravel 11 -</title>
		<link href="" rel="stylesheet" crossorigin="anonymous">
		<script src=""></script>
		<style type="text/css">
			height: 50px;
			padding-top: 16px;
		<div class="container">
			<div class="row">
				<div class="col-md-8 offset-md-2">
					<div class="card mt-5">
						<h3 class="card-header p-3">Integrate Stripe Payment Gateway in Laravel 11 -<</h3>
						<div class="card-body">
							<div class="alert alert-success" role="alert"> 
								{{ $value }}
							<form id='checkout-form' method='post' action="{{ route('') }}">
							<input type="input" class="form-control" name="name" placeholder="Enter Name">
							<input type='hidden' name='stripeToken' id='stripe-token-id'>                              
							<div id="card-element" class="form-control" ></div>
								class="btn btn-success mt-3"
								style="margin-top: 20px; width: 100%;padding: 7px;"
								onclick="createToken()">PAY $10
	<script src=""></script>
	<script type="text/javascript">
		var stripe = Stripe('{{ env('STRIPE_KEY') }}')
		var elements = stripe.elements();
		var cardElement = elements.create('card');
		function createToken() {
		    document.getElementById("pay-btn").disabled = true;
		    stripe.createToken(cardElement).then(function(result) {
		        if(typeof result.error != 'undefined') {
		            document.getElementById("pay-btn").disabled = false;
		        /* creating token success */
		        if(typeof result.token != 'undefined') {
		            document.getElementById("stripe-token-id").value =;


Step 7: Run the Laravel 11 Application

Now, run the laravel 11 application using the following command.

php artisan serve

Testing card details:

Card Name: Test
Card Number: 4242424242424242
Month: 07
Year: 2027
CVV: 123




You might also like:


Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.