Plugin Directory

Changeset 2093489


Ignore:
Timestamp:
05/23/2019 06:05:19 AM (7 years ago)
Author:
mariaaspen
Message:

Update With Latest Wordpress

Location:
woo-paytm-payment-gateway/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • woo-paytm-payment-gateway/trunk/include/function.php

    r2053803 r2093489  
    11<?php
    2 
    3 function wppg_encrypt($input, $ky)
    4 {
     2function wppg_encrypt($input, $ky){
    53    $key   = html_entity_decode($ky);
    64    $iv = "@@@@&&&&####$$$$";
     
    97}
    108
    11 function wppg_decrypt($crypt, $ky)
    12 {
     9function wppg_decrypt($crypt, $ky){
    1310    $key   = html_entity_decode($ky);
    1411    $iv = "@@@@&&&&####$$$$";
     
    1714}
    1815
    19 function wppg_pkcs5_pad($text, $blocksize)
    20 {
    21     $pad = $blocksize - (strlen($text) % $blocksize);
    22     return $text . str_repeat(chr($pad), $pad);
    23 }
    24 
    25 function wppg_pkcs5_unpad($text)
    26 {
    27     $pad = ord($text{strlen($text) - 1});
    28     if ($pad > strlen($text))
    29         return false;
    30     return substr($text, 0, -1 * $pad);
    31 }
    32 
    33 function wppg_generateRandString($length)
    34 {
     16function wppg_generateRandString($length){
    3517    $random = "";
    3618    srand((double) microtime() * 1000000);
     
    4729}
    4830
    49 function wppg_checkString($value)
    50 {
     31function wppg_checkString($value){
    5132    $myvalue = ltrim($value);
    5233    $myvalue = rtrim($myvalue);
     
    5637}
    5738
    58 function wppg_getChecksumFromArray($arrayList, $key, $sort = 1)
    59 {
    60     if ($sort != 0) {
     39function wppg_getChecksumFromArray($arrayList, $key, $sort = 1){
     40    if($sort != 0){
    6141        ksort($arrayList);
    6242    }
     
    7050}
    7151
    72 function wppg_verifychecksum($arrayList, $key, $checksumvalue)
    73 {
     52function wppg_verifychecksum($arrayList, $key, $checksumvalue){
    7453    $arrayList = wppg_removeCheckSumParam($arrayList);
    7554    ksort($arrayList);
     
    8463   
    8564    $validFlag = "FALSE";
    86     if ($website_hash == $paytm_hash) {
     65    if($website_hash == $paytm_hash){
    8766        $validFlag = "TRUE";
    8867    } else {
     
    9271}
    9372
    94 function wppg_getArraytoStr($arrayList) {
     73function wppg_getArraytoStr($arrayList){
    9574    $findme   = 'REFUND';
    9675    $findmepipe = '|';
    9776    $paramStr = "";
    9877    $flag = 1; 
    99     foreach ($arrayList as $key => $value) {
     78    foreach($arrayList as $key => $value){
    10079        $pos = strpos($value, $findme);
    10180        $pospipe = strpos($value, $findmepipe);
    102         if ($pos !== false || $pospipe !== false)
    103         {
     81        if($pos !== false || $pospipe !== false){
    10482            continue;
    10583        }
    10684       
    107         if ($flag) {
     85        if($flag){
    10886            $paramStr .= wppg_checkString($value);
    10987            $flag = 0;
     
    11593}
    11694
    117 function wppg_getArraytoStrForVerify($arrayList) {
     95function wppg_getArraytoStrForVerify($arrayList){
    11896    $paramStr = "";
    11997    $flag = 1;
    120     foreach ($arrayList as $key => $value) {
    121         if ($flag) {
     98    foreach($arrayList as $key => $value){
     99        if($flag){
    122100            $paramStr .= wppg_checkString($value);
    123101            $flag = 0;
     
    129107}
    130108
    131 function wppg_redirect2PG($paramList, $key)
    132 {
    133     $hashString = wppg_getChecksumFromArray($paramList);
    134     $checksum   = wppg_encrypt($hashString, $key);
    135 }
    136 
    137 function wppg_removeCheckSumParam($arrayList)
    138 {
    139     if (isset($arrayList["CHECKSUMHASH"])) {
     109function wppg_removeCheckSumParam($arrayList){
     110    if(isset($arrayList["CHECKSUMHASH"])){
    140111        unset($arrayList["CHECKSUMHASH"]);
    141112    }
     
    143114}
    144115
    145 function wppg_getTxnStatus($requestParamList)
    146 {
    147     return get_paytm_response_url(PAYTM_STATUS_QUERY_URL, $requestParamList);
    148 }
    149 
    150 function wppg_initiateTxnRefund($requestParamList)
    151 {
    152     $CHECKSUM                     = wppg_getChecksumFromArray($requestParamList, PAYTM_MERCHANT_KEY, 0);
    153     $requestParamList["CHECKSUM"] = $CHECKSUM;
    154     return get_paytm_response_url(PAYTM_REFUND_URL, $requestParamList);
    155 }
    156 
    157 function get_paytm_response_url($apiURL, $requestParamList)
    158 {
     116function wppg_get_paytm_response_url($apiURL, $requestParamList){
    159117    $jsonResponse      = "";
    160118    $responseParamList = array();
     
    165123    return $responseParamList;
    166124}
    167 
    168 function wppg_ChecksumParamPattern($param)
    169 {
    170     $pattern[0]     = "%,%";
    171     $pattern[1]     = "%#%";
    172     $pattern[2]     = "%\(%";
    173     $pattern[3]     = "%\)%";
    174     $pattern[4]     = "%\{%";
    175     $pattern[5]     = "%\}%";
    176     $pattern[6]     = "%<%";
    177     $pattern[7]     = "%>%";
    178     $pattern[8]     = "%`%";
    179     $pattern[9]     = "%!%";
    180     $pattern[10]    = "%\\$%";
    181     $pattern[11]    = "%\%%";
    182     $pattern[12]    = "%\^%";
    183     $pattern[13]    = "%=%";
    184     $pattern[14]    = "%\+%";
    185     $pattern[15]    = "%\|%";
    186     $pattern[16]    = "%\\\%";
    187     $pattern[17]    = "%:%";
    188     $pattern[18]    = "%'%";
    189     $pattern[19]    = "%\"%";
    190     $pattern[20]    = "%;%";
    191     $pattern[21]    = "%~%";
    192     $pattern[22]    = "%\[%";
    193     $pattern[23]    = "%\]%";
    194     $pattern[24]    = "%\*%";
    195     $pattern[25]    = "%&%";
    196     $ChecksumParamPattern = preg_replace($pattern, "", $param);
    197     return $ChecksumParamPattern;
    198 }
  • woo-paytm-payment-gateway/trunk/readme.txt

    r2053802 r2093489  
    33Tags: WooCommerce Paytm Pay, WooCommerce Paytm, Pay with Paytm on WooCommerce, Paytm Payment Gateway, Paytm, Paytm plugin for WooCommerce, Paytm integration with WooCommerce, paytm plugin for wordpress
    44Requires at least: 4.9
    5 Tested up to: 4.9.1
    6 Stable tag: 1.1.1
     5Tested up to: 5.2
     6Stable tag: 1.1.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4747Update Latest Paytm API.
    4848
    49  = 1.1.1 =
     49 = 1.1.2 =
    5050Compatible with PHP 7.0
     51
  • woo-paytm-payment-gateway/trunk/wc-paytm.php

    r2053802 r2093489  
    22/*
    33Plugin Name: WooCommerce Paytm Payment Gateway 
    4 Version: 1.1.1
    5 Description: This plugin using visitors to pay via Paytm.
     4Version: 1.1.2
     5Description: This plugin is used to integrate Paytm payment gateway with Woocommerce.
    66Author: FTI Technologies
    77Author URI: https://www.freelancetoindia.com/
    88*/
    99
    10 define( 'PAYTM_PLUGIN_PATH',plugin_dir_path( __FILE__ ));
     10define( 'PAYTM_PLUGIN_PATH', plugin_dir_path( __FILE__ ));
    1111require_once(PAYTM_PLUGIN_PATH . 'include/function.php');
    1212add_action('plugins_loaded', 'WC_paytmpay_init');
    1313
    14 function WC_paytmpay_init() {
     14function WC_paytmpay_init(){
    1515
    1616    if ( !class_exists( 'WC_Payment_Gateway' ) ) return;
     
    2121   
    2222    function PaytmPayShowMsg($content){
    23             return '<div class="box '.htmlentities($_GET['type']).'-box">'.htmlentities(urldecode($_GET['msg'])).'</div>'.$content;
     23        return '<div class="box '.htmlentities($_GET['type']).'-box">'.htmlentities(urldecode($_GET['msg'])).'</div>'.$content;
    2424    }
    2525    /**
     
    2828    class WC_Gateway_paytmpay extends WC_Payment_Gateway {
    2929       
    30     protected $msg = array();
    31        
    32         /**
    33     * Constructor for the gateway.
    34     */
     30        protected $msg = array();
     31           
     32        /**
     33        * Constructor for the gateway.
     34        */
     35
    3536        public function __construct(){
    36            
    37             $this -> id = 'paytmpay';
    38             $this -> has_fields = false;
    39             $this -> order_button_text  = __('Pay via paytm', 'woocommerce' );
    40             $this -> method_title = __('Pay With Paytm');
    41             $this -> method_description = __('Your Payment pay with paytm.');
    42             $this -> icon = WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/images/logo.gif';
    43             $this -> init_form_fields();
    44             $this -> init_settings();
    45             $this -> title = $this -> settings['title'];
    46             $this -> description = $this -> settings['description'];
    47             $this -> merchantID = $this -> settings['merchantID'];
    48             $this -> merchant_key = $this -> settings['merchant_key'];           
    49             $this -> industry_type_id = $this -> settings['industry_type_id'];
    50             $this -> paytm_channel_id = $this -> settings['paytm_channel_id'];
    51             $this -> website = $this -> settings['website'];
    52             $this -> mode = $this -> settings['mode'];
    53             $this -> callbackurl = $this -> settings['callbackurl'];
    54             $this -> log = $this -> settings['log'];
    55             $this -> msg['message'] = "";
    56             $this -> msg['class'] = "";
     37            $this->id = 'paytmpay';
     38            $this->has_fields = false;
     39            $this->order_button_text  = __('Pay via paytm', 'woocommerce' );
     40            $this->method_title = __('Pay With Paytm');
     41            $this->method_description = __('Your Payment pay with paytm.');
     42            $this->icon = WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/images/logo.gif';
     43            $this->init_form_fields();
     44            $this->init_settings();
     45            $this->title = $this->settings['title'];
     46            $this->description = $this->settings['description'];
     47            $this->merchantID = $this->settings['merchantID'];
     48            $this->merchant_key = $this->settings['merchant_key'];           
     49            $this->industry_type_id = $this->settings['industry_type_id'];
     50            $this->paytm_channel_id = $this->settings['paytm_channel_id'];
     51            $this->website = $this->settings['website'];
     52            $this->mode = $this->settings['mode'];
     53           
     54            $this->msg['message'] = "";
     55            $this->msg['class'] = "";   
    5756           
    58             add_action('init', array(&$this, 'capture_paytm_response'));
    59            
    6057            add_action('woocommerce_api_' . strtolower( get_class( $this ) ), array( $this, 'capture_paytm_response' ) );
    6158            add_action('woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) );
    6259            add_action('woocommerce_receipt_' . $this->id, array(&$this, 'receipt_page'));
    63          
    64         }
    65        
    66 
    67     function init_form_fields(){   
    68             $this -> form_fields = array(
     60        }
     61       
     62
     63        function init_form_fields(){   
     64            $this->form_fields = array(
    6965                'enabled' => array(
    7066                    'title' => __('Enable/Disable'),
    7167                    'type' => 'checkbox',
    7268                    'label' => __('Enable Paytm Payment Gateway.'),
    73                     'default' => 'no'),
    74                
     69                    'default' => 'no'
     70                ),
    7571                'title' => array(
    76                     'title' => __('Title:'),
     72                    'title' => __('Title'),
    7773                    'type'=> 'text',
    7874                    'description' => __('This controls the title which the user sees during checkout.'),
    79                     'default' => __('pay with paytm')),
    80                
     75                    'default' => __('pay with paytm')
     76                ),
    8177                'description' => array(
    82                     'title' => __('Description:'),
     78                    'title' => __('Description'),
    8379                    'type' => 'textarea',
    8480                    'description' => __('This controls the description which the user sees during checkout.'),
    85                     'default' => __('The best payment gateway provider in India for e-payment through credit card, debit card & netbanking.')),
    86                
     81                    'default' => __('The best payment gateway provider in India for e-payment through credit card, debit card & netbanking.')
     82                ),
    8783                'merchantID' => array(
    8884                    'title' => __('Merchant ID'),
    8985                    'type' => 'text',
    90                     'description' => __('This id(USER ID) available at "Generate Secret Key" of "Integration -> Card payments integration at paytm."')),
    91                
     86                    'description' => __('This id(USER ID) available at "Generate Secret Key" of "Integration -> Card payments integration at paytm."')
     87                ),
    9288                'merchant_key' => array(
    9389                    'title' => __('Merchant Key'),
    9490                    'type' => 'text',
    95                     'description' =>  __('Given to Merchant by paytm')),
    96                
     91                    'description' =>  __('Given to Merchant by paytm')
     92                ),
    9793                'industry_type_id' => array(
    9894                    'title' => __('Industry Type ID'),
    9995                    'type' => 'text',
    100                     'description' =>  __('Given to Merchant by paytm')),
    101                
     96                    'description' =>  __('Given to Merchant by paytm')
     97                ),
    10298                'paytm_channel_id' => array(
    10399                    'title' => __('Channel ID'),
    104100                    'type' => 'text',
    105                     'description' =>  __('WEB - for desktop websites / WAP - for mobile websites')),
    106                
     101                    'description' =>  __('WEB - for desktop websites / WAP - for mobile websites')),               
    107102                'website' => array(
    108103                    'title' => __('Website'),
    109104                    'type' => 'text',
    110105                    'description' =>  __('Given to Merchant by paytm'),
    111                     ),
    112                    
    113                 'callbackurl' => array(
    114                         'title' => __('Set CallBack URL'),
    115                         'type' => 'select',
    116                         'options'  => array('yes'=>'yes','no'=>'no'),
    117                         'label' => __('Select to enable Sandbox Enviroment'),
    118                         'description' => "Unchecked means in Production Enviroment",
    119                         'default' => 'yes'                   
    120                 ),
    121                
     106                ),
    122107                'mode' => array(
    123                         'title' => __('Enable Test Mode'),
    124                         'type' => 'select',
    125                         'options'  => array('yes'=>'yes','no'=>'no'),
    126                         'label' => __('Select to enable Sandbox Enviroment'),
    127                         'description' => "Unchecked means in Production Enviroment",
    128                         'default' => 'yes'                   
    129                 ),
    130                
    131                 'log' => array(
    132                         'title' => __('Do you want to log'),
    133                         'type' => 'checkbox',
    134                         'label' => __('Select to enable Log'),
    135                         'default' => "no"
     108                    'title' => __('Enable Test Mode'),
     109                    'type' => 'select',
     110                    'options'  => array('yes'=>'yes','no'=>'no'),
     111                    'label' => __('Select to enable Sandbox Enviroment'),
     112                    'default' => 'yes'                   
    136113                )
    137114            );
    138 
    139 
    140115        }
    141116       
     
    146121            $description = $this->get_description();
    147122            if ( $description ) {
    148             echo wpautop( wptexturize( trim( $description ) ) );
     123                echo wpautop( wptexturize( trim( $description ) ) );
    149124            }
    150125        }
    151126       
    152     /**
     127        /**
    153128         * Admin Panel Options
    154129         * - Options for bits like 'title' and availability on a country-by-country basis
     
    158133            echo '<p>'.__('India online payment solutions for all your transactions by paytm').'</p>';
    159134            echo '<table class="form-table">';
    160             $this -> generate_settings_html();
     135                $this->generate_settings_html();
    161136            echo '</table>';
    162 
    163         }
    164        
    165         /**
    166      * Return the gateway's description.
    167      *
    168      * @return string
    169      */
    170     public function get_description() {
    171         return apply_filters( 'woocommerce_gateway_description', $this->description, $this->id );
    172     }
     137        }
     138       
     139        /**
     140         * Return the gateway's description.
     141         *
     142         * @return string
     143         */
     144        public function get_description(){
     145            return apply_filters( 'woocommerce_gateway_description', $this->description, $this->id );
     146        }
    173147       
    174148       
     
    177151         **/
    178152        function receipt_page($order){
    179             echo '<p>'.__('Thank you for your order, please click the button below to pay with paytm.').'</p>';
    180             echo $this -> generate_paytm_form($order);
     153            echo '<p><h4 style="text-align: center;">'.__('We’re processing your order. It may take more few seconds!<br />Please do not refresh or close this session.').'</h4></p>';
     154            echo $this->generate_paytm_form($order);
    181155        }
    182156       
     
    187161            if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) {
    188162                $order = new WC_Order($order_id);
    189              } else {
     163            } else {
    190164                $order = new woocommerce_order($order_id);
    191165            }
     
    195169        }
    196170       
    197     /**
     171        /**
    198172         * Check for valid paytm server callback // response processing //
    199173        **/
    200174        function capture_paytm_response(){ 
    201             global $woocommerce;           
     175            global $woocommerce;       
     176            //echo '<pre>'; print_r($_POST); die('WooCommerce');   
    202177            if(isset($_POST['ORDERID']) && isset($_POST['RESPCODE'])){
    203178                $order_sent = sanitize_text_field($_POST['ORDERID']);
     
    209184                }
    210185               
    211                
    212                 if($this -> log == "yes")
    213                 {
    214                         error_log("Response Code = " . sanitize_text_field($_POST['RESPCODE']));
    215                 }
    216 
    217                 $redirect_url = $order->get_checkout_order_received_url();
    218                 $this -> msg['class'] = 'error';
    219                 $this -> msg['message'] = "Thank you for shopping with us. However, the transaction has been Failed For Reason  : " . $responseDescription;
    220                 if($_POST['RESPCODE'] == 01) {
     186                $this->msg['class'] = 'error';
     187                $this->msg['message'] = "Transaction has been Failed For Reason  : " . $responseDescription;
     188                if($_POST['RESPCODE'] == 01){
    221189                   
    222190                    $order_amount = $order->get_total();
    223191                   
    224                     if((sanitize_text_field($_POST['TXNAMOUNT'])    == $order_amount)){
    225                         if($this -> log == "yes"){error_log("amount matched");}
    226                        
     192                    if((sanitize_text_field($_POST['TXNAMOUNT']) == $order_amount)){
    227193                        $order_sent               = sanitize_text_field($_POST['ORDERID']);
    228194                        $res_code                 = sanitize_text_field($_POST['RESPCODE']);
    229195                        $responseDescription      = sanitize_text_field($_POST['RESPMSG']);
    230                         $order_amount = sanitize_text_field($_POST['TXNAMOUNT']);
     196                        $order_amount             = sanitize_text_field($_POST['TXNAMOUNT']);
    231197                       
    232                         if(wppg_verifychecksum($_POST,$this -> merchant_key,sanitize_text_field($_POST['CHECKSUMHASH'])) === "TRUE"){
     198                        if(wppg_verifychecksum($_POST, $this->merchant_key, sanitize_text_field($_POST['CHECKSUMHASH'])) === "TRUE"){
    233199                           
    234                             $requestParamList = array("MID" => $this -> merchantID , "ORDERID" => $order_sent);
    235                            
     200                            $requestParamList = array("MID" => $this->merchantID , "ORDERID" => $order_sent);
    236201                            $StatusCheckSum = wppg_getChecksumFromArray($requestParamList, $this->merchant_key);
    237                            
    238202                            $requestParamList['CHECKSUMHASH'] = $StatusCheckSum;
    239203                           
    240                             if($this -> mode=='yes')
    241                             {
     204                            if($this->mode=='yes'){
    242205                                $check_status_url = 'https://securegw-stage.paytm.in/merchant-status/getTxnStatus';
    243 
    244                             }
    245                             else
    246                             {
     206                            } else {
    247207                                $check_status_url = 'https://securegw.paytm.in/merchant-status/getTxnStatus';
    248208                            }
    249                             $responseParamList = get_paytm_response_url($check_status_url, $requestParamList);
     209
     210                            $responseParamList = wppg_get_paytm_response_url($check_status_url, $requestParamList);
    250211                                                       
    251                             if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT']==$order_amount)
     212                            if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT'] == $order_amount)
    252213                            {
    253                            
    254214                                if ( $order->has_status( 'pending' ) )
    255215                                {
    256                                     $this -> msg['message'] = "Thank you for your order . Your transaction has been successful.";
    257                                     $this -> msg['class'] = 'success';
     216                                    $this->msg['message'] = "Thank you for your order. Your transaction has been successful.";
     217                                    $this->msg['class'] = 'success';
    258218                                   
    259                                     if($order->has_status( 'processing' )){
    260 
    261                                     } else {
    262                                         $order -> payment_complete();
    263                                         $order -> add_order_note('Mobile Wallet payment successful');
    264                                         $order -> add_order_note($this->msg['message']);
    265                                         $woocommerce -> cart -> empty_cart();
    266 
    267                                     }
     219                                    $order->payment_complete();
     220                                    $order->update_status('completed');
     221                                    $order->add_order_note($this->msg['message']);
     222                                    $woocommerce->cart->empty_cart();
    268223                                }
     224                            } else {
     225                                $this->msg['class'] = 'error';
     226                                $this->msg['message'] = "It seems some issue in server to server communication. Kindly connect with administrator.";
     227                                $order->update_status('failed');
     228                                $order->add_order_note($this->msg['message']);
    269229                            }
    270                             else
    271                             {
    272                                 $this -> msg['class'] = 'error';
    273                                 $this -> msg['message'] = "It seems some issue in server to server communication. Kindly connect with administrator.";
    274                                 $order -> update_status('failed');
    275                                 $order -> add_order_note('Failed');
    276                                 $order -> add_order_note($this->msg['message']);
    277                             }                       
     230                        } else {
     231                            $this->msg['class'] = 'error';
     232                            $this->msg['message'] = "Severe Error Occur.";
     233                            $order->update_status('failed');
     234                            $order->add_order_note($this->msg['message']);
    278235                        }
    279                         else{
    280                             $this -> msg['class'] = 'error';
    281                             $this -> msg['message'] = "Severe Error Occur.";
    282                             $order -> update_status('failed');
    283                             $order -> add_order_note('Failed');
    284                             $order -> add_order_note($this->msg['message']);
    285                         }
    286                        
     236                    } else {
     237                        $this->msg['class'] = 'error';
     238                        $this->msg['message'] = "Order Mismatch Occur.";
     239                        $order->update_status('failed');
     240                        $order->add_order_note($this->msg['message']);
    287241                    }
    288                     else{
    289                            
    290                         $this -> msg['class'] = 'error';
    291                         $this -> msg['message'] = "Order Mismatch Occur";
    292                         $order -> update_status('failed');
    293                         $order -> add_order_note('Failed');
    294                         $order -> add_order_note($this->msg['message']);
    295                        
    296                     }                   
     242                } else {
     243                    $order->update_status('failed');
     244                    $order->add_order_note('Failed');
     245                    $order->add_order_note($this->msg['message']);
    297246                }
    298                 else{
    299                     $order -> update_status('failed');
    300                     $order -> add_order_note('Failed');
    301                     $order -> add_order_note($responseDescription);
    302                     $order -> add_order_note($this->msg['message']);
    303247               
    304                 }
    305                 add_action('the_content', array(&$this, 'PaytmPayShowMsg'));
     248                add_action('the_content', array(&$this, 'PaytmPayShowMsg'));
    306249               
    307        
    308250                $redirect_url = $order->get_checkout_order_received_url();
    309                
    310                 $redirect_url = add_query_arg( array('msg'=> urlencode($this -> msg['message']), 'type'=>$this -> msg['class']), $redirect_url );
    311 
     251                $redirect_url = add_query_arg( array('msg' => urlencode($this->msg['message']), 'type' => $this->msg['class']), $redirect_url );
    312252                wp_redirect( $redirect_url );
    313253                exit;       
     
    321261        public function generate_paytm_form($order_id){
    322262            global $woocommerce;
    323             $txnDate=date('Y-m-d');         
     263            $txnDate = date('Y-m-d');           
    324264            $milliseconds = (int) (1000 * (strtotime(date('Y-m-d'))));
    325265
    326266            if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) {
    327267                $order = new WC_Order($order_id);
    328              } else {
     268            } else {
    329269                $order = new woocommerce_order($order_id);
    330270            }
     
    333273           
    334274            $a = strstr($redirect_url,"?");
    335             if($a){ $redirect_url .= "&wc-api=WC_Gateway_paytmpay";}
    336             else {$redirect_url .= "?wc-api=WC_Gateway_paytmpay";}         
    337             error_log("redirect url = this {$redirect_url}");
     275            if($a){
     276                $redirect_url .= "&wc-api=WC_Gateway_paytmpay";
     277            } else {
     278                $redirect_url .= "?wc-api=WC_Gateway_paytmpay";
     279            }
     280           
    338281            //////////////
    339282            $order_id = $order->get_id();
    340283            $Order_Total =  $order->get_total();
    341             $txntype='1';
    342             $ptmoption='1';
    343             $currency =  get_woocommerce_currency();
    344             $purpose="1";
    345             $productDescription='paytmpay';
    346            
    347            
    348             $ip=$_SERVER['REMOTE_ADDR'];
    349 
     284           
    350285            $email = $order->get_billing_email();
    351286            $mobile_no = $order->get_billing_phone();
    352287
    353288            $post_params = Array(
    354                 "MID" => $this -> merchantID,
     289                "MID" => $this->merchantID,
    355290                "ORDER_ID" => $order_id,
    356291                "CUST_ID" => $email,
     
    361296                "EMAIL" => $email,
    362297                "MOBILE_NO" => $mobile_no
    363                 );
    364             if($this -> callbackurl=='yes')
    365             {
    366                     $post_params["CALLBACK_URL"] = get_site_url() . '/?page_id=7&wc-api=WC_Gateway_paytmpay';
    367             }
    368             $all = '';
    369             foreach($post_params as $name => $value) {
    370                 if($name != 'checksum') {
    371                 $all .= "'";
    372                 if ($name == 'returnUrl') {
    373                 $all .= $value;
    374                 } else {
    375 
    376                 $all .= $value;
    377                 }
    378                 $all .= "'";
    379                 }
    380             }
    381             if($this->log == "yes")
    382             {           
    383                     error_log("AllParams : ".$all);
    384                     error_log("Secret Key : ".$this->merchant_key);
    385             }
    386 
     298            );
     299           
     300            $post_params["CALLBACK_URL"] = get_site_url() . '/?page_id=7&wc-api=WC_Gateway_paytmpay';
     301           
    387302            $checksum = wppg_getChecksumFromArray($post_params, $this->merchant_key);
    388303           
    389             $paytm_args = array(
    390                 'merchantID' => $this->merchantID,
    391                 'orderId' => $order_id,
    392                 'returnUrl' => $redirect_url,
    393                 'buyerEmail' => $order->get_billing_email(),
    394                 'buyerFirstName' => $order->get_billing_first_name(),
    395                 'buyerLastName' => $order->get_billing_last_name(),
    396                 'buyerAddress' => $order->get_billing_address_1(),
    397                 'buyerCity' => $order->get_billing_city(),
    398                 'buyerState' => $order->get_billing_state(),
    399                 'buyerCountry' => $order->get_billing_country(),
    400                 'buyerPincode' => $order->get_billing_postcode(),
    401                 'buyerPhoneNumber' => $order->get_billing_phone(),
    402                 'txnType' => $txntype,
    403                 'ptmoption' => $ptmoption,
    404                 'mode' => $this->mode,
    405                 'currency' => $currency,
    406                 'amount' => $Order_Total,
    407                 'merchantIpAddress' => $ip,
    408                 'purpose' => $purpose,
    409                 'productDescription' => $productDescription,
    410                 'txnDate' =>  $txnDate,
    411                 'checksum' => $checksum
    412                 );
    413                 foreach($paytm_args as $name => $value) {
    414                     if($name != 'checksum') {
    415                         if ($name == 'returnUrl') {
    416                             $value = $value;
    417 
    418                         } else {
    419                         $value = $value;
    420 
    421                         }
    422                     }
    423         }
    424 
    425            
    426            
    427304            $paytm_args_array = array();
    428 
    429             $paytm_args_array[] = "<input type='hidden' name='MID' value='".  $this -> merchantID ."'/>";
     305            $paytm_args_array[] = "<input type='hidden' name='MID' value='".  $this->merchantID ."'/>";
    430306            $paytm_args_array[] = "<input type='hidden' name='ORDER_ID' value='". $order_id ."'/>";
    431             $paytm_args_array[] = "<input type='hidden' name='WEBSITE' value='". $this -> website ."'/>";
    432             $paytm_args_array[] = "<input type='hidden' name='INDUSTRY_TYPE_ID' value='". $this -> industry_type_id ."'/>";
    433             $paytm_args_array[] = "<input type='hidden' name='CHANNEL_ID' value='". $this -> paytm_channel_id ."'/>";
     307            $paytm_args_array[] = "<input type='hidden' name='WEBSITE' value='". $this->website ."'/>";
     308            $paytm_args_array[] = "<input type='hidden' name='INDUSTRY_TYPE_ID' value='". $this->industry_type_id ."'/>";
     309            $paytm_args_array[] = "<input type='hidden' name='CHANNEL_ID' value='". $this->paytm_channel_id ."'/>";
    434310            $paytm_args_array[] = "<input type='hidden' name='TXN_AMOUNT' value='". $Order_Total ."'/>";
    435311            $paytm_args_array[] = "<input type='hidden' name='CUST_ID' value='". $email ."'/>";
     
    437313            $paytm_args_array[] = "<input type='hidden' name='MOBILE_NO' value='". $mobile_no ."'/>";
    438314           
    439             if($this -> callbackurl=='yes')
    440                 {
    441                         $call = get_site_url() . '/?page_id=7&wc-api=WC_Gateway_paytmpay';
    442                         $paytm_args_array[] = "<input type='hidden' name='CALLBACK_URL' value='" . $call . "'/>";
    443                 }
    444            
    445                 $paytm_args_array[] = "<input type='hidden' name='txnDate' value='". date('Y-m-d H:i:s') ."'/>";
    446                 $paytm_args_array[] = "<input type='hidden' name='CHECKSUMHASH' value='". $checksum ."'/>";
    447                 if($this -> mode=='yes')
    448                 {
    449                         $action_url = 'https://securegw-stage.paytm.in/theia/processTransaction';
    450                 }
    451                 else
    452                 {
    453                         $action_url = 'https://securegw.paytm.in/theia/processTransaction';
    454                 }
     315            $call = get_site_url() . '/?page_id=7&wc-api=WC_Gateway_paytmpay';
     316            $paytm_args_array[] = "<input type='hidden' name='CALLBACK_URL' value='" . $call . "'/>";
     317               
     318            $paytm_args_array[] = "<input type='hidden' name='txnDate' value='". date('Y-m-d H:i:s') ."'/>";
     319            $paytm_args_array[] = "<input type='hidden' name='CHECKSUMHASH' value='". $checksum ."'/>";
     320           
     321            if($this->mode=='yes'){
     322                $action_url = 'https://securegw-stage.paytm.in/theia/processTransaction';
     323            } else {
     324                $action_url = 'https://securegw.paytm.in/theia/processTransaction';
     325            }
     326
    455327            return '<form action="'.$action_url.'" method="post" id="paytm_payment_form" name="gopaytm">
    456328                ' . implode('', $paytm_args_array) . '
     
    461333            </form>';
    462334        }
    463 
    464335    }
    465336
     
    474345    add_filter('woocommerce_payment_gateways', 'woocommerce_add_paytm_gateway' );
    475346}
    476 
    477347?>
Note: See TracChangeset for help on using the changeset viewer.