Laravel 8 Stripe Payment Gateway Integration Example

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

In this Laravel 8 stripe payment gateway integration tutorial, I’ll show you how to integrate stripe payment gateway in laravel 8. In this tutorial you will learn to integrate stripe in laravel 8. In this step by step tutorial I’ll share laravel 8 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 8 Stripe Payment Gateway Integration Example

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

Laravel 8 Stripe Integration Example

  • Install Laravel 8 App
  • Install stripe Package
  • Stripe Configuration
  • Make Route
  • Create Controller
  • Create Blade View file
  • Run Development Server

Install Laravel 8

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

Make sure you have composer installed.

Setup Database Credentials

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Install Stripe package

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

Stripe Configuration

Create Stripe account and generate key and secret key. Go to the official Stripe website and signup with basic details. 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:

Create 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

Create Controller and Methods

Now, lets create a payment controller using following command

Once the above command executed, it will create a controller file StripeController.php in app/Http/Controllers/ directory. Open the StripeController.php file and put the following code in it.

Controllers/StripeController.php

Create View/Blade 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

Start 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 –

http://localhost:8000/stripe

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