Laravel 7/6 Stripe Payment Gateway Integration Example

In this tutorial you will learn about the Laravel 7/6 Stripe Payment Gateway Integration Example and its application with practical example.

In this Laravel 7/6 stripe payment gateway integration tutorial, I’ll show you how to integrate stripe payment gateway in laravel 7. In this tutorial you will learn to integrate stripe in laravel 7. In this step by step tutorial I’ll share laravel 7 stripe integration example.

Stripe Payment Gateway

Stripe is one of the most popular payment gateway, that allows us to accept payment worldwide. Stripe is very simple, hassle free and easy to integrate payment gateway. Integrating stripe payment gateway with laravel is a breeze. After integrating stripe in laravel you will be able to collect payment via simple payment form which allow customer to provide card information like card number, expiry date and a CVC code.

Laravel 7/6 Stripe Payment Gateway Integration Example

In this tutorial, you will learn to integrate stripe payment gateway in your laravel 7 project. Follow this step by step tutorial to learn stripe payment gateway integration in laravel 7.

Laravel 7/6 Stripe Payment Gateway Integration Example

  • Step 1: Install Laravel Fresh Setup
  • Step 2: Install stripe Package
  • Step 3: Set Secret Credential
  • Step 4: Make Route
  • Step 5: Create Controller
  • Step 6: Create Blade View file
  • Step 7: Run Development Server

Step 1: Install Laravel Fresh Project

First of all we need to create a fresh laravel project, download and install Laravel using the below command

Step 2: Install Stripe package

Now, we need to install stripe-laravel package in our project. Open your terminal and switch to project directory and use the following composer command to install stripe-laravel package.

After that, we need to register the provider and aliases. Go to the app/config/app.php and put the below lines here :

Step 3: Set Secret Credential

Now, we need to set stripe key and secret key in our project’s .env file. In stripe dashboard switch to the test mode and get the stripe key and secret. Now, open .env file located in project’s root folder and set the stripe key and secret as following –

.env file

You will also need to set up the Stripe API key, Let’s open or create the config/services.php file, and add or update the 'stripe' array as following:

Step 4: Make Route

After this, we need to add following two routes in “routes/web.php” to display barcode. Lets open “routes/web.php” file and add following route.

routes/web.php

Step 5: Create Controller

Now, lets create a payment controller using following command

Go to app/Http/Controller/StripeController and put the below code :

Step 6: Create Blade View file

In this step, we will create view/blade file to accept stripe payment. Lets create astripe.blade.php” file in “resources/views/” directory and put the following code in it.

resources/views/stripe.blade.php

Step 7: Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Testing Card Credential

In this tutorial we have learn about the Laravel 7/6 Stripe Payment Gateway Integration Example and its application with practical example. I hope you will like this tutorial.