info@ddtechnology.com +91 9511638160
Build Your Website in 1 Day 100% Money-Back Guarantee
Claim Offer
Free Tools Get A Quote
CodeIgniter

Integrating Payment Gateways with CodeIgniter 4: A Complete Guide for Indian E‑Commerce Businesses

Learn how to securely integrate Razorpay, Paytm, and Cashfree payment gateways into CodeIgniter 4 applications. Step‑by‑step tutorial covering setup, API usage, webhook handling, …

DD D&D TechnologyTech Insights Jun 18, 2026 2 min read
Integrating Payment Gateways with CodeIgniter 4: A Complete Guide for Indian E‑Commerce Businesses
Share:

Integrating Payment Gateways with CodeIgniter 4: A Complete Guide for Indian E‑Commerce Businesses

Indian e‑commerce is growing rapidly, and offering a smooth, secure checkout experience is essential for converting visitors into customers. If you are building your store with CodeIgniter 4, integrating popular Indian payment gateways such as Razorpay, Paytm, and Cashfree can be done efficiently while keeping security and SEO best practices in mind.

Why Choose CodeIgniter 4 for Payment Integration?

  • Lightweight MVC framework with excellent performance.
  • Built‑in HTTP client and request/response handling simplifies API calls.
  • Easy routing and controller structure for creating webhook endpoints.
  • Strong community support and extensive documentation.

Before diving into the code, ensure you have the following prerequisites:

  1. PHP 7.4+ and Composer installed.
  2. A fresh CodeIgniter 4 project (via composer create-project codeigniter4/appstarter).
  3. API keys for Razorpay, Paytm, and Cashfree (sandbox credentials for testing).
  4. SSL certificate on your domain (required for live transactions).

1. Setting Up Razorpay in CodeIgniter 4

Install Razorpay SDK

composer require razorpay/razorpay

Create a Controller

<?php
namespace App\Controllers;

use Razorpay\Api\Api;

class Payment extends BaseController
{
    public function razorpayCheckout()
    {
        $api = new Api('YOUR_RAZORPAY_KEY_ID', 'YOUR_RAZORPAY_KEY_SECRET');

        $orderData = [
            'receipt'         => 'receipt_' . uniqid(),
            'amount'          => 50000, // amount in paise (₹500)
            'currency'        => 'INR',
            'payment_capture' => 1 // auto capture
        ];

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

        $data = [
            'orderId'    => $razorpayOrder['id'],
            'amount'     => $orderData['amount'],
            'currency'   => $orderData['currency'],
            'keyId'      => 'YOUR_RAZORPAY_KEY_ID',
            'name'       => 'Your Store Name',
            'description'=> 'Purchase description',
            'image'      => base_url('assets/logo.png'),
            'prefill'    => [
                'name'  => 'Customer Name',
                'email' => 'customer@example.com',
                'contact'=> '9999999999'
            ],
            'theme'      => ['color' => '#F37254']
                
Was this article helpful? 4.8 (128 votes)
DD
D&D Technology
We help businesses grow with modern websites, web apps, and digital
solutions powered by the latest technologies.
View All Posts

Join the Conversation

0 Comments
AI

Ready to Add AI in Your Ecommerce Platform?

Launch automation, chatbot, recommendation engine and smart dashboards.

Transparent Process
Clear steps, no hidden charges
Fast Project Kickoff
Start your project immediately
Dedicated Expert Team
Experienced, reliable, innovative
24/7 Support
We're here whenever you need us

Build Your Website in 1 Day

From design to launch — fast turnaround without compromising quality.

Get Started

Launch Your SaaS in 1 Day

Production-ready SaaS platform with auth, payments, and admin — done in 24 hours.

See SaaS Products

100% Money-Back Guarantee

Not satisfied? Get a full refund — no questions asked. Your trust is our priority.

Talk to Us
Flexible Start Plans

Start Your Project with a Small First Step

Pay the essential setup cost or your first EMI, and our team starts building right away.

WEBSITE LAUNCH

Pay Your Domain +
1 Month EMI

Secure your domain, pay your first EMI, and we begin your website design and development immediately.

Domain Setup 1st EMI Website Work Starts
Start Website Project
Perfect for business websites, portfolios & eCommerce
APP LAUNCH

Pay Play Store Fee +
1 Month EMI

Cover your Play Store setup and first EMI, and we start your Android/iOS app design and development.

Play Store Setup 1st EMI App Work Starts
Start App Project
Ideal for startup apps, booking apps & business apps
SOFTWARE LAUNCH

Pay 1 Month EMI &
Start Your Software

Begin your custom software journey with the first EMI and our team starts planning, UI/UX, and development.

1st EMI Project Kickoff Software Development
Start Software Project
Best for ERP, CRM, HRMS, SaaS & custom systems
Transparent EMI ProcessClear pricing, no hidden charges.
Fast Project KickoffStart within 24–48 hours.
Dedicated Expert TeamExperienced, reliable & responsive.