Nucleus Web Technologies
  • Office Shoranur Road, Thrissur
  • Email[email protected]
  • Phone +91-8330862370
  • Contact Us
Nucleus Web Technologies
  • Home
  • Services
    • Graphic Design
      • Branding
      • Marketing Collaterals
      • UI/UX Design
    • Web Development
      • Web Development
      • E-Commerce Website
      • Mobile App Development
      • Website design
    • Digital Marketing
      • Search Engine Optimization
      • Google Marketing
      • Social Media Marketing
      • Email Marketing
    • Content Writing
      • Corporate Communication
      • Internal Communications
    • Online Software
      • Custom made online Software
  • Solutions
    • Domain Registration & Hosting
    • Website Design & Development
    • Search engine optimization (seo)
    • E-Commerce websites
  • Articles
    • Articles
    • Portfolio
    • FAQ
  • About Us
    • Profile
    • Business Partners
    • Jobs
  • Products
  • contact

Article Details

  • Home
  • Article
  • Integrating PhonePe as a payment gateway in CodeIgniter 3 involves following steps
Thumb

Integrating PhonePe as a payment gateway in CodeIgniter 3 involves following steps

Integrating PhonePe as a payment gateway in CodeIgniter 3 involves following similar steps as for Instamojo. Here's a guide on how to do it:

Step 1: Install CodeIgniter 3
If you haven't already installed CodeIgniter 3, you can download it from the official website and set up your project.

Step 2: Get PhonePe API Credentials
To integrate PhonePe, you'll need to sign up as a merchant on PhonePe's Business Console (https://business.phonepe.com/merchant) and get your API credentials, including the merchant ID and API key.

Step 3: Create a Controller
Create a controller in CodeIgniter to handle payment requests and responses. For example, you can create a controller named "Payment" using the following command in your terminal:

```bash
php index.php tools/make_controller Payment
```

Step 4: Configure Payment Gateway Settings
In your CodeIgniter project, open the `config.php` file located in `application/config` and set the `base_url` to your project's URL.

Step 5: Create Payment Form
Create a view file where users can fill in payment details and submit the payment request. For example, create a view file named `payment_form.php` in your `application/views` folder.

```php
<!-- application/views/payment_form.php -->
<form method="post" action="<?= base_url('payment/process_payment') ?>">
  <input type="text" name="amount" placeholder="Amount">
  <input type="text" name="name" placeholder="Name">
  <input type="email" name="email" placeholder="Email">
  <button type="submit">Pay Now</button>
</form>
```

Step 6: Process Payment Request
In the `Payment` controller, process the payment request and redirect the user to the PhonePe payment page.

```php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Payment extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
    }

    public function index() {
        $this->load->view('payment_form');
    }

    public function process_payment() {
        $merchant_id = 'YOUR_PHONEPE_MERCHANT_ID';
        $api_key = 'YOUR_PHONEPE_API_KEY';
        $amount = $this->input->post('amount');
        $name = $this->input->post('name');
        $email = $this->input->post('email');

        // Generate payment URL with required parameters
        $payment_url = "https://mercury.phonepe.com/payments/pay/" . $merchant_id . "/" . $amount . "/" . $name . "/" . $email . "?redirect_url=" . base_url('payment/payment_success');

        redirect($payment_url);
    }

    public function payment_success() {
        // Handle successful payment here
        echo 'Payment Successful';
    }
}
```

Remember to replace `'YOUR_PHONEPE_MERCHANT_ID'` and `'YOUR_PHONEPE_API_KEY'` with your actual PhonePe API credentials obtained from your PhonePe Business Console.

Step 7: Handling Payment Response
Create a method in the `Payment` controller to handle successful payment responses. After successful payment, the user will be redirected back to the `payment_success` method, where you can handle the payment completion.

Conclusion

Integrating PhonePe as a payment gateway in CodeIgniter 3 involves setting up a controller to handle payment requests and responses, and creating a payment form where users can enter their payment details. Upon form submission, users will be redirected to the PhonePe payment page for secure payment processing. After successful payment, users will be redirected back to your website, and you can handle the payment completion in the `payment_success` method.

Please note that the integration steps provided above are based on general principles, and the actual implementation may vary based on your specific requirements and the latest updates from PhonePe's API. Always refer to PhonePe's official documentation for the most up-to-date information and guidelines.

  • 22 Jul, 2023

Latest Articles

  • integrate Instamojo payment gateway with CodeIgniter 3
    integrate Instamojo payment gateway with CodeIgniter 3
    22 Jul, 2023
  • Advice on Selecting the Correct Technology Stack for a Web Development Project
    Advice on Selecting the Correct Technology Stack for a Web Development Project
    29 Nov, 2022
  • What makes branding so crucial?
    What makes branding so crucial?
    27 Oct, 2022
  • What sets static websites apart from dynamic ones?
    What sets static websites apart from dynamic ones?
    25 Oct, 2022
  • Which Should You Choose: An In-House Team or Outsourcing?
    Which Should You Choose: An In-House Team or Outsourcing?
    20 Oct, 2022
  • Ideas on Communication for Start-ups
    Ideas on Communication for Start-ups
    17 Oct, 2022
  • Do you prefer a customized or templated website?
    Do you prefer a customized or templated website?
    13 Oct, 2022
  • Is conventional marketing being displaced by digital marketing?
    Is conventional marketing being displaced by digital marketing?
    11 Nov, 2021
  • Tips for Writing SEO Content
    Tips for Writing SEO Content
    11 Nov, 2021
  • Various Kinds of Web Development
    Various Kinds of Web Development
    30 Oct, 2021

Portfolio

  • Inspire Solution
  • Trentrix
  • Griantek
  • CADD Centre Thrissur
  • DreamZone Thrissur
  • Galaxy Educational Services
  • Shalom Institute of Mental Health and Research
  • Travel Designer

By understanding your business, Nucleus Web Technologies create a website design tailored to the needs of your site and allow you to tackle the team. Our people design the right website that fulfils your desire to achieve the right brand identity and identity.

  • Tweet
SiteLock

Recent Posts

  • integrate Instamojo payment gateway with CodeIgniter 3
    Jul 22, 2023
  • Integrating PhonePe as a payment gateway in CodeIgniter 3 involves following steps
    Jul 22, 2023

Quick Links

Home
Graphic Design
Web Development
Digital Marketing
Content Writing
Online Software
Contact

© Copyright © 2006-2026. All Rights Reserved by Nucleus WT

  • Terms & Conditions
  • Privacy Policy
  • Refund Policy
  • Support