Razorpay Payment Gateway Integration in Codeigniter using cURL

In this tutorial, We have shared how to integrate Razorpay payment gateway in Codeigniter using cURL. Razorpay is the most popular payment gateway in India. Razorpay provides clean, fast, secure payments services with hassle-free integration with developer-friendly APIs. It allows online businesses to accept and process payment modes like Cards, Net-banking, Wallets & UPI. Developer Friendly API, Fast Onboarding, and No Setup. Razorpay payment gateway is the easiest option for the web developer to implement a payment system on the Web Application.
Step 1: Create Razorpay Account
First we need to create account on Razorpay and generate KeyId and Secret Key. We will keep created Razorpay account in test mode to test payment functionality.
Step 2: Update Razorpay Config Details
Here in this example, we will use Test App to integrate Razorpay gateway. So we will update config.php with KeyID and Secret Key from Razorpay.
Step 3: Open a file constants
Open “application/config/constants.php” file and define constants:
Step 4: Create a Controller file Razorpay
Create a model file named “Razorpay.php” inside “application/controllers” folder.
Step 5: Create a view file index
Create a view file named “index.php” inside “application/views/razorpay” folder
Step 6: Create a view file checkout
Create a view file named “checkout.php” inside “application/views/razorpay” folder
Step 7: Open a file routes
Open “application/config/routes.php” file and add code like as bellow:
Domestic
Mastercard Visa
5104_0155_5555_5558, 5104_0600_0000_0008 4111_1111_1111_1111
International
Mastercard Visa
5555_5555_5555_4444, 5105_1051_0510_5100 4012_8888_8888_1881, 4000_1841_8621_8826