Integrate Payment Gateway - RazorPay with Laravel

A guide on integrating RazorPay in Laravel Application

Author

Aanchal Goyal
Aanchal GoyalSenior Software Engineer - II

Date

Nov 18, 2022

Table of Contents

Introduction

In this tutorial, you will learn how to integrate RazorPay in your Laravel 8 application. Read on to know the essential steps for the integration.

Steps to Integrate RazorPay with Laravel

Let’s get started. Follow the steps below, and you are good to go!

Step 1 - Install the Laravel 8 Application

Go to the directory you want to install your project in the terminal and run the below command to install new Laravel project 

Step 2 - Connect Database to an Application

In this step, open your project folder in vs. code and open .env and add your database name, user, and password like this.

Step 3 - Add RazorPay Credentials

If you already have Razorpay account, login into the Razorpay dashboard or create a new Razorpay account. Then go to settings from the left sidebar, and you will see the API KEYS tab.

Open that tab and generate a new key. Copy those keys, and paste them into your .env

Screenshot 2022-04-14 at 5.32.25 PM.jpg

Step 4 - Install the Composer Package of RazorPay

Now, could you install the composer package of Razorpay? To install that, get the root directory of your project in the terminal and run the below command.

Step 5 - Create Route

Open web.php and create a new route. 

Step 6 - Create Migration and Model

Now, you need to create migration for new table payments to store the response of razorpay API. Also, create a model Payment for the same. Run this below command 

Copy this code in the migration file and run php artisan migrate

Step 7 - Create Controller

Now, create a controller using this command and write the below code. In the controller, we will write the logic for Razorpay API call and store the response in our database.

Step 8 - Create View File

Create Laravel blade file and add the below code in that file and call that file with the help of the view function from the controller. 

Now run this below command and open this URL http://127.0.0.1:8000/product

Conclusion

This was a tutorial on integrating Razorpay into your Laravel 8 application. You can try it out and let us know how it went!

SHARE ON

Related Articles.

More from the engineering frontline.

Dive deep into our research and insights on design, development, and the impact of various trends to businesses.

From RFPs to Revenue: How We Built an AI Agent Team That Writes Technical Proposals in 60 Seconds
Article

Apr 9, 2026

From RFPs to Revenue: How We Built an AI Agent Team That Writes Technical Proposals in 60 Seconds

GeekyAnts built DealRoom.ai — four AI agents that turn RFPs into accurate technical proposals in 60 seconds, with real-time cost breakdowns and scope maps.

How We Built an AI System That Automates Senior Solution Architect Workflows
Article

Apr 6, 2026

How We Built an AI System That Automates Senior Solution Architect Workflows

Discover how we built a 4-agent AI co-pilot that converts complex RFPs into draft technical proposals in 15 minutes — with built-in conflict detection, assumption surfacing, and confidence scoring.

AI Code Healer for Fixing Broken CI/CD Builds Fast
Article

Apr 6, 2026

AI Code Healer for Fixing Broken CI/CD Builds Fast

A deep dive into how GeekyAnts built an AI-powered Code Healer that analyzes CI/CD failures, summarizes logs, and generates code-level fixes to keep development moving.

A Real-Time AI Fraud Decision Engine Under 50ms
Article

Apr 2, 2026

A Real-Time AI Fraud Decision Engine Under 50ms

A deep dive into how GeekyAnts built a real-time AI fraud detection system that evaluates transactions in milliseconds using a hybrid multi-agent approach.

Building an Autonomous Multi-Agent Fraud Detection System in Under 200ms
Article

Apr 1, 2026

Building an Autonomous Multi-Agent Fraud Detection System in Under 200ms

GeekyAnts built a 5-agent fraud detection pipeline that makes decisions in under 200ms — 15x cheaper than single-model systems, with full explainability built in.

Building a Self-Healing CI/CD System with an AI Agent
Article

Mar 31, 2026

Building a Self-Healing CI/CD System with an AI Agent

When code breaks a pipeline, developers have to stop working and figure out why. This blog shows how an AI agent reads the error, finds the fix, and submits it for review all on its own.

Scroll for more
View all articles