Laravel 10 Stripe Payment Gateway Integration Tutorial

By Hardik Savani November 5, 2023 Category : Laravel

Hello Developer,

This extensive guide will teach you laravel 10 stripe integration. you can see stripe payment gateway integration in laravel 10. This article will give you a simple example of laravel 10 stripe payment gateway example. This post will give you a simple example of laravel 10 payment integration stripe example. follow the below example for stripe integration in laravel 10.

You need to create a stripe developer account and need to get API key and secret from there. Then we will use stripe/stripe-php composer library for the stripe payment gateway in laravel 10. I write step by step integration for the stripe payment gateway.

Stripe is a very popular and secure internet payment gateway company that helps to accept payments worldwide. Stripe provides really nice development interface to start and you don’t have to pay subscription charges to learn it provides a free developer account, before starting to code in your app.

I will give you an example from scratch to implement a stripe payment gateway in the laravel 10 application. You just need to follow a few steps to get a full example to pay.

Step 1: Install Laravel 10

This is optional; however, if you have not created the laravel app, then you may go ahead and execute the below command:

composer create-project laravel/laravel example-app

Step 2: Install stripe-php Package

In this step we need to install stripe-php via the Composer package manager, so one your terminal and fire the bellow command:

composer require stripe/stripe-php

Step 3: Set Stripe API Key and SECRET

Now, we need to set the stripe key and secret. so first you can go on Stripe website and create a development stripe account key and secret and add bellow:




Step 4: Create Controller File

in the next step, now we have create a new controller as StripePaymentController and write both methods on it like as below, So let's create both controllers:



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Stripe;

use Illuminate\View\View;

use Illuminate\Http\RedirectResponse;

class StripePaymentController extends Controller



* success response method.


* @return \Illuminate\Http\Response


public function stripe(): View


return view('stripe');



* success response method.


* @return \Illuminate\Http\Response


public function stripePost(Request $request): RedirectResponse



Stripe\Charge::create ([

"amount" => 10 * 100,

"currency" => "usd",

"source" => $request->stripeToken,

"description" => "Test payment from"


return back()

->with('success', 'Payment successful!');



Step 5: Create Routes

In this step, we will create two routes for get request and another for post request. So, let's add a new route to that file.



use Illuminate\Support\Facades\Route;

use App\Http\Controllers\StripePaymentController;



| Web Routes



| Here is where you can register web routes for your application. These

| routes are loaded by the RouteServiceProvider within a group which

| contains the "web" middleware group. Now create something great!




Route::get('stripe', 'stripe');

Route::post('stripe', 'stripePost')->name('');


Step 6: Create Blade File

In the Last step, let's create stripe.blade.php(resources/views/stripe.blade.php) for layout and write code of jquery to get token from stripe here and put the following code:


<!DOCTYPE html>



<title>Laravel 10 - Stripe Payment Gateway Integration Example -</title>

<link rel="stylesheet" href="" />

<script src=""></script>



<div class="container">

<h1>Laravel 10 - Stripe Payment Gateway Integration Example <br/></h1>

<div class="row">

<div class="col-md-6 col-md-offset-3">

<div class="panel panel-default credit-card-box">

<div class="panel-heading display-table" >

<h2 class="panel-title" >Checkout Forms</h2>


<div class="panel-body">

@if (Session::has('success'))

<div class="alert alert-success text-center">

<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>

<p>{{ Session::get('success') }}</p>



<form id='checkout-form' method='post' action="{{ route('') }}">


<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');




Create Token Code



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 =;







Run Laravel App:

All the required steps have been done, now you have to type the given below command and hit enter to run the Laravel app:

php artisan serve

Now, Go to your web browser, type the given URL, and view the app output:



Now you can check with the following card details:

Name: Test

Number: 4242 4242 4242 4242

CSV: 123

Expiration Month: 12

Expiration Year: 2028

I hope it can help you...