Changeset 2915744
- Timestamp:
- 05/22/2023 10:49:02 AM (3 years ago)
- Location:
- thanh-toan-chuyen-khoan
- Files:
-
- 6 edited
-
tags/1.0.0/inc/class-ttck-admin-page.php (modified) (1 diff)
-
tags/1.0.0/inc/functions.php (modified) (1 diff)
-
tags/1.0.0/ttck.php (modified) (3 diffs)
-
trunk/inc/class-ttck-admin-page.php (modified) (1 diff)
-
trunk/inc/functions.php (modified) (1 diff)
-
trunk/ttck.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
thanh-toan-chuyen-khoan/tags/1.0.0/inc/class-ttck-admin-page.php
r2781700 r2915744 257 257 </td> 258 258 <tr> 259 <!-- 260 <tr> 261 <th scope="row"><?php echo __('Webhook', 'thanh-toan-chuyen-khoan') ?></th> 262 <td> 263 <input type="text" name="settings[webhook]" id="webhook" value="<?php echo isset($settings['webhook'])? $settings['webhook']:'' ?>"/> 264 </td> 265 </tr> --> 266 <tr> 267 <th scope="row"><?php echo __('Telegram Bot Token', 'thanh-toan-chuyen-khoan') ?></th> 268 <td> 269 <input type="text" name="settings[telegram_token]" id="telegram_token" value="<?php echo isset($settings['telegram_token'])? $settings['telegram_token']:'' ?>"/> 270 </td> 271 </tr> 272 <tr> 273 <th scope="row"><?php echo __('Telegram Group ID', 'thanh-toan-chuyen-khoan') ?></th> 274 <td> 275 <input type="text" name="settings[telegram_chatid]" id="telegram_chatid" value="<?php echo isset($settings['telegram_chatid'])? $settings['telegram_chatid']:'' ?>"/> 276 </td> 277 </tr> 259 278 <tr> 260 279 <th scope="row"><?php echo __('Auto check user paid', 'thanh-toan-chuyen-khoan') ?></th> -
thanh-toan-chuyen-khoan/tags/1.0.0/inc/functions.php
r2896956 r2915744 71 71 return $headers; 72 72 } 73 73 function ttck_parse_code($des, $prefix, $insensitive){ 74 //TODO : Rewrite this function. 75 //phân biệt 76 if ($insensitive=='yes') { 77 $re = '/'.$prefix.'\d+/m'; 78 }else{ 79 $re = '/'.$prefix.'\d+/mi'; //$this->get_option( 'transaction_prefix' ) 80 } 81 82 preg_match_all($re, $des, $matches, PREG_SET_ORDER, 0); 83 84 if (count($matches) == 0 ) 85 return null; 86 // Print the entire match result 87 $orderCode = $matches[0][0]; 88 return $orderCode; 89 } 74 90 function ttck_parse_order_id($des, $prefix, $insensitive){ 75 91 //TODO : Rewrite this function. -
thanh-toan-chuyen-khoan/tags/1.0.0/ttck.php
r2781700 r2915744 525 525 } 526 526 $result = ['msg'=>[],'error'=>1,'rawInput'=> $txtBody]; 527 $bankMsg = ""; 528 $domain = parse_url(home_url(),PHP_URL_HOST); 527 529 528 530 if(!empty($jsonBody->data)) … … 540 542 } 541 543 } 544 //message for telegram: Amount: %s\nDesc: %s\nDate: %s 545 $bankMsg = sprintf("Thông báo giao dịch:\nTrang web: %s\nSố tiền: %s\nMã: %s\nTin nhắn: %s", 546 $domain, 547 number_format($transaction->amount), 548 ttck_parse_code($des,$this->settings['bank_transfer']['transaction_prefix'], $this->settings['bank_transfer']['case_insensitive']), 549 $transaction->description//$transaction->when 550 ); 542 551 $order_id = ttck_parse_order_id($des, $this->settings['bank_transfer']['transaction_prefix'], $this->settings['bank_transfer']['case_insensitive']); 543 552 if (is_null($order_id)) { … … 605 614 if(empty($result['error'])) break; 606 615 } 616 //telegram bot 617 if(!empty($this->settings['telegram_token']) && !empty($this->settings['telegram_chatid'])) { 618 $token = trim($this->settings['telegram_token']); 619 $chatid = trim($this->settings['telegram_chatid']); 620 $text = substr($bankMsg,0,4000);//$jsonBody->data? json_encode($jsonBody->data):'[]'; 621 if(substr( $token, 0, 3 ) != "bot") $token='bot'.$token; 622 $response = wp_remote_get( "https://api.telegram.org/{$token}/sendMessage?chat_id={$chatid}&text=".urlencode($text), array( 623 'timeout' => 120, 624 'httpversion' => '1.1', 625 'headers' => array( 626 ) 627 )); 628 #$result['msg'][] = wp_remote_retrieve_body( $response ); 629 } 630 //other webhook 631 if(!empty($this->settings['webhook']) && filter_var($this->settings['webhook'], FILTER_VALIDATE_URL)) { 632 $resp = wp_remote_post ($this->settings['webhook'], [ 633 'method' => 'POST', 634 'timeout' => 45, 635 'redirection' => 5, 636 'httpversion' => '1.0', 637 'blocking' => false,//true 638 'headers' => array('Content-Type: application/json'), 639 'sslverify' => false, 640 'body'=> $txtBody,//json_decode($txtBody,true) 641 ]); 642 if ( is_wp_error( $resp ) ) $result['msg'][] = $resp->get_error_message(); 643 } 644 //end 607 645 $result['msg'] = join(". ", $result['msg']); 608 646 wp_send_json($result); -
thanh-toan-chuyen-khoan/trunk/inc/class-ttck-admin-page.php
r2781700 r2915744 257 257 </td> 258 258 <tr> 259 <!-- 260 <tr> 261 <th scope="row"><?php echo __('Webhook', 'thanh-toan-chuyen-khoan') ?></th> 262 <td> 263 <input type="text" name="settings[webhook]" id="webhook" value="<?php echo isset($settings['webhook'])? $settings['webhook']:'' ?>"/> 264 </td> 265 </tr> --> 266 <tr> 267 <th scope="row"><?php echo __('Telegram Bot Token', 'thanh-toan-chuyen-khoan') ?></th> 268 <td> 269 <input type="text" name="settings[telegram_token]" id="telegram_token" value="<?php echo isset($settings['telegram_token'])? $settings['telegram_token']:'' ?>"/> 270 </td> 271 </tr> 272 <tr> 273 <th scope="row"><?php echo __('Telegram Group ID', 'thanh-toan-chuyen-khoan') ?></th> 274 <td> 275 <input type="text" name="settings[telegram_chatid]" id="telegram_chatid" value="<?php echo isset($settings['telegram_chatid'])? $settings['telegram_chatid']:'' ?>"/> 276 </td> 277 </tr> 259 278 <tr> 260 279 <th scope="row"><?php echo __('Auto check user paid', 'thanh-toan-chuyen-khoan') ?></th> -
thanh-toan-chuyen-khoan/trunk/inc/functions.php
r2896956 r2915744 71 71 return $headers; 72 72 } 73 73 function ttck_parse_code($des, $prefix, $insensitive){ 74 //TODO : Rewrite this function. 75 //phân biệt 76 if ($insensitive=='yes') { 77 $re = '/'.$prefix.'\d+/m'; 78 }else{ 79 $re = '/'.$prefix.'\d+/mi'; //$this->get_option( 'transaction_prefix' ) 80 } 81 82 preg_match_all($re, $des, $matches, PREG_SET_ORDER, 0); 83 84 if (count($matches) == 0 ) 85 return null; 86 // Print the entire match result 87 $orderCode = $matches[0][0]; 88 return $orderCode; 89 } 74 90 function ttck_parse_order_id($des, $prefix, $insensitive){ 75 91 //TODO : Rewrite this function. -
thanh-toan-chuyen-khoan/trunk/ttck.php
r2781700 r2915744 525 525 } 526 526 $result = ['msg'=>[],'error'=>1,'rawInput'=> $txtBody]; 527 $bankMsg = ""; 528 $domain = parse_url(home_url(),PHP_URL_HOST); 527 529 528 530 if(!empty($jsonBody->data)) … … 540 542 } 541 543 } 544 //message for telegram: Amount: %s\nDesc: %s\nDate: %s 545 $bankMsg = sprintf("Thông báo giao dịch:\nTrang web: %s\nSố tiền: %s\nMã: %s\nTin nhắn: %s", 546 $domain, 547 number_format($transaction->amount), 548 ttck_parse_code($des,$this->settings['bank_transfer']['transaction_prefix'], $this->settings['bank_transfer']['case_insensitive']), 549 $transaction->description//$transaction->when 550 ); 542 551 $order_id = ttck_parse_order_id($des, $this->settings['bank_transfer']['transaction_prefix'], $this->settings['bank_transfer']['case_insensitive']); 543 552 if (is_null($order_id)) { … … 605 614 if(empty($result['error'])) break; 606 615 } 616 //telegram bot 617 if(!empty($this->settings['telegram_token']) && !empty($this->settings['telegram_chatid'])) { 618 $token = trim($this->settings['telegram_token']); 619 $chatid = trim($this->settings['telegram_chatid']); 620 $text = substr($bankMsg,0,4000);//$jsonBody->data? json_encode($jsonBody->data):'[]'; 621 if(substr( $token, 0, 3 ) != "bot") $token='bot'.$token; 622 $response = wp_remote_get( "https://api.telegram.org/{$token}/sendMessage?chat_id={$chatid}&text=".urlencode($text), array( 623 'timeout' => 120, 624 'httpversion' => '1.1', 625 'headers' => array( 626 ) 627 )); 628 #$result['msg'][] = wp_remote_retrieve_body( $response ); 629 } 630 //other webhook 631 if(!empty($this->settings['webhook']) && filter_var($this->settings['webhook'], FILTER_VALIDATE_URL)) { 632 $resp = wp_remote_post ($this->settings['webhook'], [ 633 'method' => 'POST', 634 'timeout' => 45, 635 'redirection' => 5, 636 'httpversion' => '1.0', 637 'blocking' => false,//true 638 'headers' => array('Content-Type: application/json'), 639 'sslverify' => false, 640 'body'=> $txtBody,//json_decode($txtBody,true) 641 ]); 642 if ( is_wp_error( $resp ) ) $result['msg'][] = $resp->get_error_message(); 643 } 644 //end 607 645 $result['msg'] = join(". ", $result['msg']); 608 646 wp_send_json($result);
Note: See TracChangeset
for help on using the changeset viewer.