403Webshell
Server IP : 43.141.49.107  /  Your IP : 113.219.202.44
Web Server : Apache
System : Linux VM-8-5-opencloudos 6.6.34-9.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 19 19:35:45 CST 2024 x86_64
User : www ( 1000)
PHP Version : 8.1.27
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/wwwroot/www.ucppt.com/wp-content/plugins/wpcom-member-pro/payment/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/www.ucppt.com/wp-content/plugins/wpcom-member-pro/payment/alipay.php
<?php
namespace WPCOM\Member\Payments;
use WPCOM\Member\Order;

defined('ABSPATH') || exit;

class Alipay extends Payment {
    private $_config;
    private $is_f2fpay;
    public function __construct() {
        $this->id = 'alipay';
        $this->title = '支付宝';
        $this->icon = WPCOM_MP_URI . 'payment/alipay/alipay.svg';
        $this->color = '#1677ff';
        $this->_config = [];

        add_action('wp_ajax_WPCOM_Alipay_order_status', [$this, 'order_status']);
        add_action('wp_ajax_nopriv_WPCOM_Alipay_order_status', [$this, 'order_status']);

        parent::__construct();
    }

    public function init($index){
        $appid = wpcom_mp_options('alipay_appid');
        $private_key = wpcom_mp_options('alipay_private_key');
        $public_key = wpcom_mp_options('alipay_public_key');
        $f2fpay = wpcom_mp_options('alipay_f2fpay');
        $this->is_f2fpay = $f2fpay && $f2fpay[$index] && $f2fpay[$index] == '1';
        $this->modal = $this->is_f2fpay; // 当面付使用弹框
        $this->_config = [
            'app_id' => $appid && isset($appid[$index]) ? trim($appid[$index]) : '',
            'merchant_private_key' => $private_key && isset($private_key[$index]) ? trim($private_key[$index]) : '',
            'alipay_public_key' => $public_key && isset($public_key[$index]) ? trim($public_key[$index]) : '',
        ];
    }

    public function process_payment($order_id) {
        $url = Order::get_checkout_payment_url($order_id);
        if($this->is_f2fpay){
            return [
                'result' => 'success',
                'redirect' =>  $url,
                'height' => '472px',
                'modal-size' => 'modal-sm'
            ];
        }else{
            return [
                'result' => 'success',
                'redirect' =>  $url
            ];
        }
    }

    private function config($order_id) {
        $config = $this->_config + [
            //异步通知地址
            'notify_url' => Order::get_checkout_notify_url($order_id, $this->id),
            //同步跳转
            'return_url' => Order::get_checkout_return_url($order_id, $this->id),
            //编码格式
            'charset' => "UTF-8",
            //签名方式
            'sign_type' => "RSA2",
            //支付宝网关
            'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
            //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
        ];
        return $config;
    }

    public function order_status() {
        apply_filters('wpcom_payment_gateways', []);
        $order_id = isset($_POST['order_id']) && $_POST['order_id'] ? $_POST['order_id'] : '';
        $nonce = isset($_POST['nonce']) && $_POST['nonce'] ? $_POST['nonce'] : '';
        if($this->is_f2fpay && $nonce && wp_verify_nonce($nonce, 'wpcom_alipay_receipt_page')){
            $order = $order_id ? Order::get_order($order_id) : '';
            $user_id = get_current_user_id();
            if ($order && isset($order->ID) && (!$order->user || ((int) $order->user === $user_id)) && $order->status === 'paid') {
                $res = [
                    'redirect' => Order::get_checkout_return_url($order->ID, $this->id),
                    'status' => 'paid'
                ];
                wp_send_json($res);
            }
        }
    }

    public function receipt_page($order_id) {
        $order = Order::get_order($order_id);
        if (!$order || $order->status === 'paid') return;

        if($this->is_f2fpay){
            include_once WPCOM_MP_DIR . 'payment/alipay/f2fpay/service/AlipayTradeService.php';
            include_once WPCOM_MP_DIR . 'payment/alipay/f2fpay/model/builder/AlipayTradePrecreateContentBuilder.php';
            $payRequestBuilder = new \AlipayTradePrecreateContentBuilder();
            self::add_log('#'.$order_id.'发起支付宝支付:当面付', $this->id);
        }else if ($this->is_mobile()) {
            include_once WPCOM_MP_DIR . 'payment/alipay/wappay/service/AlipayTradeService.php';
            include_once WPCOM_MP_DIR . 'payment/alipay/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php';
            $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
            self::add_log('#'.$order_id.'发起支付宝支付:手机网站支付', $this->id);
        } else {
            include_once WPCOM_MP_DIR . 'payment/alipay/pagepay/service/AlipayTradeService.php';
            include_once WPCOM_MP_DIR . 'payment/alipay/pagepay/buildermodel/AlipayTradePagePayContentBuilder.php';
            $payRequestBuilder = new \AlipayTradePagePayContentBuilder();
            self::add_log('#'.$order_id.'发起支付宝支付:电脑网站支付', $this->id);
        }

        //构造参数
        $total = $order->price;
        $payRequestBuilder->setBody($this->get_order_title($order));
        $payRequestBuilder->setSubject($this->get_order_title($order));
        $payRequestBuilder->setTotalAmount($total);
        $payRequestBuilder->setOutTradeNo($order->number);
        if ($this->is_mobile() || $this->is_f2fpay) {
            $payRequestBuilder->setTimeExpress('30m');
        }

        $config = $this->config($order_id);
        $aop = new \AlipayTradeService($config);

        if($this->is_f2fpay){
            try{
                $qrPayResult = $aop->qrPay($payRequestBuilder);
                $response = $qrPayResult->getResponse();
                $qrcode = '';
                if($qrPayResult->getTradeStatus() === 'SUCCESS' && isset($response->qr_code) && $response->qr_code){
                    $qrcode = $response->qr_code;
                }else if(isset($response->trade_status) && $response->trade_status == 'TRADE_CLOSED'){
                    if(Order::update_order_number($order_id)){
                        self::add_log('#'.$order_id.' 当面付订单关闭,更新订单号并重新发起支付', $this->id);
                        $this->receipt_page($order_id);
                        return false;
                    }else{
                        $response->code = 'TRADE_CLOSED';
                        $response->msg = '订单异常,请关闭订单重新发起支付';
                    }
                }
            }catch (\Exception $e){
                $response = new \stdClass;
                $response->code = $e->getCode();
                $response->msg = $e->getMessage();
            }

            if(isset($qrcode) && $qrcode){ ?>
                <div class="wpcom-wxpay-inner">
                    <div id="j-wpcom-alipay" class="wpcom-wxpay-img" data-url="<?php echo $qrcode; ?>" data-order="<?php echo $order_id; ?>"></div>
                    <p class="wpcom-wxpay-note" style="line-height:2;font-size: 16px;color: #333;">使用支付宝扫描二维码进行支付</p>
                </div>
                <script src="<?php echo includes_url('js/jquery/jquery.min.js'); ?>"></script>
                <script src="<?php echo WPCOM_MP_URI . 'js/pay.js'; ?>"></script>
                <script> _ajax_url = "<?php echo admin_url( 'admin-ajax.php');?>"; _nonce = "<?php echo wp_create_nonce('wpcom_alipay_receipt_page');?>"; </script>
            <?php }else{ ?>
                <div class="text-center" style="margin-bottom: 30px;color:#f66;">
                    <span style="color:red;">错误代码:<?php echo $response->code ?>; 错误信息:<?php echo $response->msg; if(isset($response->sub_msg)) echo  ':'. $response->sub_msg ?></span>
                </div>
            <?php }
        }else{ ?>
            <div class="loading-img"></div>
            <p class="loading-text">正在转入支付平台...</p>
            <div class="wpcom-alipay-html">
                <?php if ($this->is_mobile()) {
                    $aop->wapPay($payRequestBuilder, $config['return_url'], $config['notify_url']);
                } else {
                    $aop->pagePay($payRequestBuilder, $config['return_url'], $config['notify_url']);
                } ?>
            </div>
        <?php }
    }

    public function check_response($order_id) {
        if(!is_numeric($order_id)) return ;

        require_once WPCOM_MP_DIR . 'payment/alipay/pagepay/service/AlipayTradeService.php';

        self::add_log('#支付宝异步通知数据:' . wp_json_encode($_POST), $this->id);
        if(!isset($_POST['out_trade_no']))  exit;
        $arr = $_POST;
        $arr['fund_bill_list'] = stripslashes($arr['fund_bill_list']);
        $config = $this->config($order_id);
        $alipaySevice = new \AlipayTradeService($config);
        $result = $alipaySevice->check($arr);

        self::add_log('#'.$arr['out_trade_no'].' 支付宝异步通知:' . $result . ';通知数据:' . wp_json_encode($arr), $this->id);
        self::add_log('#'.$arr['out_trade_no'].' 支付宝通知验证:' . ($result && $arr['app_id'] == $config['app_id']), $this->id);
        if( $result && $arr['app_id'] == $config['app_id'] ){
            $trade_status = $arr['trade_status'];
            if($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') {
                self::add_log('#'.$arr['out_trade_no'].' 支付宝异步通知验证成功:' . $trade_status .';支付宝订单:' . $arr['trade_no'], $this->id);
                $order = Order::get_order( $order_id );
                if($order && $order->number && $order->number == $arr['out_trade_no'] && $order->status === 'unpaid'){ // 判断订单号,以及支付状态
                    Order::payment_complete( $order->ID,  $this->id);
                    self::add_log('#'.$arr['out_trade_no'].' 订单支付完成!', $this->id);
                }
            }
            echo "success";
        }else{
            echo "fail";
        }
        exit;
    }
}

new Alipay();

Youez - 2016 - github.com/yon3zu
LinuXploit