Plugin Directory

Changeset 3336276


Ignore:
Timestamp:
07/30/2025 02:39:34 AM (8 months ago)
Author:
aipsg
Message:

tagging version 1.1.3

Location:
allinpayintl/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • allinpayintl/trunk/Allinpay_INTL.php

    r3213666 r3336276  
    9393                $showInfo = '<button type="button" class="button" id="allinpay_query_btn" data-order-id="' . $order_id . '">' . $button_text . '</button>';
    9494                $allowed_html=array(
    95                         'button'=> array(
    96                             'type' => array(),
    97                             'class' => array(),
    98                             'id' => array(),
    99                             'data-order-id' => array()
    100                             )
    101                         );
     95                    'button'=> array(
     96                        'type' => array(),
     97                        'class' => array(),
     98                        'id' => array(),
     99                        'data-order-id' => array()
     100                    )
     101                );
    102102                echo wp_kses($showInfo,$allowed_html);
    103103            }
     
    116116            wp_enqueue_script('allinpay-query-button-script', rtrim(plugin_dir_url(__FILE__),'/').'/js/custom-query-button.js', array('jquery'), '1.7', true);
    117117            wp_localize_script( 'allinpay-query-button-script', 'custom_script_vars', array(
    118                         'nonce' => wp_create_nonce( 'allinpay_query' ),'ajaxurl'=> admin_url('admin-ajax.php')
    119                         ) );
     118                'nonce' => wp_create_nonce( 'allinpay_query' ),'ajaxurl'=> admin_url('admin-ajax.php')
     119            ) );
    120120            wp_enqueue_script( 'jquery' );
    121121        }
     
    129129                $order = wc_get_order( $order_id );
    130130                $query_data = array('version' => $this->version,
    131                         'mchtId'=> $this->merchant_id,
    132                         'transType'=> 'Query',
    133                         'oriAccessOrderId'=> $order->get_meta('custom_order_number'),
    134                         'signType' => 'RSA2'
    135                         );
     131                    'mchtId'=> $this->merchant_id,
     132                    'transType'=> 'Query',
     133                    'oriAccessOrderId'=> $order->get_meta('custom_order_number'),
     134                    'signType' => 'RSA2'
     135                );
    136136                $signature = $this->generate_signature($query_data);
    137137                $query_data['sign'] = $signature;
     
    162162        }
    163163        function add_allinpay_style(){
    164            
     164
    165165            wp_register_style('allinpay-css-default',rtrim(plugin_dir_url(__FILE__),'/'). '/css/default.css');
    166166            wp_enqueue_style('allinpay-css-default');
     
    170170            // Payment gateway settings initialization
    171171            $this->form_fields = array(
    172                     'enabled' => array(
    173                         'title' => __('Enable/Disable','allinpay_intl'),
    174                         'type' => 'checkbox',
    175                         'label' => 'Enable Allinpay INTL',
    176                         'default' => 'no'
    177                         ),
    178                     'title' => array(
    179                         'title' => 'Title',
    180                         'type' => 'text',
    181                         'description' => 'This controls the title which the user sees during checkout.',
    182                         'default' => __('Allinpay INTL','allinpay_intl'),
    183                         'desc_tip' => true
    184 
    185                         ),
    186                     'description' => array(
    187                         'title' => 'Description',
    188                         'type' => 'textarea',
    189                         'description' => 'This controls the description which the user sees during checkout.',
    190                         'default' => 'Pay with Allinpay INTL',
    191                         ),
    192                     'version' => array(
    193                             'title' => 'Version',
    194                             'type' => 'text',
    195                             'description' => 'This controls the title which the user sees during checkout.',
    196                             'default' => 'V2.0.0',
    197                             'desc_tip' => true
    198                             ),
    199 
    200                     'trace_url' => array(
    201                             'title' => 'Trace Url',
    202                             'type' => 'text',
    203                             'description' => 'Enter the trace url provided by Payment Gateway.',
    204                             'default' => '',
    205                             'desc_tip' => true
    206                             ),
    207                     'merchant_id' => array(
    208                             'title' => 'Merchant ID',
    209                             'type' => 'text',
    210                             'description' => 'Enter your merchant ID provided by Payment Gateway.',
    211                             'desc_tip' => true
    212                             ),
    213                     'private_key' => array(
    214                             'title' => 'Private Key',
    215                             'type' => 'textarea',
    216                             'description' => 'Enter your private key provided by  Payment Gateway.',
    217                             'desc_tip' => true
    218                             ),
    219                     'public_key' => array(
    220                             'title' => 'Public Key',
    221                             'type' => 'textarea',
    222                             'description' => 'Enter your public key provided by  Payment Gateway.',
    223                             'desc_tip' => true
    224                             ),
    225 
    226                     'debug_log' => array(
    227                             'title' => __('debug_log','allinpay_intl'),
    228                             'type' => 'checkbox',
    229                             'description' => __('Log payment events,such as trade status,inside<code>wp-content/uploads/wc-logs/</code> ','allinpay_intl'),
    230                             'default' => 'no'
    231                             )
    232 
    233                         );
     172                'enabled' => array(
     173                    'title' => __('Enable/Disable','allinpay_intl'),
     174                    'type' => 'checkbox',
     175                    'label' => 'Enable Allinpay INTL',
     176                    'default' => 'no'
     177                ),
     178                'title' => array(
     179                    'title' => 'Title',
     180                    'type' => 'text',
     181                    'description' => 'This controls the title which the user sees during checkout.',
     182                    'default' => __('Allinpay INTL','allinpay_intl'),
     183                    'desc_tip' => true
     184
     185                ),
     186                'description' => array(
     187                    'title' => 'Description',
     188                    'type' => 'textarea',
     189                    'description' => 'This controls the description which the user sees during checkout.',
     190                    'default' => 'Pay with Allinpay INTL',
     191                ),
     192                'version' => array(
     193                    'title' => 'Version',
     194                    'type' => 'text',
     195                    'description' => 'This controls the title which the user sees during checkout.',
     196                    'default' => 'V2.0.0',
     197                    'desc_tip' => true
     198                ),
     199
     200                'trace_url' => array(
     201                    'title' => 'Trace Url',
     202                    'type' => 'text',
     203                    'description' => 'Enter the trace url provided by Payment Gateway.',
     204                    'default' => '',
     205                    'desc_tip' => true
     206                ),
     207                'merchant_id' => array(
     208                    'title' => 'Merchant ID',
     209                    'type' => 'text',
     210                    'description' => 'Enter your merchant ID provided by Payment Gateway.',
     211                    'desc_tip' => true
     212                ),
     213                'private_key' => array(
     214                    'title' => 'Private Key',
     215                    'type' => 'textarea',
     216                    'description' => 'Enter your private key provided by  Payment Gateway.',
     217                    'desc_tip' => true
     218                ),
     219                'public_key' => array(
     220                    'title' => 'Public Key',
     221                    'type' => 'textarea',
     222                    'description' => 'Enter your public key provided by  Payment Gateway.',
     223                    'desc_tip' => true
     224                ),
     225
     226                'debug_log' => array(
     227                    'title' => __('debug_log','allinpay_intl'),
     228                    'type' => 'checkbox',
     229                    'description' => __('Log payment events,such as trade status,inside<code>wp-content/uploads/wc-logs/</code> ','allinpay_intl'),
     230                    'default' => 'no'
     231                )
     232
     233            );
    234234        }
    235235
     
    247247            foreach($items as $item){
    248248                $weldpay_item = array(
    249                         'sku' => $item['product_id'],
    250                         'productName' => $item['name'],
    251                         'price'=> $item['total'],
    252                         'quantity'=> $item['quantity'],
    253                         );
     249                    'sku' => $item['product_id'],
     250                    'productName' => $item['name'],
     251                    'price'=> $item['total'],
     252                    'quantity'=> $item['quantity'],
     253                );
    254254                $weldpay_items[]=json_encode($weldpay_item);
    255255            }
    256256            //var_dump($weldpay_items);
    257257            $payment_data = array(
    258                     'version' => $this->version,
    259                     'mchtId' => $this->merchant_id,
    260                     'transType' => 'CashierPay',
    261                     //'accessOrderId' => $order->get_id(),
    262                     'accessOrderId' => $order->get_meta('custom_order_number'),
    263                     'currency' => $order->get_currency(),
    264                     'amount' => $order->get_total(),
    265                     'language' =>substr(get_locale(), 0, 2),
    266                     //'payPageStyle' => 'DEFAULT',
    267                     'email' =>  $order->get_billing_email(),
    268                     'returnUrl' => WC()->api_request_url('allinpay_front_payment_callback'),
    269                     'notifyUrl' =>  WC()->api_request_url('allinpay_payment_callback'),
    270                     //'timeZone' //持卡人时区,可选
    271 
    272                     'signType' => 'RSA2',//签名类型
    273                     //'txnTitle' => $order->get_title(),
    274                     //'txnDetail' => $order->get_title(),
    275 
    276 
    277                     'shippingFirstName' => !empty($order->get_shipping_first_name()) ? $order->get_shipping_first_name():$order->get_billing_first_name(),
    278                     //'shippingFirstName' => $order->get_shipping_first_name(),
    279                     'shippingLastName' => !empty($order->get_shipping_last_name()) ? $order->get_shipping_last_name():$order->get_billing_last_name(),
    280                     'shippingAddress1' => !empty($order->get_shipping_address_1())? $order->get_shipping_address_1():$order->get_billing_address_1(),
    281                     //'shippingAddress2' => $order->get_shipping_address_2(), //可选
    282                     'shippingCity' => !empty($order->get_shipping_city())? $order->get_shipping_city():$order->get_billing_city(),
    283                     //'shippingState'=> $order->get_shipping_state(),
    284                     'shippingState'=>!empty($order->get_shipping_state()) ? $order->get_shipping_state() :( !empty($order->get_shipping_city())?$order->get_shipping_city():$order->get_billing_city()),
    285                     'shippingCountry'=>!empty($order->get_shipping_country())?$order->get_shipping_country():$order->get_billing_country(),
    286                     'shippingZipCode' => !empty($order->get_shipping_postcode())?$order->get_shipping_postcode():$order->get_billing_postcode(),
    287                     'shippingPhone' => $order->get_billing_phone(),
    288 
    289                     'billingFirstName' => $order->get_billing_first_name(),
    290                     'billingLastName' => $order->get_billing_last_name(),
    291                     'billingAddress1' => $order->get_billing_address_1(),
    292                     //'billingAddress2' => $order->get_billing_address_2(),
    293                     'billingCity' => $order->get_billing_city(),
    294                     'billingState' => $order->get_billing_state(),
    295                     'billingCountry' => $order->get_billing_country(),
    296                     'billingZipCode' => $order->get_billing_postcode(),
    297                     'billingPhone' => $order->get_billing_phone());
     258                'version' => $this->version,
     259                'mchtId' => $this->merchant_id,
     260                'transType' => 'CashierPay',
     261                //'accessOrderId' => $order->get_id(),
     262                'accessOrderId' => $order->get_meta('custom_order_number'),
     263                'currency' => $order->get_currency(),
     264                'amount' => $order->get_total(),
     265                'language' =>substr(get_locale(), 0, 2),
     266                //'payPageStyle' => 'DEFAULT',
     267                'email' =>  $order->get_billing_email(),
     268                'returnUrl' => WC()->api_request_url('allinpay_front_payment_callback'),
     269                'notifyUrl' =>  WC()->api_request_url('allinpay_payment_callback'),
     270                //'timeZone' //持卡人时区,可选
     271
     272                'signType' => 'RSA2',//签名类型
     273                //'txnTitle' => $order->get_title(),
     274                //'txnDetail' => $order->get_title(),
     275
     276
     277                'shippingFirstName' => !empty($order->get_shipping_first_name()) ? $order->get_shipping_first_name():$order->get_billing_first_name(),
     278                //'shippingFirstName' => $order->get_shipping_first_name(),
     279                'shippingLastName' => !empty($order->get_shipping_last_name()) ? $order->get_shipping_last_name():$order->get_billing_last_name(),
     280                'shippingAddress1' => !empty($order->get_shipping_address_1())? $order->get_shipping_address_1():$order->get_billing_address_1(),
     281                //'shippingAddress2' => $order->get_shipping_address_2(), //可选
     282                'shippingCity' => !empty($order->get_shipping_city())? $order->get_shipping_city():$order->get_billing_city(),
     283                //'shippingState'=> $order->get_shipping_state(),
     284                'shippingState'=>!empty($order->get_shipping_state()) ? $order->get_shipping_state() :( !empty($order->get_shipping_city())?$order->get_shipping_city():$order->get_billing_city()),
     285                'shippingCountry'=>!empty($order->get_shipping_country())?$order->get_shipping_country():$order->get_billing_country(),
     286                'shippingZipCode' => !empty($order->get_shipping_postcode())?$order->get_shipping_postcode():$order->get_billing_postcode(),
     287                'shippingPhone' => $order->get_billing_phone(),
     288
     289                'billingFirstName' => $order->get_billing_first_name(),
     290                'billingLastName' => $order->get_billing_last_name(),
     291                'billingAddress1' => $order->get_billing_address_1(),
     292                //'billingAddress2' => $order->get_billing_address_2(),
     293                'billingCity' => $order->get_billing_city(),
     294                'billingState' => $order->get_billing_state(),
     295                'billingCountry' => $order->get_billing_country(),
     296                'billingZipCode' => $order->get_billing_postcode(),
     297                'billingPhone' => $order->get_billing_phone());
    298298            $productInfo =  '[' . implode(',', $weldpay_items) . ']';
    299299            $payment_data['productInfo'] = $productInfo;
     
    314314            }
    315315            return array(
    316                     'result' => 'success',
    317                     'redirect' => $parseJson['payUrl']
    318                     );
     316                'result' => 'success',
     317                'redirect' => $parseJson['payUrl']
     318            );
    319319        }
    320320        // 将 iframe 插入页面,没啥用
     
    337337            }
    338338            $payment_data = array(
    339                     'version' => $this->version,
    340                     'mchtId' => $this->merchant_id,
    341                     'transType' => 'Refund',
    342                     'accessOrderId' => $refundOrderId,
    343                     'refundAmount' => $amount,
    344                     'oriAccessOrderId'=> $platId,
    345                     'signType' => 'RAS2'
    346                     );
     339                'version' => $this->version,
     340                'mchtId' => $this->merchant_id,
     341                'transType' => 'Refund',
     342                'accessOrderId' => $refundOrderId,
     343                'refundAmount' => $amount,
     344                'oriAccessOrderId'=> $platId,
     345                'signType' => 'RAS2'
     346            );
    347347
    348348            $signature = $this->generate_signature($payment_data);
     
    385385            $paramsStr = $this->toUrlParams($array, true);
    386386            $args = array(
    387                     'body' => $paramsStr,
    388                     'timeout' => '30',
    389                     'redirection' => '30',
    390                     'headers' =>array(
    391                         'content-type'=> 'application/x-www-form-urlencoded;charset=utf-8'
    392                         )
    393                      );
     387                'body' => $paramsStr,
     388                'timeout' => '30',
     389                'redirection' => '30',
     390                'headers' =>array(
     391                    'content-type'=> 'application/x-www-form-urlencoded;charset=utf-8'
     392                )
     393            );
    394394            $this->allinpay_log("发送到渠道的请求参数为:".$paramsStr);
    395395            $response = wp_remote_post($url,$args);
     
    427427        //异步通知
    428428        function allinpay_payment_callback() {
    429             if(!isset($_POST['resultCode'])){
    430                 $this->allinpay_log('后台接口通知返回参数异常,resultCode为空!!!');
     429            if (empty($_POST)) {
     430                $this->allinpay_log('后台通知返回参数为空');
    431431                return;
    432432            }
    433             $resultCode = wc_clean($_POST['resultCode']);
    434             $resultDesc = wc_clean($_POST['resultDesc']);
    435             //get json request notify from snappay
    436             $customerNo = null;
    437             $order_id = null;
    438             if(isset($_POST['accessOrderId'])){
    439                 $customerNo =wc_clean($_POST['accessOrderId']);
    440                 if (strlen($customerNo) >= 14) {
    441                     $order_id = substr($customerNo, 14);
    442                 } else {
    443                     wp_die();
    444                 }
    445             }
     433            // 获取所有POST参数并过滤
     434            $params = array_map('wc_clean', $_POST);
     435            $signature = $params['sign'] ?? '';
     436            if (empty($signature)) {
     437                $this->allinpay_log('回调参数中缺少签名字段');
     438                return;
     439            }
     440
     441            // 检查必填参数
     442            if (empty($params['resultCode']) || empty($params['accessOrderId'])) {
     443                $this->allinpay_log('回调参数中缺少必填字段: resultCode或accessOrderId');
     444                echo 'SUCCESS';
     445                wp_die();
     446            }
     447
     448            $customerNo = $params['accessOrderId'];
     449            $order_id = (strlen($customerNo) >= 14) ? substr($customerNo, 14) : null;
     450            if (!$order_id) {
     451                $this->allinpay_log("无效的订单号格式: $customerNo");
     452                echo 'SUCCESS';
     453                wp_die();
     454            }
     455
    446456            $order = wc_get_order($order_id);
    447             if($order==null || 'completed'==$order->get_status()){
    448                 wp_die();
    449             }
    450             $notifyArray = array(
    451                     'resultCode'=> $resultCode,
    452                     'resultDesc' => $resultDesc,
    453                     'instNo' => wc_clean($_POST['instNo']),
    454                     'mchtId' => wc_clean($_POST['mchtId']),
    455                     'accessOrderId' => $customerNo,
    456                     'orderId' => wc_clean($_POST['orderId']),
    457                     'cardNo' => wc_clean($_POST['cardNo']),
    458                     'currency' => wc_clean($_POST['currency']),
    459                     'amount' => wc_clean($_POST['amount']),
    460                     'signType' => wc_clean($_POST['signType']),
    461                     'payMethod' => wc_clean($_POST['payMethod']),
    462                     );
    463             if(isset($_POST['payMethod'])){
    464                 $notifyArray['payMethod'] = wc_clean($_POST['payMethod']);
    465             }
    466             if(isset($_POST['cardOrgn'])){
    467                 $notifyArray['cardOrgn'] =wc_clean($_POST['cardOrgn']);
    468             }
    469             if(isset($_POST['localCurrency'])){
    470                 $notifyArray['localCurrency'] =wc_clean($_POST['localCurrency']);
    471             }
    472             if(isset($_POST['localAmount'])){
    473                 $notifyArray['localAmount'] =wc_clean($_POST['localAmount']);
    474             }
    475             if(isset($_POST['transTime'])){
    476                 $notifyArray['transTime'] =wc_clean($_POST['transTime']);
    477             }
    478             $signature = $_POST['sign'];
    479             ksort($notifyArray);
    480             $signStr = $this->toUrlParams($notifyArray,false);
     457            if (!$order || $order->get_status() === 'completed') {
     458                echo 'SUCCESS';
     459                wp_die();
     460            }
     461
     462            // 删除不需要参与签名的字段
     463            unset(
     464                $params['sign'],
     465                $params['wc-api']
     466            );
     467
     468            // 构建签名串
     469            ksort($params);
     470            $signStr = $this->toUrlParams($params,false);
    481471            $signResult = $this->verify_signature($signStr,$signature);
    482472            if(!$signResult){
     
    494484                $order->payment_complete($transaction_id);
    495485                $custom_data = array(
    496                         'localCurrency' => $notifyArray['localCurrency'],
    497                         'localAmount' => $notifyArray['localAmount']
    498                         );
     486                    'localCurrency' => $notifyArray['localCurrency'],
     487                    'localAmount' => $notifyArray['localAmount']
     488                );
    499489
    500490                foreach ($custom_data as $key => $value) {
     
    507497            } else {
    508498                $custom_data = array(
    509                         'resultCode' => $notifyArray['resultCode'],
    510                         'resultDesc' => $notifyArray['resultDesc']
    511                         );
     499                    'resultCode' => $notifyArray['resultCode'],
     500                    'resultDesc' => $notifyArray['resultDesc']
     501                );
    512502
    513503                foreach ($custom_data as $key => $value) {
     
    578568    }
    579569
    580    
    581         function custom_payment_descriptions($description, $payment_id) {
    582             switch ($payment_id) {
    583                 case 'allinpay_intl':
    584                     $description .= '<p>This is the description for allInPay.</p>';
    585                     break;
    586                 // Add descriptions for other payment methods as needed
    587                 default:
    588                     break;
    589             }
    590             return $description;
    591         }
     570
     571    function custom_payment_descriptions($description, $payment_id) {
     572        switch ($payment_id) {
     573        case 'allinpay_intl':
     574            $description .= '<p>This is the description for allInPay.</p>';
     575            break;
     576            // Add descriptions for other payment methods as needed
     577        default:
     578            break;
     579        }
     580        return $description;
     581    }
    592582
    593583    function allinpay_woocommerce_order_number($order_number, $order)
  • allinpayintl/trunk/readme.txt

    r3213666 r3336276  
    55Tested up to: 6.3
    66Requires PHP: 7.4
    7 Stable tag: 1.1.2
     7Stable tag: 1.1.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4141= 1.1.2 =
    4242fix some bugs.
     43= 1.1.3 =
     44Compatible with the latest version of the API.
    4345FAQ:
    4446
Note: See TracChangeset for help on using the changeset viewer.