Codxplore.com

Latest news:

Sahih al-Bukhari (সহীহ বুখারী) is a free Hadith application for android. This application is advertisement free. Download now https://play.google.com/store/apps/details?id=com.akramhossin.bukharisharif

Yii2 ccavenue payment gateway integration.


Yii2 ccavenue payment gateway integration.

In this blog post, i will try to explain how to integrate ccavenue payment gateway in Yii2.

ccavenue  is one of India's leading digital payments and e-commerce solutions provider. 

They provide extensive suite of web services to extend digital payment solutions. Before getting started with implementation

you need to clone or download my github repository https://github.com/akramrana/yii2-ccavenue to your desktop and unzip it.

Requirements:

  • LIve working keys shared by ccavenue to check on live server.
  • Demo working keys shared by ccavenue to check on development server.

Installation Steps:

1. Make a folder as components to your project if it does not exist. After this copy the yii2-ccavenue/components/Ccavenue

PHP Class and paste into the recently created components  folder.

2. Now open the yii2-ccavenue/config folder and copy the function.php file and paste this into your project config folder.

3. Include the function.php file into the config/web.php file in your project. To include function.php file use the following code

$functions = require(__DIR__ . '/functions.php');

4. In yii2-ccavenue/SiteController before action method i have removed the csrf validation for payment-process and payment-cancel method,

because this two method will be handle the ccavenue api POST request.

5. subscription method in yii2-ccavenue/SiteController, which will process your payment request and submit the payment request

to the ccvaenue payment gateway. Now look into the actionSubscription, we have following code

$params = [
  'tid' => time(),
  'merchant_id' => 12345,
  'order_id' => 14523,
  'amount' => 2500,
  'currency' => 'INR',
  'redirect_url' => $redirectUrl,
  'cancel_url' => $cancelUrl,
  'language' => 'EN',
];
\app\components\Ccavenue::form($params, 'auto', 'test', 'websites');

Ccavenue form method has following parameters

  • Payment options, such merchant_id, order_id, amount etc,
  • Payment submission mode, which will be auto
  • Payment environment. It has two option test and live
  • Server Name as source of payment request.

for more details check yii2-ccavenue/components/Ccavenue class.

6. Copy yii2-ccavenue/views/subscription.php file into your views

7. Copy the yii2-ccavenue/SiteController actionPaymentProcess and actionPaymentCancel methods with views(yii2-ccavenue/views.*)

8. actionPaymentProcess and actionPaymentCancel in this two method you have to use exact same working key

which you have used before to submit your payment request to ccavenue gateway.

for reference please check yii2-ccavenue/components/Ccavenue Class form method.

Tags : PHP, Yii2,

Views : 871

Subscribe Us


Follow Us