Changeset 2093489
- Timestamp:
- 05/23/2019 06:05:19 AM (7 years ago)
- Location:
- woo-paytm-payment-gateway/trunk
- Files:
-
- 3 edited
-
include/function.php (modified) (12 diffs)
-
readme.txt (modified) (2 diffs)
-
wc-paytm.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-paytm-payment-gateway/trunk/include/function.php
r2053803 r2093489 1 1 <?php 2 3 function wppg_encrypt($input, $ky) 4 { 2 function wppg_encrypt($input, $ky){ 5 3 $key = html_entity_decode($ky); 6 4 $iv = "@@@@&&&&####$$$$"; … … 9 7 } 10 8 11 function wppg_decrypt($crypt, $ky) 12 { 9 function wppg_decrypt($crypt, $ky){ 13 10 $key = html_entity_decode($ky); 14 11 $iv = "@@@@&&&&####$$$$"; … … 17 14 } 18 15 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 { 16 function wppg_generateRandString($length){ 35 17 $random = ""; 36 18 srand((double) microtime() * 1000000); … … 47 29 } 48 30 49 function wppg_checkString($value) 50 { 31 function wppg_checkString($value){ 51 32 $myvalue = ltrim($value); 52 33 $myvalue = rtrim($myvalue); … … 56 37 } 57 38 58 function wppg_getChecksumFromArray($arrayList, $key, $sort = 1) 59 { 60 if ($sort != 0) { 39 function wppg_getChecksumFromArray($arrayList, $key, $sort = 1){ 40 if($sort != 0){ 61 41 ksort($arrayList); 62 42 } … … 70 50 } 71 51 72 function wppg_verifychecksum($arrayList, $key, $checksumvalue) 73 { 52 function wppg_verifychecksum($arrayList, $key, $checksumvalue){ 74 53 $arrayList = wppg_removeCheckSumParam($arrayList); 75 54 ksort($arrayList); … … 84 63 85 64 $validFlag = "FALSE"; 86 if ($website_hash == $paytm_hash){65 if($website_hash == $paytm_hash){ 87 66 $validFlag = "TRUE"; 88 67 } else { … … 92 71 } 93 72 94 function wppg_getArraytoStr($arrayList) {73 function wppg_getArraytoStr($arrayList){ 95 74 $findme = 'REFUND'; 96 75 $findmepipe = '|'; 97 76 $paramStr = ""; 98 77 $flag = 1; 99 foreach ($arrayList as $key => $value){78 foreach($arrayList as $key => $value){ 100 79 $pos = strpos($value, $findme); 101 80 $pospipe = strpos($value, $findmepipe); 102 if ($pos !== false || $pospipe !== false) 103 { 81 if($pos !== false || $pospipe !== false){ 104 82 continue; 105 83 } 106 84 107 if ($flag){85 if($flag){ 108 86 $paramStr .= wppg_checkString($value); 109 87 $flag = 0; … … 115 93 } 116 94 117 function wppg_getArraytoStrForVerify($arrayList) {95 function wppg_getArraytoStrForVerify($arrayList){ 118 96 $paramStr = ""; 119 97 $flag = 1; 120 foreach ($arrayList as $key => $value){121 if ($flag){98 foreach($arrayList as $key => $value){ 99 if($flag){ 122 100 $paramStr .= wppg_checkString($value); 123 101 $flag = 0; … … 129 107 } 130 108 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"])) { 109 function wppg_removeCheckSumParam($arrayList){ 110 if(isset($arrayList["CHECKSUMHASH"])){ 140 111 unset($arrayList["CHECKSUMHASH"]); 141 112 } … … 143 114 } 144 115 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 { 116 function wppg_get_paytm_response_url($apiURL, $requestParamList){ 159 117 $jsonResponse = ""; 160 118 $responseParamList = array(); … … 165 123 return $responseParamList; 166 124 } 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 3 3 Tags: 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 4 4 Requires at least: 4.9 5 Tested up to: 4.9.16 Stable tag: 1.1. 15 Tested up to: 5.2 6 Stable tag: 1.1.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 47 47 Update Latest Paytm API. 48 48 49 = 1.1. 1=49 = 1.1.2 = 50 50 Compatible with PHP 7.0 51 -
woo-paytm-payment-gateway/trunk/wc-paytm.php
r2053802 r2093489 2 2 /* 3 3 Plugin Name: WooCommerce Paytm Payment Gateway 4 Version: 1.1. 15 Description: This plugin using visitors to pay via Paytm.4 Version: 1.1.2 5 Description: This plugin is used to integrate Paytm payment gateway with Woocommerce. 6 6 Author: FTI Technologies 7 7 Author URI: https://www.freelancetoindia.com/ 8 8 */ 9 9 10 define( 'PAYTM_PLUGIN_PATH', plugin_dir_path( __FILE__ ));10 define( 'PAYTM_PLUGIN_PATH', plugin_dir_path( __FILE__ )); 11 11 require_once(PAYTM_PLUGIN_PATH . 'include/function.php'); 12 12 add_action('plugins_loaded', 'WC_paytmpay_init'); 13 13 14 function WC_paytmpay_init() {14 function WC_paytmpay_init(){ 15 15 16 16 if ( !class_exists( 'WC_Payment_Gateway' ) ) return; … … 21 21 22 22 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; 24 24 } 25 25 /** … … 28 28 class WC_Gateway_paytmpay extends WC_Payment_Gateway { 29 29 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 35 36 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'] = ""; 57 56 58 add_action('init', array(&$this, 'capture_paytm_response'));59 60 57 add_action('woocommerce_api_' . strtolower( get_class( $this ) ), array( $this, 'capture_paytm_response' ) ); 61 58 add_action('woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); 62 59 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( 69 65 'enabled' => array( 70 66 'title' => __('Enable/Disable'), 71 67 'type' => 'checkbox', 72 68 'label' => __('Enable Paytm Payment Gateway.'), 73 'default' => 'no' ),74 69 'default' => 'no' 70 ), 75 71 'title' => array( 76 'title' => __('Title :'),72 'title' => __('Title'), 77 73 'type'=> 'text', 78 74 'description' => __('This controls the title which the user sees during checkout.'), 79 'default' => __('pay with paytm') ),80 75 'default' => __('pay with paytm') 76 ), 81 77 'description' => array( 82 'title' => __('Description :'),78 'title' => __('Description'), 83 79 'type' => 'textarea', 84 80 '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 ), 87 83 'merchantID' => array( 88 84 'title' => __('Merchant ID'), 89 85 '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 ), 92 88 'merchant_key' => array( 93 89 'title' => __('Merchant Key'), 94 90 'type' => 'text', 95 'description' => __('Given to Merchant by paytm') ),96 91 'description' => __('Given to Merchant by paytm') 92 ), 97 93 'industry_type_id' => array( 98 94 'title' => __('Industry Type ID'), 99 95 'type' => 'text', 100 'description' => __('Given to Merchant by paytm') ),101 96 'description' => __('Given to Merchant by paytm') 97 ), 102 98 'paytm_channel_id' => array( 103 99 'title' => __('Channel ID'), 104 100 'type' => 'text', 105 'description' => __('WEB - for desktop websites / WAP - for mobile websites')), 106 101 'description' => __('WEB - for desktop websites / WAP - for mobile websites')), 107 102 'website' => array( 108 103 'title' => __('Website'), 109 104 'type' => 'text', 110 105 '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 ), 122 107 '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' 136 113 ) 137 114 ); 138 139 140 115 } 141 116 … … 146 121 $description = $this->get_description(); 147 122 if ( $description ) { 148 echo wpautop( wptexturize( trim( $description ) ) );123 echo wpautop( wptexturize( trim( $description ) ) ); 149 124 } 150 125 } 151 126 152 /**127 /** 153 128 * Admin Panel Options 154 129 * - Options for bits like 'title' and availability on a country-by-country basis … … 158 133 echo '<p>'.__('India online payment solutions for all your transactions by paytm').'</p>'; 159 134 echo '<table class="form-table">'; 160 $this ->generate_settings_html();135 $this->generate_settings_html(); 161 136 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 } 173 147 174 148 … … 177 151 **/ 178 152 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); 181 155 } 182 156 … … 187 161 if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) { 188 162 $order = new WC_Order($order_id); 189 } else {163 } else { 190 164 $order = new woocommerce_order($order_id); 191 165 } … … 195 169 } 196 170 197 /**171 /** 198 172 * Check for valid paytm server callback // response processing // 199 173 **/ 200 174 function capture_paytm_response(){ 201 global $woocommerce; 175 global $woocommerce; 176 //echo '<pre>'; print_r($_POST); die('WooCommerce'); 202 177 if(isset($_POST['ORDERID']) && isset($_POST['RESPCODE'])){ 203 178 $order_sent = sanitize_text_field($_POST['ORDERID']); … … 209 184 } 210 185 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){ 221 189 222 190 $order_amount = $order->get_total(); 223 191 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)){ 227 193 $order_sent = sanitize_text_field($_POST['ORDERID']); 228 194 $res_code = sanitize_text_field($_POST['RESPCODE']); 229 195 $responseDescription = sanitize_text_field($_POST['RESPMSG']); 230 $order_amount = sanitize_text_field($_POST['TXNAMOUNT']);196 $order_amount = sanitize_text_field($_POST['TXNAMOUNT']); 231 197 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"){ 233 199 234 $requestParamList = array("MID" => $this -> merchantID , "ORDERID" => $order_sent); 235 200 $requestParamList = array("MID" => $this->merchantID , "ORDERID" => $order_sent); 236 201 $StatusCheckSum = wppg_getChecksumFromArray($requestParamList, $this->merchant_key); 237 238 202 $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; 239 203 240 if($this -> mode=='yes') 241 { 204 if($this->mode=='yes'){ 242 205 $check_status_url = 'https://securegw-stage.paytm.in/merchant-status/getTxnStatus'; 243 244 } 245 else 246 { 206 } else { 247 207 $check_status_url = 'https://securegw.paytm.in/merchant-status/getTxnStatus'; 248 208 } 249 $responseParamList = get_paytm_response_url($check_status_url, $requestParamList); 209 210 $responseParamList = wppg_get_paytm_response_url($check_status_url, $requestParamList); 250 211 251 if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT'] ==$order_amount)212 if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT'] == $order_amount) 252 213 { 253 254 214 if ( $order->has_status( 'pending' ) ) 255 215 { 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'; 258 218 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(); 268 223 } 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']); 269 229 } 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']); 278 235 } 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']); 287 241 } 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']); 297 246 } 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']);303 247 304 } 305 add_action('the_content', array(&$this, 'PaytmPayShowMsg')); 248 add_action('the_content', array(&$this, 'PaytmPayShowMsg')); 306 249 307 308 250 $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 ); 312 252 wp_redirect( $redirect_url ); 313 253 exit; … … 321 261 public function generate_paytm_form($order_id){ 322 262 global $woocommerce; 323 $txnDate =date('Y-m-d');263 $txnDate = date('Y-m-d'); 324 264 $milliseconds = (int) (1000 * (strtotime(date('Y-m-d')))); 325 265 326 266 if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) { 327 267 $order = new WC_Order($order_id); 328 } else {268 } else { 329 269 $order = new woocommerce_order($order_id); 330 270 } … … 333 273 334 274 $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 338 281 ////////////// 339 282 $order_id = $order->get_id(); 340 283 $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 350 285 $email = $order->get_billing_email(); 351 286 $mobile_no = $order->get_billing_phone(); 352 287 353 288 $post_params = Array( 354 "MID" => $this ->merchantID,289 "MID" => $this->merchantID, 355 290 "ORDER_ID" => $order_id, 356 291 "CUST_ID" => $email, … … 361 296 "EMAIL" => $email, 362 297 "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 387 302 $checksum = wppg_getChecksumFromArray($post_params, $this->merchant_key); 388 303 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' => $checksum412 );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 427 304 $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 ."'/>"; 430 306 $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 ."'/>"; 434 310 $paytm_args_array[] = "<input type='hidden' name='TXN_AMOUNT' value='". $Order_Total ."'/>"; 435 311 $paytm_args_array[] = "<input type='hidden' name='CUST_ID' value='". $email ."'/>"; … … 437 313 $paytm_args_array[] = "<input type='hidden' name='MOBILE_NO' value='". $mobile_no ."'/>"; 438 314 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 455 327 return '<form action="'.$action_url.'" method="post" id="paytm_payment_form" name="gopaytm"> 456 328 ' . implode('', $paytm_args_array) . ' … … 461 333 </form>'; 462 334 } 463 464 335 } 465 336 … … 474 345 add_filter('woocommerce_payment_gateways', 'woocommerce_add_paytm_gateway' ); 475 346 } 476 477 347 ?>
Note: See TracChangeset
for help on using the changeset viewer.