Plugin Directory

Changeset 2915735


Ignore:
Timestamp:
05/22/2023 10:30:12 AM (3 years ago)
Author:
hoangweb
Message:

update of my plugin

Location:
qh-testpay
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • qh-testpay/tags/1.0.1/inc/class-qhpay-admin-page.php

    r2843203 r2915735  
    262262                            </td>
    263263                        </tr>
     264                        <!--
    264265                        <tr>
    265266                            <th scope="row"><?php echo __('Webhook', 'qh-testpay') ?></th>
     
    267268                                <input type="text" name="settings[webhook]" id="webhook" value="<?php echo isset($settings['webhook'])? $settings['webhook']:'' ?>"/>
    268269                            </td>
    269                         </tr>
     270                        </tr> -->
     271                        <tr>
     272                            <th scope="row"><?php echo __('Telegram Bot Token', 'qh-testpay') ?></th>
     273                            <td>
     274                                <input type="text" name="settings[telegram_token]" id="telegram_token" value="<?php echo isset($settings['telegram_token'])? $settings['telegram_token']:'' ?>"/>
     275                            </td>
     276                        </tr>
     277                        <tr>
     278                            <th scope="row"><?php echo __('Telegram Group ID', 'qh-testpay') ?></th>
     279                            <td>
     280                                <input type="text" name="settings[telegram_chatid]" id="telegram_chatid" value="<?php echo isset($settings['telegram_chatid'])? $settings['telegram_chatid']:'' ?>"/>
     281                            </td>
     282                        </tr>
     283                   
    270284                        <tr>
    271285                            <th scope="row"><?php echo __('Auto check user paid', 'qh-testpay') ?></th>
  • qh-testpay/tags/1.0.1/inc/functions.php

    r2771861 r2915735  
    7171    return $headers;
    7272}
    73 
    74 function qhp_parse_order_id($des, $prefix, $insensitive){
     73function qhp_parse_code($des, $prefix, $insensitive){
    7574    //TODO : Rewrite this function.
    7675    //phân biệt
     
    8786    // Print the entire match result
    8887    $orderCode = $matches[0][0];
    89    
     88    return $orderCode;
     89}
     90function qhp_parse_order_id($des, $prefix, $insensitive){
     91    $orderCode = qhp_parse_code($des, $prefix, $insensitive);
    9092    $prefixLength = strlen($prefix);
    9193
  • qh-testpay/tags/1.0.1/qh-testpay.php

    r2843203 r2915735  
    1818define('QHTP_DIR', plugin_dir_path(__FILE__));
    1919define('QHTP_URL', plugins_url('/', __FILE__));
    20 define('QHTP_TEST', 0);
     20define('QHTP_TEST', false);
    2121//require(__DIR__."/lib/phpqrcode/qrlib.php");
    2222require(__DIR__."/inc/functions.php");
     
    536536        }
    537537        $result = ['msg'=>[],'error'=>1,'rawInput'=> $txtBody];
     538        $bankMsg = "";
     539        $domain = parse_url(home_url(),PHP_URL_HOST);
    538540
    539541        if(!empty($jsonBody->data))
     
    551553                }
    552554            }
     555            //message for telegram
     556            $bankMsg = sprintf("QHTP Thông báo giao dịch:\nTrang web: %s\nSố tiền: %s\nMã: %s\nTin nhắn: %s",
     557                    $domain,
     558                    number_format($transaction->amount),
     559                    qhp_parse_code($des,$this->settings['bank_transfer']['transaction_prefix'], $this->settings['bank_transfer']['case_insensitive']),
     560                    $transaction->description//$transaction->when
     561                );
    553562            $order_id = qhp_parse_order_id($des, $this->settings['bank_transfer']['transaction_prefix'], $this->settings['bank_transfer']['case_insensitive']);
    554563            if (is_null($order_id)) {
     
    616625            if(empty($result['error'])) break;
    617626        }
     627        //telegram bot
     628        if(!empty($this->settings['telegram_token']) && !empty($this->settings['telegram_chatid'])) {
     629            $token = trim($this->settings['telegram_token']);
     630            $chatid = trim($this->settings['telegram_chatid']);
     631            $text = substr($bankMsg,0,4000);//$jsonBody->data? json_encode($jsonBody->data):'[]';
     632            if(substr( $token, 0, 3 ) != "bot") $token='bot'.$token;
     633            $response = wp_remote_get( "https://api.telegram.org/{$token}/sendMessage?chat_id={$chatid}&text=".urlencode($text), array(
     634                'timeout'     => 120,
     635                'httpversion' => '1.1',
     636                'headers' => array(
     637                  )
     638            ));
     639            #$result['msg'][] = wp_remote_retrieve_body( $response );
     640        }
    618641        //other webhook
    619642        if(!empty($this->settings['webhook']) && filter_var($this->settings['webhook'], FILTER_VALIDATE_URL)) {
  • qh-testpay/trunk/inc/banks/class-qhpay-base.php

    r2896947 r2915735  
    720720            $pay_url = "";
    721721            if($bank=='momo') {
    722                 $img_url = get_rest_url(null, "bck/v1/qrcode?app=momo&phone={$accountNo}&price={$amount}&content=".urlencode($addInfo));
     722                $img_url = get_rest_url(null, "qhtp/v1/qrcode?app=momo&phone={$accountNo}&price={$amount}");
    723723            }
    724724            else if($bank=='viettelpay') {
  • qh-testpay/trunk/inc/class-qhpay-admin-page.php

    r2843203 r2915735  
    262262                            </td>
    263263                        </tr>
     264                        <!--
    264265                        <tr>
    265266                            <th scope="row"><?php echo __('Webhook', 'qh-testpay') ?></th>
     
    267268                                <input type="text" name="settings[webhook]" id="webhook" value="<?php echo isset($settings['webhook'])? $settings['webhook']:'' ?>"/>
    268269                            </td>
    269                         </tr>
     270                        </tr> -->
     271                        <tr>
     272                            <th scope="row"><?php echo __('Telegram Bot Token', 'qh-testpay') ?></th>
     273                            <td>
     274                                <input type="text" name="settings[telegram_token]" id="telegram_token" value="<?php echo isset($settings['telegram_token'])? $settings['telegram_token']:'' ?>"/>
     275                            </td>
     276                        </tr>
     277                        <tr>
     278                            <th scope="row"><?php echo __('Telegram Group ID', 'qh-testpay') ?></th>
     279                            <td>
     280                                <input type="text" name="settings[telegram_chatid]" id="telegram_chatid" value="<?php echo isset($settings['telegram_chatid'])? $settings['telegram_chatid']:'' ?>"/>
     281                            </td>
     282                        </tr>
     283                   
    270284                        <tr>
    271285                            <th scope="row"><?php echo __('Auto check user paid', 'qh-testpay') ?></th>
  • qh-testpay/trunk/inc/functions.php

    r2896947 r2915735  
    7171    return $headers;
    7272}
    73 
    74 function qhp_parse_order_id($des, $prefix, $insensitive){
     73function qhp_parse_code($des, $prefix, $insensitive){
    7574    //TODO : Rewrite this function.
    7675    //phân biệt
     
    8786    // Print the entire match result
    8887    $orderCode = $matches[0][0];
    89    
     88    return $orderCode;
     89}
     90function qhp_parse_order_id($des, $prefix, $insensitive){
     91    $orderCode = qhp_parse_code($des, $prefix, $insensitive);
    9092    $prefixLength = strlen($prefix);
    9193
     
    140142    if($phone && $price){
    141143        if($app=='momo') {
    142             $text = sprintf("2|99|%s|||0|0|%d|%s|transfer_myqr", $phone, $price,$content);
     144            $text = sprintf("2|99|%s|||0|0|%d", $phone, $price);
    143145            $img = QHTP_DIR.'/assets/momo.png';
    144146            QRcode::png($text, false, QR_ECLEVEL_Q, 10);
  • qh-testpay/trunk/qh-testpay.php

    r2843203 r2915735  
    1818define('QHTP_DIR', plugin_dir_path(__FILE__));
    1919define('QHTP_URL', plugins_url('/', __FILE__));
    20 define('QHTP_TEST', 0);
     20define('QHTP_TEST', false);
    2121//require(__DIR__."/lib/phpqrcode/qrlib.php");
    2222require(__DIR__."/inc/functions.php");
     
    536536        }
    537537        $result = ['msg'=>[],'error'=>1,'rawInput'=> $txtBody];
     538        $bankMsg = "";
     539        $domain = parse_url(home_url(),PHP_URL_HOST);
    538540
    539541        if(!empty($jsonBody->data))
     
    551553                }
    552554            }
     555            //message for telegram
     556            $bankMsg = sprintf("QHTP Thông báo giao dịch:\nTrang web: %s\nSố tiền: %s\nMã: %s\nTin nhắn: %s",
     557                    $domain,
     558                    number_format($transaction->amount),
     559                    qhp_parse_code($des,$this->settings['bank_transfer']['transaction_prefix'], $this->settings['bank_transfer']['case_insensitive']),
     560                    $transaction->description//$transaction->when
     561                );
    553562            $order_id = qhp_parse_order_id($des, $this->settings['bank_transfer']['transaction_prefix'], $this->settings['bank_transfer']['case_insensitive']);
    554563            if (is_null($order_id)) {
     
    616625            if(empty($result['error'])) break;
    617626        }
     627        //telegram bot
     628        if(!empty($this->settings['telegram_token']) && !empty($this->settings['telegram_chatid'])) {
     629            $token = trim($this->settings['telegram_token']);
     630            $chatid = trim($this->settings['telegram_chatid']);
     631            $text = substr($bankMsg,0,4000);//$jsonBody->data? json_encode($jsonBody->data):'[]';
     632            if(substr( $token, 0, 3 ) != "bot") $token='bot'.$token;
     633            $response = wp_remote_get( "https://api.telegram.org/{$token}/sendMessage?chat_id={$chatid}&text=".urlencode($text), array(
     634                'timeout'     => 120,
     635                'httpversion' => '1.1',
     636                'headers' => array(
     637                  )
     638            ));
     639            #$result['msg'][] = wp_remote_retrieve_body( $response );
     640        }
    618641        //other webhook
    619642        if(!empty($this->settings['webhook']) && filter_var($this->settings['webhook'], FILTER_VALIDATE_URL)) {
Note: See TracChangeset for help on using the changeset viewer.