| Server IP : 43.141.49.119 / 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 : |
<?php
namespace WPCOM\Member\Payments;
use WPCOM\Member\Order;
defined( 'ABSPATH' ) || exit;
class YZF_Alipay extends Payment {
private $_config;
public $type;
public function __construct() {
$this->id = 'alipay-yzf';
$this->title = '支付宝';
$this->icon = WPCOM_MP_URI . 'payment/alipay/alipay.svg';
$this->color = '#1677ff';
$this->type = 'alipay';
$this->init_hook();
}
function init_hook(){
parent::__construct();
}
public function init($index){
$mchid = wpcom_mp_options('wxpay_mchid');
$key = wpcom_mp_options('wxpay_key');
$tranasction_url = wpcom_mp_options('pay_tranasction_url');
$this->_config = [
'pid' => $mchid && isset($mchid[$index]) ? trim($mchid[$index]) : '',
'secret' => $key && isset($key[$index]) ? trim($key[$index]) : '',
'api' => $tranasction_url && isset($tranasction_url[$index]) && $tranasction_url[$index] ? untrailingslashit(trim($tranasction_url[$index])) : '',
];
}
public function process_payment($order_id) {
$url = Order::get_checkout_payment_url($order_id);
return [
'result' => 'success',
'redirect' => $url
];
}
public function receipt_page($order_id) {
$order = Order::get_order($order_id);
if (!$order || $order->status === 'paid') return;
$total_amount = round($order->price, 2);
$data = [
'pid' => $this->_config['pid'],
'type' => $this->type,
'out_trade_no' => $order->number,
'notify_url' => Order::get_checkout_notify_url($order_id, $this->id),
'return_url' => Order::get_checkout_return_url($order->ID, $this->id),
'name' => $this->get_order_title($order),
'money' => $total_amount,
];
$data['sign'] = $this->sign($data, $this->_config['secret']);
$data['sign_type'] = 'MD5'; ?>
<div class="loading-img"></div>
<p class="loading-text">正在转入支付平台...</p>
<div class="wpcom-pay-html" style="display: none;">
<form id="dopay" action="<?php echo esc_url($this->_config['api'] . '/submit.php');?>" method="post">
<?php foreach ($data as $k => $v) { ?>
<input type="hidden" name="<?php echo $k;?>" value="<?php echo $v;?>" />
<?php } ?>
<input type="submit" value="提交"></form>
<script>document.getElementById("dopay").submit();</script>
</div>
<?php }
public function check_response($order_id) {
if(!is_numeric($order_id)) return ;
$data = $_GET;
unset($data['action']);
unset($data['order_id']);
unset($data['api']);
self::add_log('#'.$data['out_trade_no'].' 易支付异步通知数据:' . wp_json_encode($data), $this->id);
if ($this->sign($data, $this->_config['secret']) === $_GET['sign']) {
self::add_log('#'.$data['out_trade_no'].' 易支付异步通知验证成功', $this->id);
echo "success";
$order = Order::get_order( $order_id );
if(isset($data['trade_status']) && $data['trade_status'] === 'TRADE_SUCCESS' && $order && $order->number && $order->number == $data['out_trade_no'] && $order->status === 'unpaid'){ // 判断订单号,以及支付状态
Order::payment_complete( $order->ID, $this->id);
self::add_log('#'.$data['out_trade_no'].' 订单支付完成!', $this->id);
}
} else {
echo "error sign";
return false;
}
}
private function sign($param, $app_secret){
ksort($param);
reset($param);
$signstr = '';
foreach($param as $k => $v){
if($k != "sign" && $k != "sign_type" && $v!=''){
$signstr .= $k.'='.$v.'&';
}
}
$signstr = substr($signstr,0,-1);
$signstr .= $app_secret;
$sign = md5($signstr);
return $sign;
}
}
class YZF_WXpay extends YZF_Alipay {
public function __construct() {
$this->id = 'wxpay-yzf';
$this->title = '微信支付';
$this->icon = WPCOM_MP_URI . 'payment/wxpay/wxpay.svg';
$this->color = '#2bae67';
$this->type = 'wxpay';
parent::init_hook();
}
}
new YZF_Alipay();
new YZF_WXpay();