How to Integrate Razorpay Payment Gateway in Laravel 8 App

How to Integrate Razorpay Payment Gateway in Laravel 8 App

In this Laravel 8 tutorial, you'll learn how to integrate Razorpay Payment Gateway in Laravel 8 App. We will use the JavaScript lib of the Razorpay Payment Gateway for payment deduction.

Laravel 8 razorpay payment gateway integration example. In this tutorial, you will learn how to integrate a razorpay payment gateway in laravel 8 app.

In this laravel 8 razorpay payment gateway example tutorial, will use the javascript lib of the razorpay payment gateway for payment deduction.

And as well as, will implement a simple script code for payment deduction and payment success.

Before start tutorial, you need to create razorpay account and get secret app key from razorpay app. So, you can visit this link and create razorpay app.

Laravel 8 Razorpay Payment Gateway Integration Example

  • Step 1: Install Laravel 8 App
  • Step 2: Connecting App to Database
  • Step 3: Create Model & Migration
  • Step 4: Make Routes
  • Step 5: Create Controller & Methods
  • Step 6: Create Blade View
  • Step 7: Start Development Server
  • Step 8: Run This App

Step 1: Install Laravel 8 App

In this step, download or install the latest laravel 8 app by using the following command, so open terminal and execute the following command:

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

Step 2: Connecting App to Database

In this step, visit laravel 8 app root directory and open .env file. Then add the database details:

  DB_CONNECTION=mysql 
  DB_HOST=127.0.0.1 
  DB_PORT=3306 
  DB_DATABASE=here your database name here
  DB_USERNAME=here database username here
  DB_PASSWORD=here database password here

Step 3: Create Model & Migration

In this step, create table name Payment and it’s migration file. use the below command.

php artisan make:model Payment -m

It command will create one model name Payment and also create one migration file for the Payment table. After successfully run the command go to database/migrations/Payments.php file and replace function, below here :

public function up()
 {
 Schema::create('payments', function (Blueprint $table) {
 $table->increments('id');
 $table->string('r_payment_id');
 $table->string('product_id');
 $table->string('user_id');
 $table->string('amount');
 $table->timestamps();
 });
 }

Next, migrate the table using the below command. It will create two new tables in the database.

php artisan migrate

Step 4: Make Route

In this step, create three routes and add on this routes in web.php file. So, visit /routes/web.php file and add the following routes in web.php:

use App\Http\Controllers\RazorpayController;

Route::get('product', [RazorpayController::class, 'index']);
Route::get('paysuccess', [RazorpayController::class, 'razorPaySuccess']);
Route::get('razor-thank-you', [RazorpayController::class, 'RazorThankYou']);

laravel javascript php web-development developer

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

PHP Web Application Development Company

As a top **PHP Web Application Development Company in USA**[https://www.dataeximit.com/php-development-services/](https://www.dataeximit.com/php-development-services/ "https://www.dataeximit.com/php-development-services/"), we at Data EximIT have...

PHP Website Development

Skenix Infotech is a leading PHP Web Development Company that helps companies get results with industry best practices. Get affordable PHP Development Services.

Laravel Development Company

Skenix Infotech is a top Laravel Website Development Company with Expert Laravel Developers that provides robust Laravel Development Services at fair costs.

Hire Dedicated PHP Developer

Looking to hire affordable yet experienced PHP developers? **[Hire Dedicated PHP Developer](https://hourlydeveloper.io/hire-dedicated-php-developer/ "Hire Dedicated PHP Developer")**, who can convert your idea to reality, within the stipulated...

Hire PHP Developer

Looking to develop a PHP based website from scratch or revamp your existing website? **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")** has always been an industry leader for companies and business owners looking to hire...