paytm A Paytm component for Yii framework

  1. Requirements
  2. Installation
  3. Usage
  4. Resource

Requirements

-The component is build for Yii framework version 1.1 or above
-You will need CURL PHP extension

Installation

Download the latest package from github, extract the component file (Paytm.php) to your components directory and checkout sample controller and view files to test the component. Place the Paytm configuration array inside your 'components' definitions

'paytm' => array(
    'class' => 'application.components.Paytm',
    'api_live' => false,
    'merchant_key' => 'PAYTM_MERCHANT_KEY',
    'merchant_id' => 'PAYTM_MERCHANT_MID',
    'website' => 'PAYTM_MERCHANT_WEBSITE',
    'industry_type_id' => 'PAYTM_INDUSTRY_TYPE_ID',
),

Usage

A sample controller to demonstrate the usage of the component

<?php

class PaytmController extends Controller {

    public function index() {
        $param_list = array();
        // Create an array having all required parameters for creating checksum.
        $param_list['MID'] = Yii::app()->paytm->merchant_id;
        $param_list['INDUSTRY_TYPE_ID'] = Yii::app()->paytm->industry_type_id;
        $param_list['CHANNEL_ID'] = Yii::app()->paytm->channel_id;
        $param_list['WEBSITE'] = Yii::app()->paytm->website;

        $param_list['REQUEST_TYPE'] = 'DEFAULT'; //or SUBSCRIBE

        $param_list['ORDER_ID'] = 'sample12345';
        $param_list['TXN_AMOUNT'] = '199'; //INR

        $param_list['CUST_ID'] = 'CUSTOMER_ID';
        $param_list['MOBILE_NO'] = 'CUSTOMER_PHONE'; //Mobile number of customer
        $param_list['EMAIL'] = 'CUSTOMER_EMAIL'; //Email ID of customer
        //Here checksum string will return by getChecksumFromArray() function.
        $checkSum = Yii::app()->paytm->getChecksumFromArray($param_list);
        $param_list['CHECKSUMHASH'] = $checkSum;

        //paytm processing begin
        $this->renderPartial('paytm', array('param_list' => $param_list));
    }

    /**
     * Paytm resonse handler
     */
    public function actionResponse() {
        //validation
        if ($_POST['STATUS'] == 'TXN_SUCCESS') {

            $param_list = $_POST;
            $paytm_checksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
            //verify checksum
            $isValidChecksum = Yii::app()->paytm->verifychecksum_e($param_list, $paytm_checksum);
            //if checksum matched
            if ($isValidChecksum === true) {
                //mark order as success
                //send success email
                //show thank u page
                $this->redirect(array('paytm/confirm'));
                Yii::app()->end();
            }
        }
        //Transaction status is failure
        $this->redirect(array('paytm/error'));
    }

    public function actionConfirm() {
        $this->render('confirm');
    }

    public function actionError() {
        $this->render('error');
    }

}

Resource

1 0
1 follower
123 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Santosh Singh
Created on: Mar 17, 2016
Last updated: 8 years ago

Downloads

show all

Related Extensions