Laravel 10 Stripe Payment Gateway Integration Example


Laravel 10 stripe payment gateway integration tutorial example; this tutorial will show you how to integrate stripe payment gateway in Laravel 10 app.

Stripe was founded in 2011 and is a payment gateway that lets you accept credit card payments (in person or online) by transferring money between your merchant account and a payment processor. This is done using a physical credit card terminal or an online processor

Stripe is the most popular payment gateway which is integrated into many websites, Stripe payment is easy to integrate and use. Stripe is a very simple and most powerful and flexible tool. So in this tutorial, you will learn step by step how to integrate stripe payment gateway in Laravel 10 app.

Stripe Payment Gateway Integration In Laravel 10

  • Step 1: Install Laravel 10 App
  • Step 2: Install stripe Package
  • Step 3: Stripe Configuration
  • Step 4: Make Route
  • Step 5: Create Controller
  • Step 6: Create Blade View file
  • Step 7: Run Development Server

Step 1: Install Laravel 10 App

In this step, execute the following command on terminal to install Laravel 10 app. So, Open command prompt and execute the following command:

composer create-project --prefer-dist laravel/laravel blog

Step 2: Install Stripe package

In this step, install stripe package in Laravel 10 app by executing the following command on terminal:

composer require stripe/stripe-php

After that, you need to set stripe key and secret. So, visit on Stripe website and create development stripe account. And get key and secret from

Step 3: Stripe Configuration

Now open .evn file and set the secret credential provided by a stripe payment gateway


Next step, you need to set up the Stripe API key, to do this open or create the config/services.php file, and add or update the 'stripe' array:

   'stripe' => [
        'secret' => env('STRIPE_SECRET'),

Step 4: Make Route

In this step, open web.php file, which is placed inside routes directory. And add the following routes into it:

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\StripeController;
| 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', [StripeController::class, 'stripe']);
Route::post('stripe', [StripeController::class, 'stripePost'])->name('');

Step 5: Create Controller

In this step, execute the following command on terminal to create the controller name StripeController:

php artisan make:controller StripeController

Then visit app/Http/Controllers/ directory and open StripeController. Then add the following code into StripeController.php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Session;
use Stripe;
class StripeController extends Controller
     * success response method.
     * @return \Illuminate\Http\Response
    public function stripe()
        return view('stripe');
     * success response method.
     * @return \Illuminate\Http\Response
    public function stripePost(Request $request)
        Stripe\Charge::create ([
                "amount" => 100 * 100,
                "currency" => "usd",
                "source" => $request->stripeToken,
                "description" => "Test payment from" 
        Session::flash('success', 'Payment successful!');
        return back();

Step 6: Create Blade View file

In this step, Visit app/resources/views/ and create one blade view file name stripe.blade.php. Then add the following code into Stripe.blade.php file:

<!DOCTYPE html>
<title>Laravel 10 - Stripe Payment Gateway Integration Tutorial Example -</title>
<link rel="stylesheet" href="">
<script src=""></script>
<style type="text/css">
.panel-title {
display: inline;
font-weight: bold;
.display-table {
display: table;
.display-tr {
display: table-row;
.display-td {
display: table-cell;
vertical-align: middle;
width: 61%;
<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" >
<div class="row display-tr" >
<h3 class="panel-title display-td" >Payment Details</h3>
<div class="display-td" >                            
<img class="img-responsive pull-right" src="">
<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>
action="{{ route('') }}" 
data-stripe-publishable-key="{{ env('STRIPE_KEY') }}"
<div class='form-row row'>
<div class='col-xs-12 form-group required'>
<label class='control-label'>Name on Card</label> <input
class='form-control' size='4' type='text'>
<div class='form-row row'>
<div class='col-xs-12 form-group card required'>
<label class='control-label'>Card Number</label> <input
autocomplete='off' class='form-control card-number' size='20'
<div class='form-row row'>
<div class='col-xs-12 col-md-4 form-group cvc required'>
<label class='control-label'>CVC</label> <input autocomplete='off'
class='form-control card-cvc' placeholder='ex. 311' size='4'
<div class='col-xs-12 col-md-4 form-group expiration required'>
<label class='control-label'>Expiration Month</label> <input
class='form-control card-expiry-month' placeholder='MM' size='2'
<div class='col-xs-12 col-md-4 form-group expiration required'>
<label class='control-label'>Expiration Year</label> <input
class='form-control card-expiry-year' placeholder='YYYY' size='4'
<div class='form-row row'>
<div class='col-md-12 error form-group hide'>
<div class='alert-danger alert'>Please correct the errors and try
<div class="row">
<div class="col-xs-12">
<button class="btn btn-primary btn-lg btn-block" type="submit">Pay Now ($100)</button>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(function() {
var $form         = $(".require-validation");
$('form.require-validation').bind('submit', function(e) {
var $form         = $(".require-validation"),
inputSelector = ['input[type=email]', 'input[type=password]',
'input[type=text]', 'input[type=file]',
'textarea'].join(', '),
$inputs       = $form.find('.required').find(inputSelector),
$errorMessage = $form.find('div.error'),
valid         = true;
$inputs.each(function(i, el) {
var $input = $(el);
if ($input.val() === '') {
if (!$'cc-on-file')) {
number: $('.card-number').val(),
cvc: $('.card-cvc').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val()
}, stripeResponseHandler);
function stripeResponseHandler(status, response) {
if (response.error) {
} else {
/* token contains id, last4, and card type */
var token = response['id'];
$form.append("<input type='hidden' name='stripeToken' value='" + token + "'/>");

Step 7: Run Development Server

In this step, execute the PHP artisan serve command on terminal to start development server:

php artisan serve

If you want to run the project diffrent port so use this below command

php artisan serve --port=8080

Now, open browser and hit the following URL on it:


Testing Card Credential

 Card No : 4242424242424242
Month : any future month
Year : any future Year
CVV : 123


Stripe payment gateway integration in Laravel 10 tutorial, you have learn how to integrate the stripe payment gateway in Laravel 10 app.

Recommended Laravel Posts

If you have any questions or thoughts to share, use the comment form below to reach us.


Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.


Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00