Razorpay Payment Gateway Integration PHP

In his example I have explain how to develop Razorpay Payment Gateway Integration PHP & MySQL. Current days most e-commerce sites are using Razorpay because it has lot of features when compared to Instamojo, PayU, Stripe etc. Commission rate also very low, this is also one of the major reason for why most of developers are like to use Razorpay. The payment user interface also fine and looks like very attractive. Peoples are like to see the material design with user friendly navigation.

Here we are using Core PHP and in future may be work with Laravel Framework. Most of software companies are using PHP frameworks to develop large scale projects like shopping sites, food delivery app and more. Already in our blog we are posting PayU, Instamojo Gateway Integration. So once check and if it’s fine then go for easiest results. But Razorpay integration little bit hard to setup the code, however you can do this because well documentation.

razorpay payment gateway integration
credits – Razorpay

Before starting any project once read the official documentation, so here read Razorpay official steps for integrate into your websites. Documentations are clearly explained in every server side programming languages like PHP, Java, Python, Node etc. The full steps are explained in the upcoming section or move with official documentation.

Create Account – Razorpay

Initial Step is create new account on Razorpay after that Login on your own Dashboard and generate the API Keys to access the data into our web application. And now starts to integrate the code using PHP programming language. For that you have to follow 7 steps then only successfully conntected & make payments via Razorpay payment integration gateway.

  1. Download Razorpay PHP SDK via Composer
  2. Add SDK into your current project
  3. Create & Add products on the particular site.
  4. Checkout
  5. Communicate with Server Side & then accept the payment
  6. Verify Payment details like card information, debit & credit card, UPI payments, PayPal, Net Banking etc.
  7. Finally check the Payment Status whether it’s fail or pass.

Actually these steps are very easy however read this link to get more depth idea about integration procedures. This is the link, once check if you have no idea then just leave and focus on other work categories.

//API DEMO CODE
$orderData = [
    'receipt'         => 'rcptid_11',
    'amount'          => 39900, // 39900 rupees in paise
    'currency'        => 'INR'
];

$razorpayOrder = $api->order->create($orderData);

Moreover payment button, how configure the payments details, Handle Payment Success & Failure Status. And then finally verify and accept the payments from your end.

Integration Steps – Razorpay Payment Gateway

  1. Web Integration
  2. Android Apps Integration
  3. iOS Integration Steps
  4. Ecommerce Plugin
  5. React Native

In this example we are going to use Web Integration steps to gain more knowledge and easy to develop the online payment portal to accept and receive payments. After build the integration you have to test the payment gateway and the sample apps also given by official websites. Set up web hooks for the live mode configuration.

razorpay integration php

Success Payment Code – Razorpay Payment Gateway Integration

When you have successfully complete the payments, it’s redirected to your website. After that you can check the payment status about transaction id etc. The sample code explained in below section,

"handler": function (response){
    alert(response.razorpay_payment_id);
    alert(response.razorpay_order_id);
    alert(response.razorpay_signature)}

Source Code

I hope above all code and explanations are helps to build he payment gateway service for your web application. Actually the steps for easy so for more clarification once read the official documentation to know more information. Because here i explain only major things. If any doubts during integration just contact us for solve the issues.

Leave a Reply