how to integration rozarpay in codeigniter 3 - deesoft service

how to integration rozarpay in codeigniter 3

Deepak Tailor Image
Deepak Tailor - Feb 05 2023
how to integration rozarpay in codeigniter 3

Here's an example of how you can integrate Razorpay in CodeIgniter 3:

Install the Razorpay PHP library by running this command in your terminal: composer require razorpay/razorpay.

Create a Razorpay account and obtain your API Key ID and API Key Secret.

In your CodeIgniter controller, load the Razorpay library by adding this line at the top of your controller file: use Razorpay\Api\Api;.

In the same controller, create a function for processing payments:

public function process_payment()
    $api = new Api(KEY_ID, KEY_SECRET);

    $order_id = $this->input->post('razorpay_order_id');
    $payment_id = $this->input->post('razorpay_payment_id');
    $signature = $this->input->post('razorpay_signature');

    $attributes = array(
        'razorpay_order_id' => $order_id,
        'razorpay_payment_id' => $payment_id,
        'razorpay_signature' => $signature


    // Payment success, do something here

    echo "Payment Successful";
    catch (Exception $e)
    // Payment failed, do something here

    echo "Payment Failed";

In your view file, create a form for entering payment details:

<form action="<?php echo base_url('payment/process_payment'); ?>" method="post">
    data-key="<?php echo KEY_ID; ?>"
    data-buttontext="Pay with Razorpay"
    data-name="Example Store"
    data-description="Test Transaction"
    data-image="""Harshil Mathur"""
<input type="hidden" name="razorpay_payment_id" id="razorpay_payment_id">
<input type="hidden" name="razorpay_order_id" id="razorpay_order_id">
<input type="hidden" name="razorpay_signature" id="razorpay_signature">

Note: Replace KEY_ID and KEY_SECRET with your own API key and secret.

Create a route in your routes.php file to map the form action to the function in your controller:

$route['payment/process_payment'] = 'PaymentController/process_payment';

Create a controller file named PaymentController.php in the controllers directory and paste the code for the process_payment function into it.

Create a view file named payment.php in the views directory and paste the code for the payment form into it.

Load the view file in the controller by adding the following code to the controller:

public function index()

Finally, run the application and test the payment form.

Deepak Tailor Image
Deepak Tailor

My name is Deepak tailor as a fullstack developer. I have been in the IT industry (PHP, Nodejs, flutter) for the last 5 years. For professional and customize web development & app development, you can send inquiry on our email.
You can contact him at