Stripe Payment Gateway Integration in Laravel 5.8

Admin   PHP   31519  2021-06-13 10:55:59

In this tutorial, i will guide you step by step laravel 5.8 stripe integration example from scratch. you will learn to implement stripe payment gateway integration with your laravel 5.8 application.

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

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

Follow Tuto: Payment Processing by HighRiskPay

I will give you example from scratch to implement stripe payment gateway in laravel 5.8 application. You just need to follow few step to get full example to pay.

Step 1: Install Laravel 5.8

I am going to explain step by step from scratch so, we need to get fresh Laravel 5.8 application using bellow command, So open your terminal OR command prompt and run bellow command:

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

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 bellow command:

composer require stripe/stripe-php

Step 3: Set Stripe API Key and SECRET

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




Step 4: Create Routes

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



Route::get('stripe', '[email protected]');

Route::post('stripe', '[email protected]')->name('');

Step 5: Create Controller File

in next step, now we have create new controller as StripePaymentController and write both method on it like as bellow, So let's create both controller:



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Session;

use Stripe;

class StripePaymentController 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 File

In 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 following code: