Laravel 8 Razorpay Payment Gateway Integration Example

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

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

Laravel 8 Razorpay Payment Gateway Integration Example

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

  • SInstall Laravel 8 App
  • Connecting App to Database
  • Create Model & Migration
  • Make Routes
  • Create Controller & Methods
  • Create Blade View
  • Start Development Server
  • Run This App

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.

Create Model & Migration

Now, we have to define table schema for payments table. Open terminal and let’s run the following command to generate a migration along with model file to create payments table in our database.

Once this command is executed you will find a migration file created under “database/migrations”. lets open migration file and put following code in it –

Now, run following command to migrate database schema.

After, the migration executed successfully the payments table will be created in database.

Create Routes

After this, we need to add following routes in “routes/web.php” file along with a resource route. Lets open “routes/web.php” file and add following route.

routes/web.php

Create Controller By Artisan Command

Now, lets create a controller for Razorpay Payments. Create a controller named RazorpayController using command given below –

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

app/Http/Controllers/RazorpayController.php

Create Blade Views

In this step, we will create view/blade file razorpay payment processing. Lets create a blade file “razorpay.blade.php” in “resources/views/” directory and put the following code in it respectively.

resources/views/razorpay.blade.php

Get your secret key from razorpay payment gateway dashboard and put the key in script tag section like this => “key”: “rzp_test_ddgdfgdfgdg”,

Then visit resources/views and Create a new blade view file name thankyou.blade.php. Then put the following code into it:

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 –

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