HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: 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
Upload Files
File: /www/wwwroot/bs.kntsleep.com/system/basic/class/alipay.class.php
<?php
/*
 * Copyright (c) Huyin Information Technology Co., Ltd. All Rights Reserved.
 * BOSSCMS Content Management System (https://www.bosscms.net/)
 */
defined('IS_OK') or exit('Access Forbidden');

class alipay
{
	public static $config = array();

	public static function init()
	{
		global $G;
		self::$config = array(
			'app_id' => $G['config']['pay3_api_id'],
			'merchant_private_key' => $G['config']['pay3_private_key'],
			'alipay_public_key' => $G['config']['pay3_public_key'],
			'gatewayUrl' => 'https://openapi.alipay.com/gateway.do',
			'sign_type'=>'RSA2',
			'charset' => 'UTF-8'
		);
	}

	public static function pay($data, $info=null, $output=true)
	{
		global $G;
		if($G['config']['pay3_open']){
			if(!isset($info)){
				if(isMobile()){
					$info = 'wap';
				}else{
					$info = 'pc';
				}
			}
			if($info == 'wap'){
				if(is_file($file = ROOT_PATH.'system/extend/alipay/wappay/service/AlipayTradeService.php')){
					require_once $file;
					require_once ROOT_PATH.'system/extend/alipay/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php';
					$payRequestBuilder = new AlipayTradeWapPayContentBuilder();
					$payRequestBuilder->setBody($data['text']); //订单名称,必填
					$payRequestBuilder->setSubject($data['name']); //商品描述,可空
					$payRequestBuilder->setTotalAmount($data['price']); //付款金额,必填
					$payRequestBuilder->setOutTradeNo($data['num']); //商户订单号,商户网站订单系统中唯一订单号,必填
					$payRequestBuilder->setTimeExpress($data['etime']); //订单过期
					self::$config['notify_url'] = $data['mobile_notify_url'];
					self::$config['return_url'] = $data['mobile_return_url'];
					$aop = new AlipayTradeService(self::$config);
					$res = $aop->wapPay($payRequestBuilder,self::$config['return_url'],self::$config['notify_url']);
					if($output){
						echo $res;
					}else{
						return array('info'=>'wap','html'=>$res);
					}
				}
			}else if($info == 'pc'){
				if(is_file($file = ROOT_PATH.'system/extend/alipay/pagepay/service/AlipayTradeService.php')){
					require_once $file;
					require_once ROOT_PATH.'system/extend/alipay/pagepay/buildermodel/AlipayTradePagePayContentBuilder.php';
					$payRequestBuilder = new AlipayTradePagePayContentBuilder();
					$payRequestBuilder->setBody($data['text']); //订单名称,必填
					$payRequestBuilder->setSubject($data['name']); //商品描述,可空
					$payRequestBuilder->setTotalAmount($data['price']); //付款金额,必填
					$payRequestBuilder->setOutTradeNo($data['num']); //商户订单号,商户网站订单系统中唯一订单号,必填
					$payRequestBuilder->setTimeExpress($data['etime']); //订单过期
					self::$config['notify_url'] = $data['pc_notify_url'];
					self::$config['return_url'] = $data['pc_return_url'];
					$aop = new AlipayTradeService(self::$config);
					$res = $aop->pagePay($payRequestBuilder,self::$config['return_url'],self::$config['notify_url']);
					if($output){
						echo $res;
					}else{
						return array('info'=>'pc','html'=>$res);
					}
				}
			}
		}
	}

	public static function receive($notify=true, $mobile=false)
	{
		global $G;
		if($G['config']['pay3_open']){
			if(is_file($file = ROOT_PATH.'system/extend/alipay/'.($mobile?'wappay':'pagepay').'/service/AlipayTradeService.php')){
				require_once $file;
				$alipaySevice = new AlipayTradeService(self::$config);
				if($alipaySevice->check($notify?$_POST:$_GET)){
					if($notify){
						if($G['post']['app_id']==self::$config['app_id'] && preg_match('/^(TRADE_SUCCESS|TRADE_FINISHED)$/',$G['post']['trade_status'])){
							return array(
								'notify' => true,
								'price' => $G['post']['total_amount'],
								'num' => $G['post']['out_trade_no'],
								'no' => $G['post']['trade_no']
							);
							echo 'success';
						}
					}else{
						if($G['get']['app_id']==self::$config['app_id']){
							return array(
								'notify' => false,
								'price' => $G['get']['total_amount'],
								'num' => $G['get']['out_trade_no'],
								'no' => $G['get']['trade_no']
							);
						}
					}
				}
			}
		}
	}
}

/* PHP8.0+ 补充函数 */
if(!function_exists('each')){
    function each(&$array){
       $res = array();
       $key = key($array);
       if($key !== null){
           next($array); 
           $res[1] = $res['value'] = $array[$key];
           $res[0] = $res['key'] = $key;
       }else{
           $res = false;
       }
       return $res;
    }
}
?>