Laravel 7/6 Razorpay Payment Gateway Integration Tutorial

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

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

Razorpay Payment Gateway

Razorpay is one of the popular payment gateway, that allows us to accept payment from your customer. Razorpay is very simple, hassle free and easy to integrate payment gateway. Integrating Razorpay payment gateway in laravel 7/6 is a breeze.

Laravel 7/6 Razorpay Payment Gateway Integration Tutorial

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

  • Install Laravel App
  • Setup Database
  • Model & Migration
  • Make Route
  • Create Controller & Methods
  • Create Blade View
  • Start Development Server

Step 1: Install Laravel App

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

Step 2: Setup Database

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.

Step 3: Model & Migration

Now, in this step we will create model and migration file. Please run the following command:

The above command will create a model name Payment and also create a migration file for the Payment table. Now, go to database/migrations/Payments.php file and replace function, below here :

Before we run php artisan migrate command go to app/providers/AppServiceProvider.php and put the below code :

Now, in this step we will create model and migration file. Please run the following command:

Step 4: Make Route

Now we will create following routes in the web.php file. Go to app/routes/web.php file and create following routes in it. The first route is to list products and second route is to store payments_id and user information provided by the razorpay payment gateway.

routes/web.php

Step 5: Create Controller

Now, lets create a controller named RazorpayController using command given below –

After successfully create controller go to app/controllers/RazorpayController.php and put the below code :

Step 6: Create Blade view

Now we will create some blade view file name razorpay.blade.php and where we will show product list. Go to resources/views & create razorpay.blade.php file.

Get Your secret key from razorpay payment gateway dashboard and put the key in script tag section,

 

Go to resources/views and Create a new blade view file name thankyou.blade.php. It is used for showing after payment success.

Step 7: 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 –

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