2020.02新版
This commit is contained in:
1
plugins/.htaccess
Normal file
1
plugins/.htaccess
Normal file
@@ -0,0 +1 @@
|
||||
deny from all
|
||||
21
plugins/aliold/config.ini
Normal file
21
plugins/aliold/config.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
[config]
|
||||
;支付插件英文名称,需和目录名称一致,不能有重复
|
||||
name = "aliold"
|
||||
|
||||
;支付插件显示名称
|
||||
showname = "支付宝旧版接口"
|
||||
|
||||
;支付插件作者
|
||||
author = "支付宝"
|
||||
|
||||
;支付插件作者链接
|
||||
link = "https://b.alipay.com/signing/productSetV2.htm"
|
||||
|
||||
;支付插件支持的支付方式,多种方式用英文,隔开,可选的有alipay,qqpay,wxpay,bank
|
||||
types = "alipay"
|
||||
|
||||
;支付插件要求传入的参数以及参数显示名称,可选的有appid,appkey,appsecret,appurl,appmchid
|
||||
inputs = "appid:合作者身份(PID),appkey:安全校验码(Key)"
|
||||
|
||||
;支付插件要求传入的支付方式参数
|
||||
select = "1:电脑网站支付,2:手机网站支付"
|
||||
44
plugins/aliold/inc/alipay.config.php
Normal file
44
plugins/aliold/inc/alipay.config.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/* *
|
||||
* 配置文件
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-19
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
|
||||
* 提示:如何获取安全校验码和合作身份者id
|
||||
* 1.用您的签约支付宝账号登录支付宝网站(www.alipay.com)
|
||||
* 2.点击“商家服务”(https://b.alipay.com/order/myorder.htm)
|
||||
* 3.点击“查询合作者身份(pid)”、“查询安全校验码(key)”
|
||||
|
||||
* 安全校验码查看时,输入支付密码后,页面呈灰色的现象,怎么办?
|
||||
* 解决方法:
|
||||
* 1、检查浏览器配置,不让浏览器做弹框屏蔽设置
|
||||
* 2、更换浏览器或电脑,重新登录查询。
|
||||
*/
|
||||
|
||||
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||
//合作身份者id,以2088开头的16位纯数字
|
||||
$alipay_config['partner'] = $channel['appid'];
|
||||
|
||||
//安全检验码,以数字和字母组成的32位字符
|
||||
$alipay_config['key'] = $channel['appkey'];
|
||||
|
||||
|
||||
//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
||||
|
||||
|
||||
//签名方式 不需修改
|
||||
$alipay_config['sign_type'] = strtoupper('MD5');
|
||||
|
||||
//字符编码格式 目前支持 gbk 或 utf-8
|
||||
$alipay_config['input_charset']= strtolower('utf-8');
|
||||
|
||||
//ca证书路径地址,用于curl中ssl校验
|
||||
//请保证cacert.pem文件在当前文件夹目录中
|
||||
$alipay_config['cacert'] = getcwd().'\\cacert.pem';
|
||||
|
||||
//访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
|
||||
$alipay_config['transport'] = 'https';
|
||||
?>
|
||||
168
plugins/aliold/inc/alipay_core.function.php
Normal file
168
plugins/aliold/inc/alipay_core.function.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/* *
|
||||
* 支付宝接口公用函数
|
||||
* 详细:该类是请求、通知返回两个文件所调用的公用函数核心处理文件
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-19
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
* @param $para 需要拼接的数组
|
||||
* return 拼接完成以后的字符串
|
||||
*/
|
||||
function createLinkstring($para) {
|
||||
$arg = "";
|
||||
foreach ($para as $key=>$val) {
|
||||
$arg.=$key."=".$val."&";
|
||||
}
|
||||
//去掉最后一个&字符
|
||||
$arg = substr($arg,0,-1);
|
||||
|
||||
return $arg;
|
||||
}
|
||||
/**
|
||||
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
|
||||
* @param $para 需要拼接的数组
|
||||
* return 拼接完成以后的字符串
|
||||
*/
|
||||
function createLinkstringUrlencode($para) {
|
||||
$arg = "";
|
||||
foreach ($para as $key=>$val) {
|
||||
$arg.=$key."=".urlencode($val)."&";
|
||||
}
|
||||
//去掉最后一个&字符
|
||||
$arg = substr($arg,0,-1);
|
||||
|
||||
return $arg;
|
||||
}
|
||||
/**
|
||||
* 除去数组中的空值和签名参数
|
||||
* @param $para 签名参数组
|
||||
* return 去掉空值与签名参数后的新签名参数组
|
||||
*/
|
||||
function paraFilter($para) {
|
||||
$para_filter = array();
|
||||
foreach ($para as $key=>$val) {
|
||||
if($key == "sign" || $key == "sign_type" || $val == "")continue;
|
||||
else $para_filter[$key] = $para[$key];
|
||||
}
|
||||
return $para_filter;
|
||||
}
|
||||
/**
|
||||
* 对数组排序
|
||||
* @param $para 排序前的数组
|
||||
* return 排序后的数组
|
||||
*/
|
||||
function argSort($para) {
|
||||
ksort($para);
|
||||
reset($para);
|
||||
return $para;
|
||||
}
|
||||
/**
|
||||
* 写日志,方便测试(看网站需求,也可以改成把记录存入数据库)
|
||||
* 注意:服务器需要开通fopen配置
|
||||
* @param $word 要写入日志里的文本内容 默认值:空值
|
||||
*/
|
||||
function logResult($word='') {
|
||||
$fp = fopen("log.txt","a");
|
||||
flock($fp, LOCK_EX) ;
|
||||
fwrite($fp,"执行日期:".strftime("%Y%m%d%H%M%S",time())."\n".$word."\n");
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取数据,POST模式
|
||||
* 注意:
|
||||
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了
|
||||
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem'
|
||||
* @param $url 指定URL完整路径地址
|
||||
* @param $cacert_url 指定当前工作目录绝对路径
|
||||
* @param $para 请求的数据
|
||||
* @param $input_charset 编码格式。默认值:空值
|
||||
* return 远程输出的数据
|
||||
*/
|
||||
function getHttpResponsePOST($url, $cacert_url, $para, $input_charset = '') {
|
||||
|
||||
if (trim($input_charset) != '') {
|
||||
$url = $url."_input_charset=".$input_charset;
|
||||
}
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//SSL证书认证
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);//严格认证
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
|
||||
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
|
||||
curl_setopt($curl,CURLOPT_POST,true); // post传输数据
|
||||
curl_setopt($curl,CURLOPT_POSTFIELDS,$para);// post传输数据
|
||||
$responseText = curl_exec($curl);
|
||||
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容
|
||||
curl_close($curl);
|
||||
|
||||
return $responseText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取数据,GET模式
|
||||
* 注意:
|
||||
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了
|
||||
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem'
|
||||
* @param $url 指定URL完整路径地址
|
||||
* @param $cacert_url 指定当前工作目录绝对路径
|
||||
* return 远程输出的数据
|
||||
*/
|
||||
function getHttpResponseGET($url,$cacert_url) {
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
|
||||
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//SSL证书认证
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);//严格认证
|
||||
$responseText = curl_exec($curl);
|
||||
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容
|
||||
curl_close($curl);
|
||||
|
||||
return $responseText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现多种字符编码方式
|
||||
* @param $input 需要编码的字符串
|
||||
* @param $_output_charset 输出的编码格式
|
||||
* @param $_input_charset 输入的编码格式
|
||||
* return 编码后的字符串
|
||||
*/
|
||||
function charsetEncode($input,$_output_charset ,$_input_charset) {
|
||||
$output = "";
|
||||
if(!isset($_output_charset) )$_output_charset = $_input_charset;
|
||||
if($_input_charset == $_output_charset || $input ==null ) {
|
||||
$output = $input;
|
||||
} elseif (function_exists("mb_convert_encoding")) {
|
||||
$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
|
||||
} elseif(function_exists("iconv")) {
|
||||
$output = iconv($_input_charset,$_output_charset,$input);
|
||||
} else die("sorry, you have no libs support for charset change.");
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* 实现多种字符解码方式
|
||||
* @param $input 需要解码的字符串
|
||||
* @param $_output_charset 输出的解码格式
|
||||
* @param $_input_charset 输入的解码格式
|
||||
* return 解码后的字符串
|
||||
*/
|
||||
function charsetDecode($input,$_input_charset ,$_output_charset) {
|
||||
$output = "";
|
||||
if(!isset($_input_charset) )$_input_charset = $_input_charset ;
|
||||
if($_input_charset == $_output_charset || $input ==null ) {
|
||||
$output = $input;
|
||||
} elseif (function_exists("mb_convert_encoding")) {
|
||||
$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
|
||||
} elseif(function_exists("iconv")) {
|
||||
$output = iconv($_input_charset,$_output_charset,$input);
|
||||
} else die("sorry, you have no libs support for charset changes.");
|
||||
return $output;
|
||||
}
|
||||
?>
|
||||
41
plugins/aliold/inc/alipay_md5.function.php
Normal file
41
plugins/aliold/inc/alipay_md5.function.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/* *
|
||||
* MD5
|
||||
* 详细:MD5加密
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-19
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 签名字符串
|
||||
* @param $prestr 需要签名的字符串
|
||||
* @param $key 私钥
|
||||
* return 签名结果
|
||||
*/
|
||||
function md5Sign($prestr, $key) {
|
||||
$prestr = $prestr . $key;
|
||||
return md5($prestr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证签名
|
||||
* @param $prestr 需要签名的字符串
|
||||
* @param $sign 签名结果
|
||||
* @param $key 私钥
|
||||
* return 签名结果
|
||||
*/
|
||||
function md5Verify($prestr, $sign, $key) {
|
||||
$prestr = $prestr . $key;
|
||||
$mysgin = md5($prestr);
|
||||
|
||||
if($mysgin == $sign) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
139
plugins/aliold/inc/alipay_notify.class.php
Normal file
139
plugins/aliold/inc/alipay_notify.class.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/* *
|
||||
* 类名:AlipayNotify
|
||||
* 功能:支付宝通知处理类
|
||||
* 详细:处理支付宝各接口通知返回
|
||||
* 版本:3.2
|
||||
* 日期:2011-03-25
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考
|
||||
|
||||
*************************注意*************************
|
||||
* 调试通知返回时,可查看或改写log日志的写入TXT里的数据,来检查通知返回是否正常
|
||||
*/
|
||||
|
||||
require_once(PAY_ROOT."inc/alipay_core.function.php");
|
||||
require_once(PAY_ROOT."inc/alipay_md5.function.php");
|
||||
|
||||
class AlipayNotify {
|
||||
/**
|
||||
* HTTPS形式消息验证地址
|
||||
*/
|
||||
var $https_verify_url = 'https://mapi.alipay.com/gateway.do?service=notify_verify&';
|
||||
/**
|
||||
* HTTP形式消息验证地址
|
||||
*/
|
||||
var $http_verify_url = 'http://notify.alipay.com/trade/notify_query.do?';
|
||||
var $alipay_config;
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->alipay_config = $alipay_config;
|
||||
}
|
||||
function AlipayNotify($alipay_config) {
|
||||
$this->__construct($alipay_config);
|
||||
}
|
||||
/**
|
||||
* 针对notify_url验证消息是否是支付宝发出的合法消息
|
||||
* @return 验证结果
|
||||
*/
|
||||
function verifyNotify(){
|
||||
if(empty($_POST)) {//判断POST来的数组是否为空
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
//生成签名结果
|
||||
$isSign = $this->getSignVeryfy($_POST, $_POST["sign"]);
|
||||
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
|
||||
$responseTxt = $this->getResponse($_POST["notify_id"]);
|
||||
|
||||
//验证
|
||||
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
|
||||
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
|
||||
if (preg_match("/true$/i",$responseTxt) && $isSign) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对return_url验证消息是否是支付宝发出的合法消息
|
||||
* @return 验证结果
|
||||
*/
|
||||
function verifyReturn(){
|
||||
if(empty($_GET)) {//判断POST来的数组是否为空
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
//生成签名结果
|
||||
$isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
|
||||
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
|
||||
$responseTxt = $this->getResponse($_GET["notify_id"]);
|
||||
|
||||
//验证
|
||||
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
|
||||
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
|
||||
if (preg_match("/true$/i",$responseTxt) && $isSign) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取返回时的签名验证结果
|
||||
* @param $para_temp 通知返回来的参数数组
|
||||
* @param $sign 返回的签名结果
|
||||
* @return 签名验证结果
|
||||
*/
|
||||
function getSignVeryfy($para_temp, $sign) {
|
||||
//除去待签名参数数组中的空值和签名参数
|
||||
$para_filter = paraFilter($para_temp);
|
||||
|
||||
//对待签名参数数组排序
|
||||
$para_sort = argSort($para_filter);
|
||||
|
||||
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
$prestr = createLinkstring($para_sort);
|
||||
|
||||
$isSgin = false;
|
||||
switch (strtoupper(trim($this->alipay_config['sign_type']))) {
|
||||
case "MD5" :
|
||||
$isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
|
||||
break;
|
||||
default :
|
||||
$isSgin = false;
|
||||
}
|
||||
|
||||
return $isSgin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取远程服务器ATN结果,验证返回URL
|
||||
* @param $notify_id 通知校验ID
|
||||
* @return 服务器ATN结果
|
||||
* 验证结果集:
|
||||
* invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空
|
||||
* true 返回正确信息
|
||||
* false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟
|
||||
*/
|
||||
function getResponse($notify_id) {
|
||||
$transport = strtolower(trim($this->alipay_config['transport']));
|
||||
$partner = trim($this->alipay_config['partner']);
|
||||
$veryfy_url = '';
|
||||
if($transport == 'https') {
|
||||
$veryfy_url = $this->https_verify_url;
|
||||
}
|
||||
else {
|
||||
$veryfy_url = $this->http_verify_url;
|
||||
}
|
||||
$veryfy_url = $veryfy_url."partner=" . $partner . "¬ify_id=" . $notify_id;
|
||||
$responseTxt = getHttpResponseGET($veryfy_url, $this->alipay_config['cacert']);
|
||||
|
||||
return $responseTxt;
|
||||
}
|
||||
}
|
||||
?>
|
||||
165
plugins/aliold/inc/alipay_submit.class.php
Normal file
165
plugins/aliold/inc/alipay_submit.class.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/* *
|
||||
* 类名:AlipaySubmit
|
||||
* 功能:支付宝各接口请求提交类
|
||||
* 详细:构造支付宝各接口表单HTML文本,获取远程HTTP数据
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-23
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
require_once(PAY_ROOT."inc/alipay_core.function.php");
|
||||
require_once(PAY_ROOT."inc/alipay_md5.function.php");
|
||||
|
||||
class AlipaySubmit {
|
||||
|
||||
var $alipay_config;
|
||||
/**
|
||||
*支付宝网关地址(新)
|
||||
*/
|
||||
var $alipay_gateway_new = 'https://mapi.alipay.com/gateway.do?';
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->alipay_config = $alipay_config;
|
||||
}
|
||||
function AlipaySubmit($alipay_config) {
|
||||
$this->__construct($alipay_config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成签名结果
|
||||
* @param $para_sort 已排序要签名的数组
|
||||
* return 签名结果字符串
|
||||
*/
|
||||
function buildRequestMysign($para_sort) {
|
||||
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
$prestr = createLinkstring($para_sort);
|
||||
|
||||
$mysign = "";
|
||||
switch (strtoupper(trim($this->alipay_config['sign_type']))) {
|
||||
case "MD5" :
|
||||
$mysign = md5Sign($prestr, $this->alipay_config['key']);
|
||||
break;
|
||||
default :
|
||||
$mysign = "";
|
||||
}
|
||||
|
||||
return $mysign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成要请求给支付宝的参数数组
|
||||
* @param $para_temp 请求前的参数数组
|
||||
* @return 要请求的参数数组
|
||||
*/
|
||||
function buildRequestPara($para_temp) {
|
||||
//除去待签名参数数组中的空值和签名参数
|
||||
$para_filter = paraFilter($para_temp);
|
||||
|
||||
//对待签名参数数组排序
|
||||
$para_sort = argSort($para_filter);
|
||||
|
||||
//生成签名结果
|
||||
$mysign = $this->buildRequestMysign($para_sort);
|
||||
|
||||
//签名结果与签名方式加入请求提交参数组中
|
||||
$para_sort['sign'] = $mysign;
|
||||
$para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type']));
|
||||
|
||||
return $para_sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成要请求给支付宝的参数数组
|
||||
* @param $para_temp 请求前的参数数组
|
||||
* @return 要请求的参数数组字符串
|
||||
*/
|
||||
function buildRequestParaToString($para_temp) {
|
||||
//待请求参数数组
|
||||
$para = $this->buildRequestPara($para_temp);
|
||||
|
||||
//把参数组中所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
|
||||
$request_data = createLinkstringUrlencode($para);
|
||||
|
||||
return $request_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立请求,以表单HTML形式构造(默认)
|
||||
* @param $para_temp 请求参数数组
|
||||
* @param $method 提交方式。两个值可选:post、get
|
||||
* @param $button_name 确认按钮显示文字
|
||||
* @return 提交表单HTML文本
|
||||
*/
|
||||
function buildRequestForm($para_temp, $method, $button_name) {
|
||||
//待请求参数数组
|
||||
$para = $this->buildRequestPara($para_temp);
|
||||
|
||||
$sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->alipay_gateway_new."_input_charset=".trim(strtolower($this->alipay_config['input_charset']))."' method='".$method."'>";
|
||||
foreach ($para as $key=>$val) {
|
||||
$sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>";
|
||||
}
|
||||
|
||||
//submit按钮控件请不要含有name属性
|
||||
$sHtml = $sHtml."<input type='submit' value='".$button_name."'></form>";
|
||||
|
||||
$sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>";
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立请求,以模拟远程HTTP的POST请求方式构造并获取支付宝的处理结果
|
||||
* @param $para_temp 请求参数数组
|
||||
* @return 支付宝处理结果
|
||||
*/
|
||||
function buildRequestHttp($para_temp) {
|
||||
$sResult = '';
|
||||
|
||||
//待请求参数数组字符串
|
||||
$request_data = $this->buildRequestPara($para_temp);
|
||||
|
||||
//远程获取数据
|
||||
$sResult = getHttpResponsePOST($this->alipay_gateway_new, $this->alipay_config['cacert'],$request_data,trim(strtolower($this->alipay_config['input_charset'])));
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立请求,以模拟远程HTTP的POST请求方式构造并获取支付宝的处理结果,带文件上传功能
|
||||
* @param $para_temp 请求参数数组
|
||||
* @param $file_para_name 文件类型的参数名
|
||||
* @param $file_name 文件完整绝对路径
|
||||
* @return 支付宝返回处理结果
|
||||
*/
|
||||
function buildRequestHttpInFile($para_temp, $file_para_name, $file_name) {
|
||||
|
||||
//待请求参数数组
|
||||
$para = $this->buildRequestPara($para_temp);
|
||||
$para[$file_para_name] = "@".$file_name;
|
||||
|
||||
//远程获取数据
|
||||
$sResult = getHttpResponsePOST($this->alipay_gateway_new, $this->alipay_config['cacert'],$para,trim(strtolower($this->alipay_config['input_charset'])));
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数
|
||||
* 注意:该功能PHP5环境及以上支持,因此必须服务器、本地电脑中装有支持DOMDocument、SSL的PHP配置环境。建议本地调试时使用PHP开发软件
|
||||
* return 时间戳字符串
|
||||
*/
|
||||
function query_timestamp() {
|
||||
$url = $this->alipay_gateway_new."service=query_timestamp&partner=".trim(strtolower($this->alipay_config['partner']))."&_input_charset=".trim(strtolower($this->alipay_config['input_charset']));
|
||||
$encrypt_key = "";
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->load($url);
|
||||
$itemEncrypt_key = $doc->getElementsByTagName( "encrypt_key" );
|
||||
$encrypt_key = $itemEncrypt_key->item(0)->nodeValue;
|
||||
|
||||
return $encrypt_key;
|
||||
}
|
||||
}
|
||||
?>
|
||||
57
plugins/aliold/notify.php
Normal file
57
plugins/aliold/notify.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/* *
|
||||
* 功能:支付宝服务器异步通知页面
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-23
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
|
||||
|
||||
*************************页面功能说明*************************
|
||||
* 创建该页面文件时,请留心该页面文件中无任何HTML代码及空格。
|
||||
* 该页面不能在本机电脑测试,请到服务器上做测试。请确保外部可以访问该页面。
|
||||
* 该页面调试工具请使用写文本函数logResult,该函数已被默认关闭,见alipay_notify_class.php中的函数verifyNotify
|
||||
* 如果没有收到该页面返回的 success 信息,支付宝会在24小时内按一定的时间策略重发通知
|
||||
*/
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/alipay.config.php");
|
||||
require_once(PAY_ROOT."inc/alipay_notify.class.php");
|
||||
|
||||
//计算得出通知验证结果
|
||||
$alipayNotify = new AlipayNotify($alipay_config);
|
||||
$verify_result = $alipayNotify->verifyNotify();
|
||||
|
||||
if($verify_result) {//验证成功
|
||||
//商户订单号
|
||||
|
||||
$out_trade_no = daddslashes($_POST['out_trade_no']);
|
||||
|
||||
//支付宝交易号
|
||||
|
||||
$trade_no = daddslashes($_POST['trade_no']);
|
||||
|
||||
//交易状态
|
||||
$trade_status = $_POST['trade_status'];
|
||||
|
||||
//交易金额
|
||||
$total_fee = $_POST['total_fee'];
|
||||
|
||||
if ($_POST['trade_status'] == 'TRADE_FINISHED' || $_POST['trade_status'] == 'TRADE_SUCCESS') {
|
||||
//付款完成后,支付宝系统发送该交易状态通知
|
||||
if($out_trade_no == TRADE_NO && round($total_fee,2)==round($order['money'],2)){
|
||||
if($order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='".TRADE_NO."'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='".TRADE_NO."'");
|
||||
processOrder($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "success";
|
||||
}
|
||||
else {
|
||||
//验证失败
|
||||
echo "fail";
|
||||
64
plugins/aliold/return.php
Normal file
64
plugins/aliold/return.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/* *
|
||||
* 功能:支付宝页面跳转同步通知页面
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-23
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
|
||||
*************************页面功能说明*************************
|
||||
* 该页面可在本机电脑测试
|
||||
* 可放入HTML等美化页面的代码、商户业务逻辑程序代码
|
||||
* 该页面可以使用PHP开发工具调试,也可以使用写文本函数logResult,该函数已被默认关闭,见alipay_notify_class.php中的函数verifyReturn
|
||||
*/
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/alipay.config.php");
|
||||
require_once(PAY_ROOT."inc/alipay_notify.class.php");
|
||||
|
||||
@header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
//计算得出通知验证结果
|
||||
$alipayNotify = new AlipayNotify($alipay_config);
|
||||
$verify_result = $alipayNotify->verifyReturn();
|
||||
if($verify_result) {
|
||||
//商户订单号
|
||||
|
||||
$out_trade_no = daddslashes($_GET['out_trade_no']);
|
||||
|
||||
//支付宝交易号
|
||||
|
||||
$trade_no = daddslashes($_GET['trade_no']);
|
||||
|
||||
//交易状态
|
||||
$trade_status = $_GET['trade_status'];
|
||||
|
||||
//交易金额
|
||||
$total_fee = $_GET['total_fee'];
|
||||
|
||||
if($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') {
|
||||
if($out_trade_no == TRADE_NO && round($total_fee,2)==round($order['money'],2)){
|
||||
$url=creat_callback($order);
|
||||
|
||||
if($order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='".TRADE_NO."'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='".TRADE_NO."'");
|
||||
processOrder($order,false);
|
||||
}
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}else{
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}
|
||||
}else{
|
||||
sysmsg('订单信息校验失败');
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "trade_status=".$_GET['trade_status'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
//验证失败
|
||||
sysmsg('支付宝返回验证失败!');
|
||||
}
|
||||
42
plugins/aliold/submit.php
Normal file
42
plugins/aliold/submit.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false && !$submit2){
|
||||
echo "<script>window.location.href='/submit2.php?typeid={$order['type']}&trade_no={$trade_no}';</script>";exit;
|
||||
}
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){
|
||||
include(SYSTEM_ROOT.'pages/wxopen.php');
|
||||
exit;
|
||||
}
|
||||
if(!empty($conf['localurl_alipay']) && !strpos($conf['localurl_alipay'],$_SERVER['HTTP_HOST'])){
|
||||
echo "<script>window.location.href='{$conf['localurl_alipay']}submit2.php?typeid={$order['type']}&trade_no={$trade_no}';</script>";exit;
|
||||
}
|
||||
|
||||
require_once(PAY_ROOT."inc/alipay.config.php");
|
||||
require_once(PAY_ROOT."inc/alipay_submit.class.php");
|
||||
|
||||
if(checkmobile()==true && in_array('2',$channel['apptype'])){
|
||||
$alipay_service = "alipay.wap.create.direct.pay.by.user";
|
||||
}else{
|
||||
$alipay_service = "create_direct_pay_by_user";
|
||||
}
|
||||
$parameter = array(
|
||||
"service" => $alipay_service,
|
||||
"partner" => trim($alipay_config['partner']), //合作身份者id
|
||||
"seller_id" => trim($alipay_config['partner']), //收款支付宝用户号
|
||||
"payment_type" => "1", //支付方式
|
||||
"notify_url" => $conf['localurl'].'pay/aliold/notify/'.TRADE_NO.'/', //服务器异步通知页面路径
|
||||
"return_url" => $siteurl.'pay/aliold/return/'.TRADE_NO.'/', //页面跳转同步通知页面路径
|
||||
"out_trade_no" => $trade_no, //商户订单号
|
||||
"subject" => $ordername, //订单名称
|
||||
"total_fee" => $order['money'], //付款金额
|
||||
"_input_charset" => strtolower('utf-8')
|
||||
);
|
||||
if($alipay_service=="alipay.wap.create.direct.pay.by.user"){
|
||||
$parameter['app_pay'] = "Y";
|
||||
}
|
||||
|
||||
//建立请求
|
||||
$alipaySubmit = new AlipaySubmit($alipay_config);
|
||||
$html_text = $alipaySubmit->buildRequestForm($parameter,"get", "正在跳转");
|
||||
echo $html_text;
|
||||
21
plugins/alipay/config.ini
Normal file
21
plugins/alipay/config.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
[config]
|
||||
;支付插件英文名称,需和目录名称一致,不能有重复
|
||||
name = "alipay"
|
||||
|
||||
;支付插件显示名称
|
||||
showname = "支付宝官方支付"
|
||||
|
||||
;支付插件作者
|
||||
author = "支付宝"
|
||||
|
||||
;支付插件作者链接
|
||||
link = "https://b.alipay.com/signing/productSetV2.htm"
|
||||
|
||||
;支付插件支持的支付方式,多种方式用英文,隔开,可选的有alipay,qqpay,wxpay,bank
|
||||
types = "alipay"
|
||||
|
||||
;支付插件要求传入的参数以及参数显示名称,可选的有appid,appkey,appsecret,appurl,appmchid
|
||||
inputs = "appid:应用APPID,appkey:支付宝公钥(RSA2),appsecret:商户私钥(RSA2)"
|
||||
|
||||
;支付插件要求传入的支付方式参数
|
||||
select = "1:电脑网站支付,2:手机网站支付,3:当面付扫码,4:JS支付"
|
||||
209
plugins/alipay/inc/AlipayCertifyService.php
Normal file
209
plugins/alipay/inc/AlipayCertifyService.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
require_once PAY_ROOT.'inc/lib/AopClient.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayUserCertifyOpenInitializeRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayUserCertifyOpenCertifyRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayUserCertifyOpenQueryRequest.php';
|
||||
require PAY_ROOT.'inc/config.php';
|
||||
|
||||
class AlipayCertifyService {
|
||||
|
||||
//支付宝网关地址
|
||||
public $gateway_url = "https://openapi.alipay.com/gateway.do";
|
||||
|
||||
//异步通知回调地址
|
||||
public $notify_url;
|
||||
|
||||
//签名类型
|
||||
public $sign_type;
|
||||
|
||||
//支付宝公钥地址
|
||||
public $alipay_public_key;
|
||||
|
||||
//商户私钥地址
|
||||
public $private_key;
|
||||
|
||||
//授权回调地址
|
||||
public $return_url;
|
||||
|
||||
//应用id
|
||||
public $appid;
|
||||
|
||||
//编码格式
|
||||
public $charset = "UTF-8";
|
||||
|
||||
public $token = NULL;
|
||||
|
||||
//返回数据格式
|
||||
public $format = "json";
|
||||
|
||||
//签名方式
|
||||
public $signtype = "RSA";
|
||||
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->gateway_url = $alipay_config['gatewayUrl'];
|
||||
$this->appid = $alipay_config['app_id'];
|
||||
$this->sign_type = $alipay_config['sign_type'];
|
||||
$this->private_key = $alipay_config['merchant_private_key'];
|
||||
$this->alipay_public_key = $alipay_config['alipay_public_key'];
|
||||
$this->return_url = $alipay_config['cert_return_url'];
|
||||
$this->charset = $alipay_config['charset'];
|
||||
$this->signtype = $alipay_config['sign_type'];
|
||||
|
||||
if(empty($this->appid)||trim($this->appid)==""){
|
||||
throw new Exception("appid should not be NULL!");
|
||||
}
|
||||
if(empty($this->private_key)||trim($this->private_key)==""){
|
||||
throw new Exception("private_key should not be NULL!");
|
||||
}
|
||||
if(empty($this->alipay_public_key)||trim($this->alipay_public_key)==""){
|
||||
throw new Exception("alipay_public_key should not be NULL!");
|
||||
}
|
||||
if(empty($this->charset)||trim($this->charset)==""){
|
||||
throw new Exception("charset should not be NULL!");
|
||||
}
|
||||
if(empty($this->gateway_url)||trim($this->gateway_url)==""){
|
||||
throw new Exception("gateway_url should not be NULL!");
|
||||
}
|
||||
if(empty($this->sign_type)||trim($this->sign_type)==""){
|
||||
throw new Exception("sign_type should not be NULL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//身份认证初始化服务
|
||||
public function initialize($outer_order_no, $cert_name, $cert_no, $biz_code = 'SMART_FACE') {
|
||||
|
||||
$BizContent = array(
|
||||
'outer_order_no' => $outer_order_no, //商户请求的唯一标识
|
||||
'biz_code' => $biz_code, //认证场景码
|
||||
'identity_param' => [
|
||||
'identity_type' => 'CERT_INFO', //身份信息参数类型
|
||||
'cert_type' => 'IDENTITY_CARD', //证件类型
|
||||
'cert_name' => $cert_name, //真实姓名
|
||||
'cert_no' => $cert_no, //证件号码
|
||||
],
|
||||
'merchant_config' => ['return_url'=>$this->return_url], //商户个性化配置
|
||||
);
|
||||
$request = new AlipayUserCertifyOpenInitializeRequest();
|
||||
$request->setBizContent(json_encode($BizContent));
|
||||
|
||||
$response = $this->aopclientRequestExecute($request);
|
||||
$response = $response->alipay_user_certify_open_initialize_response;
|
||||
|
||||
if(!empty($response->code)&&$response->code == 10000){
|
||||
$result = array('certify_id'=>$response->certify_id);
|
||||
}else{
|
||||
$result = array('code'=>$response->code, 'msg'=>$response->msg, 'sub_code'=>$response->sub_code, 'sub_msg'=>$response->sub_msg);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
//身份认证开始认证
|
||||
public function certify($certify_id) {
|
||||
|
||||
$BizContent = array(
|
||||
'certify_id' => $certify_id,
|
||||
);
|
||||
$request = new AlipayUserCertifyOpenCertifyRequest();
|
||||
$request->setBizContent(json_encode($BizContent));
|
||||
|
||||
$response = $this->aopclientRequestPageExecute($request);
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
//身份认证记录查询
|
||||
public function query($certify_id) {
|
||||
|
||||
$BizContent = array(
|
||||
'certify_id' => $certify_id,
|
||||
);
|
||||
$request = new AlipayUserCertifyOpenQueryRequest();
|
||||
$request->setBizContent(json_encode($BizContent));
|
||||
|
||||
$response = $this->aopclientRequestExecute($request);
|
||||
$response = $response->alipay_user_certify_open_query_response;
|
||||
|
||||
if(!empty($response->code)&&$response->code == 10000){
|
||||
$result = array('passed'=>$response->passed[0], 'identity_info'=>$response->identity_info, 'material_info'=>$response->material_info);
|
||||
}else{
|
||||
$result = array('code'=>$response->code, 'msg'=>$response->msg, 'sub_code'=>$response->sub_code, 'sub_msg'=>$response->sub_msg);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用SDK执行提交页面接口请求
|
||||
* @param unknown $request
|
||||
* @param string $token
|
||||
* @param string $appAuthToken
|
||||
* @return string $$result
|
||||
*/
|
||||
private function aopclientRequestExecute($request, $token = NULL, $appAuthToken = NULL) {
|
||||
|
||||
$aop = new AopClient ();
|
||||
$aop->gatewayUrl = $this->gateway_url;
|
||||
$aop->appId = $this->appid;
|
||||
$aop->signType = $this->sign_type;
|
||||
$aop->rsaPrivateKey = $this->private_key;
|
||||
$aop->alipayrsaPublicKey = $this->alipay_public_key;
|
||||
$aop->apiVersion = "1.0";
|
||||
$aop->postCharset = $this->charset;
|
||||
|
||||
$aop->format=$this->format;
|
||||
// 开启页面信息输出
|
||||
$aop->debugInfo=true;
|
||||
$result = $aop->execute($request,$token,$appAuthToken);
|
||||
|
||||
//打开后,将url形式请求报文写入log文件
|
||||
//$this->writeLog("response: ".var_export($result,true));
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用SDK执行提交页面接口请求
|
||||
* @param unknown $request
|
||||
* @param string $token
|
||||
* @param string $appAuthToken
|
||||
* @return string $$result
|
||||
*/
|
||||
private function aopclientRequestPageExecute($request, $token = NULL, $appAuthToken = NULL) {
|
||||
|
||||
$aop = new AopClient ();
|
||||
$aop->gatewayUrl = $this->gateway_url;
|
||||
$aop->appId = $this->appid;
|
||||
$aop->signType = $this->sign_type;
|
||||
$aop->rsaPrivateKey = $this->private_key;
|
||||
$aop->alipayrsaPublicKey = $this->alipay_public_key;
|
||||
$aop->apiVersion = "1.0";
|
||||
$aop->postCharset = $this->charset;
|
||||
|
||||
$aop->format=$this->format;
|
||||
// 开启页面信息输出
|
||||
$aop->debugInfo=true;
|
||||
$result = $aop->pageExecute($request,$token,$appAuthToken);
|
||||
|
||||
//打开后,将url形式请求报文写入log文件
|
||||
//$this->writeLog("response: ".var_export($result,true));
|
||||
return $result;
|
||||
}
|
||||
|
||||
function writeLog($text) {
|
||||
// $text=iconv("GBK", "UTF-8//IGNORE", $text);
|
||||
//$text = characet ( $text );
|
||||
file_put_contents ( PAY_ROOT."inc/log/log.txt", date ( "Y-m-d H:i:s" ) . " " . $text . "\r\n", FILE_APPEND );
|
||||
}
|
||||
|
||||
}
|
||||
167
plugins/alipay/inc/AlipayOauthService.php
Normal file
167
plugins/alipay/inc/AlipayOauthService.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
require_once PAY_ROOT.'inc/lib/AopClient.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipaySystemOauthTokenRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayUserInfoShareRequest.php';
|
||||
require PAY_ROOT.'inc/config.php';
|
||||
|
||||
class AlipayOauthService {
|
||||
|
||||
//支付宝网关地址
|
||||
public $gateway_url = "https://openapi.alipay.com/gateway.do";
|
||||
|
||||
//异步通知回调地址
|
||||
public $notify_url;
|
||||
|
||||
//签名类型
|
||||
public $sign_type;
|
||||
|
||||
//支付宝公钥地址
|
||||
public $alipay_public_key;
|
||||
|
||||
//商户私钥地址
|
||||
public $private_key;
|
||||
|
||||
//授权回调地址
|
||||
public $redirect_uri;
|
||||
|
||||
//应用id
|
||||
public $appid;
|
||||
|
||||
//编码格式
|
||||
public $charset = "UTF-8";
|
||||
|
||||
public $token = NULL;
|
||||
|
||||
//返回数据格式
|
||||
public $format = "json";
|
||||
|
||||
//签名方式
|
||||
public $signtype = "RSA";
|
||||
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->gateway_url = $alipay_config['gatewayUrl'];
|
||||
$this->appid = $alipay_config['app_id'];
|
||||
$this->sign_type = $alipay_config['sign_type'];
|
||||
$this->private_key = $alipay_config['merchant_private_key'];
|
||||
$this->alipay_public_key = $alipay_config['alipay_public_key'];
|
||||
$this->redirect_uri = $alipay_config['redirect_uri'];
|
||||
$this->charset = $alipay_config['charset'];
|
||||
$this->signtype = $alipay_config['sign_type'];
|
||||
|
||||
if(empty($this->appid)||trim($this->appid)==""){
|
||||
throw new Exception("appid should not be NULL!");
|
||||
}
|
||||
if(empty($this->private_key)||trim($this->private_key)==""){
|
||||
throw new Exception("private_key should not be NULL!");
|
||||
}
|
||||
if(empty($this->alipay_public_key)||trim($this->alipay_public_key)==""){
|
||||
throw new Exception("alipay_public_key should not be NULL!");
|
||||
}
|
||||
if(empty($this->charset)||trim($this->charset)==""){
|
||||
throw new Exception("charset should not be NULL!");
|
||||
}
|
||||
if(empty($this->gateway_url)||trim($this->gateway_url)==""){
|
||||
throw new Exception("gateway_url should not be NULL!");
|
||||
}
|
||||
if(empty($this->sign_type)||trim($this->sign_type)==""){
|
||||
throw new Exception("sign_type should not be NULL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//跳转支付宝授权页面
|
||||
public function oauth() {
|
||||
|
||||
$param = array('app_id'=>$this->appid, 'scope'=>'auth_base', 'redirect_uri'=>$this->redirect_uri);
|
||||
$url = 'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?'.http_build_query($param);
|
||||
|
||||
Header("Location: $url");
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
//换取授权访问令牌
|
||||
public function getToken($code, $grant_type = 'authorization_code') {
|
||||
|
||||
$request = new AlipaySystemOauthTokenRequest();
|
||||
if($grant_type == 'refresh_token'){
|
||||
$request->setGrantType("refresh_token");
|
||||
$request->setRefreshToken($code);
|
||||
}else{
|
||||
$request->setGrantType("authorization_code");
|
||||
$request->setCode($code);
|
||||
}
|
||||
|
||||
$response = $this->aopclientRequestExecute($request);
|
||||
$response = $response->alipay_system_oauth_token_response;
|
||||
|
||||
if(!empty($response) && $response->user_id){
|
||||
$result = array('user_id'=>$response->user_id, 'access_token'=>$response->access_token);
|
||||
}else{
|
||||
$result = array('code'=>$response->code, 'msg'=>$response->msg, 'sub_code'=>$response->sub_code, 'sub_msg'=>$response->sub_msg);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
//支付宝会员授权信息查询
|
||||
public function userinfo($accessToken) {
|
||||
|
||||
$request = new AlipayUserInfoShareRequest();
|
||||
|
||||
$response = $this->aopclientRequestExecute($request, $accessToken);
|
||||
$response = $response->alipay_user_info_share_response;
|
||||
|
||||
if(!empty($response) && $response->code == "10000"){
|
||||
$result = json_decode(json_encode($response), true);
|
||||
}else{
|
||||
$result = array('code'=>$response->code, 'msg'=>$response->msg, 'sub_code'=>$response->sub_code, 'sub_msg'=>$response->sub_msg);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用SDK执行提交页面接口请求
|
||||
* @param unknown $request
|
||||
* @param string $token
|
||||
* @param string $appAuthToken
|
||||
* @return string $$result
|
||||
*/
|
||||
private function aopclientRequestExecute($request, $token = NULL, $appAuthToken = NULL) {
|
||||
|
||||
$aop = new AopClient ();
|
||||
$aop->gatewayUrl = $this->gateway_url;
|
||||
$aop->appId = $this->appid;
|
||||
$aop->signType = $this->sign_type;
|
||||
$aop->rsaPrivateKey = $this->private_key;
|
||||
$aop->alipayrsaPublicKey = $this->alipay_public_key;
|
||||
$aop->apiVersion = "1.0";
|
||||
$aop->postCharset = $this->charset;
|
||||
|
||||
$aop->format=$this->format;
|
||||
// 开启页面信息输出
|
||||
$aop->debugInfo=true;
|
||||
$result = $aop->execute($request,$token,$appAuthToken);
|
||||
|
||||
//打开后,将url形式请求报文写入log文件
|
||||
//$this->writeLog("response: ".var_export($result,true));
|
||||
return $result;
|
||||
}
|
||||
|
||||
function writeLog($text) {
|
||||
// $text=iconv("GBK", "UTF-8//IGNORE", $text);
|
||||
//$text = characet ( $text );
|
||||
file_put_contents ( PAY_ROOT."inc/log/log.txt", date ( "Y-m-d H:i:s" ) . " " . $text . "\r\n", FILE_APPEND );
|
||||
}
|
||||
|
||||
}
|
||||
394
plugins/alipay/inc/AlipayTradeService.php
Normal file
394
plugins/alipay/inc/AlipayTradeService.php
Normal file
@@ -0,0 +1,394 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
require_once PAY_ROOT.'inc/lib/AopClient.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayTradeCreateRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayTradePagePayRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayTradeWapPayRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayTradePrecreateRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayTradeQueryRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayTradeRefundRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayTradeCloseRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/request/AlipayTradeFastpayRefundQueryRequest.php';
|
||||
require_once PAY_ROOT.'inc/model/result/AlipayF2FPrecreateResult.php';
|
||||
require_once PAY_ROOT.'inc/model/result/AlipayF2FQueryResult.php';
|
||||
require_once PAY_ROOT.'inc/model/result/AlipayF2FRefundResult.php';
|
||||
require_once PAY_ROOT.'inc/model/builder/AlipayTradeQueryContentBuilder.php';
|
||||
require PAY_ROOT.'inc/config.php';
|
||||
|
||||
class AlipayTradeService {
|
||||
|
||||
//支付宝网关地址
|
||||
public $gateway_url = "https://openapi.alipay.com/gateway.do";
|
||||
|
||||
//异步通知回调地址
|
||||
public $notify_url;
|
||||
|
||||
//同步通知回调地址
|
||||
public $return_url;
|
||||
|
||||
//签名类型
|
||||
public $sign_type;
|
||||
|
||||
//支付宝公钥地址
|
||||
public $alipay_public_key;
|
||||
|
||||
//商户私钥地址
|
||||
public $private_key;
|
||||
|
||||
//应用id
|
||||
public $appid;
|
||||
|
||||
//编码格式
|
||||
public $charset = "UTF-8";
|
||||
|
||||
|
||||
public $token = NULL;
|
||||
|
||||
//返回数据格式
|
||||
public $format = "json";
|
||||
|
||||
//签名方式
|
||||
public $signtype = "RSA2";
|
||||
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->gateway_url = $alipay_config['gatewayUrl'];
|
||||
$this->appid = $alipay_config['app_id'];
|
||||
$this->sign_type = $alipay_config['sign_type'];
|
||||
$this->private_key = $alipay_config['merchant_private_key'];
|
||||
$this->alipay_public_key = $alipay_config['alipay_public_key'];
|
||||
$this->charset = $alipay_config['charset'];
|
||||
$this->notify_url = $alipay_config['notify_url'];
|
||||
$this->return_url = $alipay_config['return_url'];
|
||||
$this->signtype = $alipay_config['sign_type'];
|
||||
|
||||
if(empty($this->appid)||trim($this->appid)==""){
|
||||
throw new Exception("appid should not be NULL!");
|
||||
}
|
||||
if(empty($this->private_key)||trim($this->private_key)==""){
|
||||
throw new Exception("private_key should not be NULL!");
|
||||
}
|
||||
if(empty($this->alipay_public_key)||trim($this->alipay_public_key)==""){
|
||||
throw new Exception("alipay_public_key should not be NULL!");
|
||||
}
|
||||
if(empty($this->charset)||trim($this->charset)==""){
|
||||
throw new Exception("charset should not be NULL!");
|
||||
}
|
||||
if(empty($this->gateway_url)||trim($this->gateway_url)==""){
|
||||
throw new Exception("gateway_url should not be NULL!");
|
||||
}
|
||||
if(empty($this->sign_type)||trim($this->sign_type)==""){
|
||||
throw new Exception("sign_type should not be NULL");
|
||||
}
|
||||
|
||||
}
|
||||
function AlipayWapPayService($alipay_config) {
|
||||
$this->__construct($alipay_config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用SDK执行提交页面接口请求
|
||||
* @param unknown $request
|
||||
* @param $ispage 是否是页面接口,电脑网站支付是页面表单接口。
|
||||
* @return string $result
|
||||
*/
|
||||
private function aopclientRequestExecute($request, $ispage=false) {
|
||||
|
||||
$aop = new AopClient ();
|
||||
$aop->gatewayUrl = $this->gateway_url;
|
||||
$aop->appId = $this->appid;
|
||||
$aop->signType = $this->sign_type;
|
||||
$aop->rsaPrivateKey = $this->private_key;
|
||||
$aop->alipayrsaPublicKey = $this->alipay_public_key;
|
||||
$aop->apiVersion = "1.0";
|
||||
$aop->postCharset = $this->charset;
|
||||
$aop->format=$this->format;
|
||||
// 开启页面信息输出
|
||||
$aop->debugInfo=true;
|
||||
if($ispage)
|
||||
{
|
||||
$result = $aop->pageExecute($request,"post");
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $aop->Execute($request);
|
||||
}
|
||||
|
||||
//打开后,将url形式请求报文写入log文件
|
||||
//$this->writeLog("response: ".var_export($result,true));
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* alipay.trade.create
|
||||
* @param $builder 业务参数,使用build中的对象生成。
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function create($req) {
|
||||
$bizContent = $req->getBizContent();
|
||||
$this->writeLog($bizContent);
|
||||
|
||||
$request = new AlipayTradeCreateRequest();
|
||||
$request->setBizContent ( $bizContent );
|
||||
$request->setNotifyUrl ( $this->notify_url );
|
||||
|
||||
// 首先调用支付api
|
||||
$response = $this->aopclientRequestExecute ( $request );
|
||||
$response = $response->alipay_trade_create_response;
|
||||
|
||||
$result = new AlipayF2FPrecreateResult($response);
|
||||
if(!empty($response)&&("10000"==$response->code)){
|
||||
$result->setTradeStatus("SUCCESS");
|
||||
} elseif($this->tradeError($response)){
|
||||
$result->setTradeStatus("UNKNOWN");
|
||||
} else {
|
||||
$result->setTradeStatus("FAILED");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//当面付2.0预下单(生成二维码)
|
||||
public function qrPay($req) {
|
||||
$bizContent = $req->getBizContent();
|
||||
$this->writeLog($bizContent);
|
||||
|
||||
$request = new AlipayTradePrecreateRequest();
|
||||
$request->setBizContent ( $bizContent );
|
||||
$request->setNotifyUrl ( $this->notify_url );
|
||||
|
||||
// 首先调用支付api
|
||||
$response = $this->aopclientRequestExecute ( $request );
|
||||
$response = $response->alipay_trade_precreate_response;
|
||||
|
||||
$result = new AlipayF2FPrecreateResult($response);
|
||||
if(!empty($response)&&("10000"==$response->code)){
|
||||
$result->setTradeStatus("SUCCESS");
|
||||
} elseif($this->tradeError($response)){
|
||||
$result->setTradeStatus("UNKNOWN");
|
||||
} else {
|
||||
$result->setTradeStatus("FAILED");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* alipay.trade.page.pay
|
||||
* @param $builder 业务参数,使用build中的对象生成。
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function pagePay($builder) {
|
||||
|
||||
$biz_content=$builder->getBizContent();
|
||||
//打印业务参数
|
||||
$this->writeLog($biz_content);
|
||||
|
||||
$request = new AlipayTradePagePayRequest();
|
||||
|
||||
$request->setNotifyUrl($this->notify_url);
|
||||
$request->setReturnUrl($this->return_url);
|
||||
$request->setBizContent ( $biz_content );
|
||||
|
||||
// 首先调用支付api
|
||||
$response = $this->aopclientRequestExecute ($request,true);
|
||||
// $response = $response->alipay_trade_wap_pay_response;
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* alipay.trade.wap.pay
|
||||
* @param $builder 业务参数,使用build中的对象生成。
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function wapPay($builder) {
|
||||
|
||||
$biz_content=$builder->getBizContent();
|
||||
//打印业务参数
|
||||
$this->writeLog($biz_content);
|
||||
|
||||
$request = new AlipayTradeWapPayRequest();
|
||||
|
||||
$request->setNotifyUrl($this->notify_url);
|
||||
$request->setReturnUrl($this->return_url);
|
||||
$request->setBizContent ( $biz_content );
|
||||
|
||||
// 首先调用支付api
|
||||
$response = $this->aopclientRequestExecute ($request,true);
|
||||
// $response = $response->alipay_trade_wap_pay_response;
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* alipay.trade.refund (统一收单交易退款接口)
|
||||
* @param $builder 业务参数,使用build中的对象生成。
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function refund($req) {
|
||||
$bizContent = $req->getBizContent();
|
||||
$this->writeLog($bizContent);
|
||||
$request = new AlipayTradeRefundRequest();
|
||||
$request->setBizContent ( $bizContent );
|
||||
$response = $this->aopclientRequestExecute ( $request );
|
||||
|
||||
$response = $response->alipay_trade_refund_response;
|
||||
|
||||
$result = new AlipayF2FRefundResult($response);
|
||||
if(!empty($response)&&("10000"==$response->code)){
|
||||
$result->setTradeStatus("SUCCESS");
|
||||
} elseif ($this->tradeError($response)){
|
||||
$result->setTradeStatus("UNKNOWN");
|
||||
} else {
|
||||
$result->setTradeStatus("FAILED");
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* alipay.trade.close (统一收单交易关闭接口)
|
||||
* @param $builder 业务参数,使用build中的对象生成。
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function close($builder){
|
||||
$biz_content=$builder->getBizContent();
|
||||
//打印业务参数
|
||||
$this->writeLog($biz_content);
|
||||
$request = new AlipayTradeCloseRequest();
|
||||
$request->setBizContent ( $biz_content );
|
||||
|
||||
$response = $this->aopclientRequestExecute ($request);
|
||||
$response = $response->alipay_trade_close_response;
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款查询 alipay.trade.fastpay.refund.query (统一收单交易退款查询)
|
||||
* @param $builder 业务参数,使用build中的对象生成。
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function refundQuery($builder){
|
||||
$biz_content=$builder->getBizContent();
|
||||
//打印业务参数
|
||||
$this->writeLog($biz_content);
|
||||
$request = new AlipayTradeFastpayRefundQueryRequest();
|
||||
$request->setBizContent ( $biz_content );
|
||||
|
||||
$response = $this->aopclientRequestExecute ($request);
|
||||
$response = $response->alipay_trade_fastpay_refund_query_response;
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* alipay.trade.query (统一收单线下交易查询)
|
||||
* @param $builder 业务参数,使用build中的对象生成。
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function query($builder) {
|
||||
$biz_content = $builder->getBizContent();
|
||||
//$this->writeLog($biz_content);
|
||||
$request = new AlipayTradeQueryRequest();
|
||||
$request->setBizContent ( $biz_content );
|
||||
$response = $this->aopclientRequestExecute ( $request );
|
||||
|
||||
return $response->alipay_trade_query_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* alipay.trade.query (统一收单线下交易查询)
|
||||
* @param $tradeNo 支付宝交易号
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function orderQuery($tradeNo) {
|
||||
$queryContentBuilder = new AlipayTradeQueryContentBuilder();
|
||||
$queryContentBuilder->setTradeNo($tradeNo);
|
||||
$response = $this->query($queryContentBuilder);
|
||||
return $response;
|
||||
}
|
||||
|
||||
// 当面付2.0消费查询
|
||||
public function queryTradeResult($req){
|
||||
$response = $this->query($req);
|
||||
$result = new AlipayF2FQueryResult($response);
|
||||
|
||||
if($this->querySuccess($response)){
|
||||
// 查询返回该订单交易支付成功
|
||||
$result->setTradeStatus("SUCCESS");
|
||||
|
||||
} elseif ($this->tradeError($response)){
|
||||
//查询发生异常或无返回,交易状态未知
|
||||
$result->setTradeStatus("UNKNOWN");
|
||||
} else {
|
||||
//其他情况均表明该订单号交易失败
|
||||
$result->setTradeStatus("FAILED");
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
// 查询返回“支付成功”
|
||||
protected function querySuccess($queryResponse){
|
||||
return !empty($queryResponse)&&
|
||||
$queryResponse->code == "10000"&&
|
||||
($queryResponse->trade_status == "TRADE_SUCCESS"||
|
||||
$queryResponse->trade_status == "TRADE_FINISHED");
|
||||
}
|
||||
|
||||
// 查询返回“交易关闭”
|
||||
protected function queryClose($queryResponse){
|
||||
return !empty($queryResponse)&&
|
||||
$queryResponse->code == "10000"&&
|
||||
$queryResponse->trade_status == "TRADE_CLOSED";
|
||||
}
|
||||
|
||||
// 交易异常,或发生系统错误
|
||||
protected function tradeError($response){
|
||||
return empty($response)||
|
||||
$response->code == "20000";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* alipay.data.dataservice.bill.downloadurl.query (查询对账单下载地址)
|
||||
* @param $builder 业务参数,使用build中的对象生成。
|
||||
* @return $response 支付宝返回的信息
|
||||
*/
|
||||
public function downloadurlQuery($builder){
|
||||
$biz_content=$builder->getBizContent();
|
||||
//打印业务参数
|
||||
$this->writeLog($biz_content);
|
||||
$request = new alipaydatadataservicebilldownloadurlqueryRequest();
|
||||
$request->setBizContent ( $biz_content );
|
||||
|
||||
$response = $this->aopclientRequestExecute ($request);
|
||||
$response = $response->alipay_data_dataservice_bill_downloadurl_query_response;
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验签方法
|
||||
* @param $arr 验签支付宝返回的信息,使用支付宝公钥。
|
||||
* @return boolean
|
||||
*/
|
||||
public function check($arr){
|
||||
$aop = new AopClient();
|
||||
$aop->alipayrsaPublicKey = $this->alipay_public_key;
|
||||
$result = $aop->rsaCheckV1($arr, $this->alipay_public_key, $this->signtype);
|
||||
if($result){
|
||||
$queryResponse = $this->orderQuery($arr['trade_no']);
|
||||
$result = $this->querySuccess($queryResponse);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function writeLog($text) {
|
||||
// $text=iconv("GBK", "UTF-8//IGNORE", $text);
|
||||
//$text = characet ( $text );
|
||||
file_put_contents ( PAY_ROOT."inc/log/log.txt", date ( "Y-m-d H:i:s" ) . " " . $text . "\r\n", FILE_APPEND );
|
||||
}
|
||||
|
||||
}
|
||||
32
plugins/alipay/inc/config.php
Normal file
32
plugins/alipay/inc/config.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
$config = array (
|
||||
//签名方式,默认为RSA2(RSA2048)
|
||||
'sign_type' => "RSA2",
|
||||
|
||||
//支付宝公钥
|
||||
'alipay_public_key' => $channel['appkey'],
|
||||
|
||||
//商户私钥
|
||||
'merchant_private_key' => $channel['appsecret'],
|
||||
|
||||
//编码格式
|
||||
'charset' => "UTF-8",
|
||||
|
||||
//支付宝网关
|
||||
'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
|
||||
|
||||
//应用ID
|
||||
'app_id' => $channel['appid'],
|
||||
|
||||
//异步通知地址
|
||||
'notify_url' => $conf['localurl'].'pay/alipay/notify/'.(defined("TRADE_NO")?TRADE_NO:$order['trade_no']).'/',
|
||||
|
||||
//同步通知地址
|
||||
'return_url' => $conf['localurl'].'pay/alipay/return/'.(defined("TRADE_NO")?TRADE_NO:$order['trade_no']).'/',
|
||||
|
||||
//登录返回页面
|
||||
'redirect_uri' => $siteurl.'user/oauth.php',
|
||||
|
||||
//实名认证返回页面
|
||||
'cert_return_url' => 'alipays://platformapi/startapp?appId=20000067&url='.urlencode($siteurl.'user/alipaycertok.php'),
|
||||
);
|
||||
1233
plugins/alipay/inc/lib/AopClient.php
Normal file
1233
plugins/alipay/inc/lib/AopClient.php
Normal file
File diff suppressed because it is too large
Load Diff
71
plugins/alipay/inc/lib/AopEncrypt.php
Normal file
71
plugins/alipay/inc/lib/AopEncrypt.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* 加密工具类
|
||||
*
|
||||
* User: jiehua
|
||||
* Date: 16/3/30
|
||||
* Time: 下午3:25
|
||||
*/
|
||||
|
||||
/**
|
||||
* 加密方法
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function encrypt($str,$screct_key){
|
||||
//AES, 128 模式加密数据 CBC
|
||||
$screct_key = base64_decode($screct_key);
|
||||
$str = trim($str);
|
||||
$str = addPKCS7Padding($str);
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
|
||||
$encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
|
||||
return base64_encode($encrypt_str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密方法
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function decrypt($str,$screct_key){
|
||||
//AES, 128 模式加密数据 CBC
|
||||
$str = base64_decode($str);
|
||||
$screct_key = base64_decode($screct_key);
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
|
||||
$encrypt_str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
|
||||
$encrypt_str = trim($encrypt_str);
|
||||
|
||||
$encrypt_str = stripPKSC7Padding($encrypt_str);
|
||||
return $encrypt_str;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充算法
|
||||
* @param string $source
|
||||
* @return string
|
||||
*/
|
||||
function addPKCS7Padding($source){
|
||||
$source = trim($source);
|
||||
$block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
|
||||
|
||||
$pad = $block - (strlen($source) % $block);
|
||||
if ($pad <= $block) {
|
||||
$char = chr($pad);
|
||||
$source .= str_repeat($char, $pad);
|
||||
}
|
||||
return $source;
|
||||
}
|
||||
/**
|
||||
* 移去填充算法
|
||||
* @param string $source
|
||||
* @return string
|
||||
*/
|
||||
function stripPKSC7Padding($source){
|
||||
$source = trim($source);
|
||||
$char = substr($source, -1);
|
||||
$num = ord($char);
|
||||
if($num==62)return $source;
|
||||
$source = substr($source,0,-$num);
|
||||
return $source;
|
||||
}
|
||||
45
plugins/alipay/inc/log/log.txt
Normal file
45
plugins/alipay/inc/log/log.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
2019-12-30 15:18:58 {"out_trade_no":"2019123015185815959","total_amount":"0.01","subject":"测试商品"}
|
||||
2019-12-30 15:30:55 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123015305514985"}
|
||||
2019-12-30 15:31:39 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123015313972121"}
|
||||
2019-12-30 15:32:06 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123015320673406"}
|
||||
2019-12-30 15:34:10 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123015340950615"}
|
||||
2019-12-30 15:34:39 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123015343916030"}
|
||||
2019-12-30 15:35:38 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123015353897750"}
|
||||
2019-12-30 15:36:45 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123015364529263"}
|
||||
2019-12-30 15:39:07 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123015390790733"}
|
||||
2019-12-30 15:39:21 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.3","out_trade_no":"2019123015392165431"}
|
||||
2019-12-30 16:08:03 {"productCode":"QUICK_WAP_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123016080349544"}
|
||||
2019-12-30 16:10:04 {"productCode":"QUICK_WAP_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123016100418612"}
|
||||
2019-12-30 16:10:59 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123016105967452"}
|
||||
2019-12-30 16:11:17 {"out_trade_no":"2019123016111735380","total_amount":"0.01","subject":"测试商品"}
|
||||
2019-12-30 16:11:26 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2019123016112643188"}
|
||||
2019-12-30 16:11:35 {"out_trade_no":"2019123016113551465","total_amount":"0.01","subject":"测试商品"}
|
||||
2019-12-30 16:33:59 {"trade_no":"2019123022001480341405429596","refund_amount":"0.30"}
|
||||
2019-12-30 16:36:50 {"trade_no":"2019123022001480341405429596","refund_amount":"0.30"}
|
||||
2019-12-30 16:37:23 {"trade_no":"2019123022001455741404921978","refund_amount":"0.01"}
|
||||
2019-12-30 16:38:30 {"trade_no":"2019123022001455741404921978","refund_amount":"0.01"}
|
||||
2019-12-30 17:25:50 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.04","out_trade_no":"2019123017255031130"}
|
||||
2020-01-03 00:16:37 {"productCode":"QUICK_WAP_PAY","subject":"在线收款","total_amount":"1.00","out_trade_no":"2020010300163764737"}
|
||||
2020-01-03 09:08:39 {"out_trade_no":"2020010309083980824","total_amount":"1","subject":"onlinepay1578013719","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:11:10 {"out_trade_no":"2020010309111073082","total_amount":"1","subject":"onlinepay1578013870","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:12:06 {"out_trade_no":"2020010309120668907","total_amount":"1","subject":"onlinepay1578013926","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:13:21 {"out_trade_no":"2020010309132192903","total_amount":"1","subject":"onlinepay1578014001","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:13:29 {"out_trade_no":"2020010309132920437","total_amount":"1","subject":"onlinepay1578014009","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:17:24 {"out_trade_no":"2020010309172451548","total_amount":"1","subject":"onlinepay1578014244","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:24:47 {"out_trade_no":"2020010309244792263","total_amount":"1","subject":"onlinepay1578014687","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:25:38 {"out_trade_no":"2020010309253836862","total_amount":"1","subject":"onlinepay1578014738","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:34:31 {"out_trade_no":"2020010309343181480","total_amount":"1","subject":"onlinepay1578015271","buyer_id":"2088902145680340"}
|
||||
2020-01-03 09:35:28 {"out_trade_no":"2020010309352871074","total_amount":"1","subject":"onlinepay1578015328","buyer_id":"2088902145680340"}
|
||||
2020-01-03 09:36:13 {"out_trade_no":"2020010309361383664","total_amount":"1","subject":"onlinepay1578015373","buyer_id":"2088902145680340"}
|
||||
2020-01-03 09:39:44 {"out_trade_no":"2020010309394488015","total_amount":"1","subject":"onlinepay1578015584","buyer_id":"2088902145680340"}
|
||||
2020-01-03 09:47:47 {"productCode":"QUICK_WAP_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2020010309474786130"}
|
||||
2020-01-03 09:48:03 {"out_trade_no":"2020010309480334513","total_amount":"0.01","subject":"测试商品"}
|
||||
2020-01-03 09:48:12 {"out_trade_no":"2020010309481226250","total_amount":"1","subject":"onlinepay1578016092","buyer_id":"2088902145680340"}
|
||||
2020-01-03 09:48:21 {"out_trade_no":"2020010309482188590","total_amount":"1","subject":"onlinepay1578016101","buyer_id":"2088212878255745"}
|
||||
2020-01-03 09:52:32 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2020010309523223008"}
|
||||
2020-01-03 09:52:36 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2020010309523626917"}
|
||||
2020-01-03 09:52:39 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"测试商品","total_amount":"0.01","out_trade_no":"2020010309523981342"}
|
||||
2020-01-03 09:54:15 {"out_trade_no":"2020010309541535375","total_amount":"0.01","subject":"测试商品"}
|
||||
2020-01-06 22:33:50 {"out_trade_no":"2020010622335057261","total_amount":"0.01","subject":"测试商品"}
|
||||
2020-02-05 17:39:49 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"购买会员 #1#","total_amount":"10.00","out_trade_no":"2020020517394978681"}
|
||||
2020-02-05 17:43:19 {"product_code":"FAST_INSTANT_TRADE_PAY","subject":"购买会员 #1#","total_amount":"10.00","out_trade_no":"2020020517431960215"}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/* *
|
||||
* 功能:支付宝电脑网站alipay.trade.close (统一收单交易关闭接口)业务参数封装
|
||||
* 版本:2.0
|
||||
* 修改日期:2017-05-01
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
*/
|
||||
|
||||
|
||||
class AlipayTradeCloseContentBuilder
|
||||
{
|
||||
|
||||
// 商户订单号.
|
||||
private $outTradeNo;
|
||||
|
||||
// 支付宝交易号
|
||||
private $tradeNo;
|
||||
|
||||
//卖家端自定义的的操作员 ID
|
||||
private $operatorId;
|
||||
|
||||
private $bizContentarr = array();
|
||||
|
||||
private $bizContent = NULL;
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
if(!empty($this->bizContentarr)){
|
||||
$this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getTradeNo()
|
||||
{
|
||||
return $this->tradeNo;
|
||||
}
|
||||
|
||||
public function setTradeNo($tradeNo)
|
||||
{
|
||||
$this->tradeNo = $tradeNo;
|
||||
$this->bizContentarr['trade_no'] = $tradeNo;
|
||||
}
|
||||
|
||||
public function getOutTradeNo()
|
||||
{
|
||||
return $this->outTradeNo;
|
||||
}
|
||||
|
||||
public function setOutTradeNo($outTradeNo)
|
||||
{
|
||||
$this->outTradeNo = $outTradeNo;
|
||||
$this->bizContentarr['out_trade_no'] = $outTradeNo;
|
||||
}
|
||||
public function getOperatorId()
|
||||
{
|
||||
return $this->operatorId;
|
||||
}
|
||||
|
||||
public function setOperatorId($operatorId)
|
||||
{
|
||||
$this->operatorId = $operatorId;
|
||||
$this->bizContentarr['operator_id'] = $operatorId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
|
||||
require_once 'GoodsDetail.php';
|
||||
require_once 'ExtendParams.php';
|
||||
require_once 'RoyaltyDetailInfo.php';
|
||||
require_once 'ContentBuilder.php';
|
||||
|
||||
class AlipayTradeCreateContentBuilder extends ContentBuilder
|
||||
{
|
||||
|
||||
// 商户网站订单系统中唯一订单号,64个字符以内,只能包含字母、数字、下划线,
|
||||
// 需保证商户系统端不能重复,建议通过数据库sequence生成,
|
||||
private $outTradeNo;
|
||||
|
||||
// 卖家支付宝账号ID,用于支持一个签约账号下支持打款到不同的收款账号,(打款到sellerId对应的支付宝账号)
|
||||
// 如果该字段为空,则默认为与支付宝签约的商户的PID,也就是appid对应的PID
|
||||
private $sellerId;
|
||||
|
||||
// 订单总金额,整形,此处单位为元,精确到小数点后2位,不能超过1亿元
|
||||
// 如果同时传入了【打折金额】,【不可打折金额】,【订单总金额】三者,则必须满足如下条件:【订单总金额】=【打折金额】+【不可打折金额】
|
||||
private $totalAmount;
|
||||
|
||||
// 订单可打折金额,此处单位为元,精确到小数点后2位
|
||||
// 可以配合商家平台配置折扣活动,如果订单部分商品参与打折,可以将部分商品总价填写至此字段,默认全部商品可打折
|
||||
// 如果该值未传入,但传入了【订单总金额】,【不可打折金额】 则该值默认为【订单总金额】- 【不可打折金额】
|
||||
private $discountableAmount;
|
||||
|
||||
//买家支付宝账号
|
||||
private $buyerId;
|
||||
|
||||
// 订单标题,粗略描述用户的支付目的。如“喜士多(浦东店)消费”
|
||||
private $subject;
|
||||
|
||||
// 订单描述,可以对交易或商品进行一个详细地描述,比如填写"购买商品2件共15.00元"
|
||||
private $body;
|
||||
|
||||
// 商品明细列表,需填写购买商品详细信息,
|
||||
private $goodsDetailList = array();
|
||||
|
||||
// 商户操作员编号,添加此参数可以为商户操作员做销售统
|
||||
private $operatorId;
|
||||
|
||||
// 商户门店编号,通过门店号和商家后台可以配置精准到门店的折扣信息,详询支付宝技术支持
|
||||
private $storeId;
|
||||
|
||||
// 商户机具终端编号,当以机具方式接入支付宝时必传,详询支付宝技术支持
|
||||
private $terminalId;
|
||||
|
||||
// 业务扩展参数,目前可添加由支付宝分配的系统商编号(通过setSysServiceProviderId方法),详情请咨询支付宝技术支持
|
||||
private $extendParams = array();
|
||||
|
||||
// (推荐使用,相对时间) 支付超时时间,5m 5分钟
|
||||
private $timeExpress;
|
||||
|
||||
private $bizContent = NULL;
|
||||
|
||||
private $bizParas = array();
|
||||
|
||||
|
||||
public function setOutTradeNo($outTradeNo)
|
||||
{
|
||||
$this->outTradeNo = $outTradeNo;
|
||||
$this->bizParas['out_trade_no'] = $outTradeNo;
|
||||
}
|
||||
public function getOutTradeNo()
|
||||
{
|
||||
return $this->outTradeNo;
|
||||
}
|
||||
|
||||
public function setSellerId($sellerId)
|
||||
{
|
||||
$this->sellerId = $sellerId;
|
||||
$this->bizParas['seller_id'] = $sellerId;
|
||||
}
|
||||
|
||||
public function getSellerId()
|
||||
{
|
||||
return $this->sellerId;
|
||||
}
|
||||
|
||||
public function setTotalAmount($totalAmount)
|
||||
{
|
||||
$this->totalAmount = $totalAmount;
|
||||
$this->bizParas['total_amount'] = $totalAmount;
|
||||
}
|
||||
|
||||
public function getTotalAmount()
|
||||
{
|
||||
return $this->totalAmount;
|
||||
}
|
||||
|
||||
public function setDiscountableAmount($discountableAmount)
|
||||
{
|
||||
$this->discountableAmount = $discountableAmount;
|
||||
$this->bizParas['discountable_amount'] = $discountableAmount;
|
||||
}
|
||||
|
||||
public function getDiscountableAmount()
|
||||
{
|
||||
return $this->discountableAmount;
|
||||
}
|
||||
|
||||
public function setBuyerId($buyerId)
|
||||
{
|
||||
$this->buyerId = $buyerId;
|
||||
$this->bizParas['buyer_id'] = $buyerId;
|
||||
}
|
||||
|
||||
public function getBuyerLogonId()
|
||||
{
|
||||
return $this->buyerLogonId;
|
||||
}
|
||||
|
||||
public function setSubject($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
$this->bizParas['subject'] = $subject;
|
||||
}
|
||||
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
public function setBody($body)
|
||||
{
|
||||
$this->body = $body;
|
||||
$this->bizParas['body'] = $body;
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function setOperatorId($operatorId)
|
||||
{
|
||||
$this->operatorId = $operatorId;
|
||||
$this->bizParas['operator_id'] = $operatorId;
|
||||
}
|
||||
|
||||
public function getOperatorId()
|
||||
{
|
||||
return $this->operatorId;
|
||||
}
|
||||
|
||||
public function setStoreId($storeId)
|
||||
{
|
||||
$this->storeId = $storeId;
|
||||
$this->bizParas['store_id'] = $storeId;
|
||||
}
|
||||
|
||||
public function getStoreId()
|
||||
{
|
||||
return $this->storeId;
|
||||
}
|
||||
|
||||
public function setTerminalId($terminalId)
|
||||
{
|
||||
$this->terminalId = $terminalId;
|
||||
$this->bizParas['terminal_id'] = $terminalId;
|
||||
}
|
||||
|
||||
public function getTerminalId()
|
||||
{
|
||||
return $this->terminalId;
|
||||
}
|
||||
|
||||
public function setTimeExpress($timeExpress)
|
||||
{
|
||||
$this->timeExpress = $timeExpress;
|
||||
$this->bizParas['timeout_express'] = $timeExpress;
|
||||
}
|
||||
|
||||
public function getTimeExpress()
|
||||
{
|
||||
return $this->timeExpress;
|
||||
}
|
||||
|
||||
public function getExtendParams()
|
||||
{
|
||||
return $this->extendParams;
|
||||
}
|
||||
|
||||
public function setExtendParams($extendParams)
|
||||
{
|
||||
$this->extendParams = $extendParams;
|
||||
$this->bizParas['extend_params'] = $extendParams;
|
||||
}
|
||||
|
||||
public function getGoodsDetailList()
|
||||
{
|
||||
return $this->goodsDetailList;
|
||||
}
|
||||
|
||||
public function setGoodsDetailList($goodsDetailList)
|
||||
{
|
||||
$this->goodsDetailList = $goodsDetailList;
|
||||
$this->bizParas['goods_detail'] = $goodsDetailList;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
if(!empty($this->bizParas)){
|
||||
$this->bizContent = json_encode($this->bizParas,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
return $this->bizContent;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/* *
|
||||
* 功能:支付宝电脑网站支付alipay.trade.fastpay.refund.query (统一收单交易退款查询)业务参数封装
|
||||
* 版本:2.0
|
||||
* 修改日期:2017-05-01
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
*/
|
||||
|
||||
|
||||
class AlipayTradeFastpayRefundQueryContentBuilder
|
||||
{
|
||||
|
||||
// 商户订单号.
|
||||
private $outTradeNo;
|
||||
// 支付宝交易号
|
||||
private $tradeNo;
|
||||
// 请求退款接口时,传入的退款请求号,如果在退款请求时未传入,则该值为创建交易时的外部交易号
|
||||
private $outRequestNo;
|
||||
|
||||
private $bizContentarr = array();
|
||||
|
||||
private $bizContent = NULL;
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
if(!empty($this->bizContentarr)){
|
||||
$this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getTradeNo()
|
||||
{
|
||||
return $this->tradeNo;
|
||||
}
|
||||
|
||||
public function setTradeNo($tradeNo)
|
||||
{
|
||||
$this->tradeNo = $tradeNo;
|
||||
$this->bizContentarr['trade_no'] = $tradeNo;
|
||||
}
|
||||
|
||||
public function getOutTradeNo()
|
||||
{
|
||||
return $this->outTradeNo;
|
||||
}
|
||||
|
||||
public function setOutTradeNo($outTradeNo)
|
||||
{
|
||||
$this->outTradeNo = $outTradeNo;
|
||||
$this->bizContentarr['out_trade_no'] = $outTradeNo;
|
||||
}
|
||||
public function getOutRequestNo()
|
||||
{
|
||||
return $this->outRequestNo;
|
||||
}
|
||||
public function setOutRequestNo($outRequestNo)
|
||||
{
|
||||
$this->outRequestNo = $outRequestNo;
|
||||
$this->bizContentarr['out_request_no'] = $outRequestNo;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/* *
|
||||
* 功能:支付宝电脑网站支付(alipay.trade.page.pay)接口业务参数封装
|
||||
* 版本:2.0
|
||||
* 修改日期:2017-05-01
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
*/
|
||||
|
||||
|
||||
class AlipayTradePagePayContentBuilder
|
||||
{
|
||||
|
||||
// 订单描述,可以对交易或商品进行一个详细地描述,比如填写"购买商品2件共15.00元"
|
||||
private $body;
|
||||
|
||||
// 订单标题,粗略描述用户的支付目的。
|
||||
private $subject;
|
||||
|
||||
// 商户订单号.
|
||||
private $outTradeNo;
|
||||
|
||||
// (推荐使用,相对时间) 该笔订单允许的最晚付款时间,逾期将关闭交易。取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)。 该参数数值不接受小数点, 如 1.5h,可转换为 90m
|
||||
private $timeExpress;
|
||||
|
||||
// 订单总金额,整形,此处单位为元,精确到小数点后2位,不能超过1亿元
|
||||
private $totalAmount;
|
||||
|
||||
// 产品标示码,固定值:QUICK_WAP_PAY
|
||||
private $productCode;
|
||||
|
||||
private $bizContentarr = array();
|
||||
|
||||
private $bizContent = NULL;
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
if(!empty($this->bizContentarr)){
|
||||
$this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bizContentarr['product_code'] = "FAST_INSTANT_TRADE_PAY";
|
||||
}
|
||||
|
||||
public function AlipayTradeWapPayContentBuilder()
|
||||
{
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function setBody($body)
|
||||
{
|
||||
$this->body = $body;
|
||||
$this->bizContentarr['body'] = $body;
|
||||
}
|
||||
|
||||
public function setSubject($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
$this->bizContentarr['subject'] = $subject;
|
||||
}
|
||||
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
public function getOutTradeNo()
|
||||
{
|
||||
return $this->outTradeNo;
|
||||
}
|
||||
|
||||
public function setOutTradeNo($outTradeNo)
|
||||
{
|
||||
$this->outTradeNo = $outTradeNo;
|
||||
$this->bizContentarr['out_trade_no'] = $outTradeNo;
|
||||
}
|
||||
|
||||
public function setTimeExpress($timeExpress)
|
||||
{
|
||||
$this->timeExpress = $timeExpress;
|
||||
$this->bizContentarr['timeout_express'] = $timeExpress;
|
||||
}
|
||||
|
||||
public function getTimeExpress()
|
||||
{
|
||||
return $this->timeExpress;
|
||||
}
|
||||
|
||||
public function setTotalAmount($totalAmount)
|
||||
{
|
||||
$this->totalAmount = $totalAmount;
|
||||
$this->bizContentarr['total_amount'] = $totalAmount;
|
||||
}
|
||||
|
||||
public function getTotalAmount()
|
||||
{
|
||||
return $this->totalAmount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
|
||||
require_once 'GoodsDetail.php';
|
||||
require_once 'ExtendParams.php';
|
||||
require_once 'RoyaltyDetailInfo.php';
|
||||
require_once 'ContentBuilder.php';
|
||||
|
||||
class AlipayTradePrecreateContentBuilder extends ContentBuilder
|
||||
{
|
||||
|
||||
// 商户网站订单系统中唯一订单号,64个字符以内,只能包含字母、数字、下划线,
|
||||
// 需保证商户系统端不能重复,建议通过数据库sequence生成,
|
||||
private $outTradeNo;
|
||||
|
||||
// 卖家支付宝账号ID,用于支持一个签约账号下支持打款到不同的收款账号,(打款到sellerId对应的支付宝账号)
|
||||
// 如果该字段为空,则默认为与支付宝签约的商户的PID,也就是appid对应的PID
|
||||
private $sellerId;
|
||||
|
||||
// 订单总金额,整形,此处单位为元,精确到小数点后2位,不能超过1亿元
|
||||
// 如果同时传入了【打折金额】,【不可打折金额】,【订单总金额】三者,则必须满足如下条件:【订单总金额】=【打折金额】+【不可打折金额】
|
||||
private $totalAmount;
|
||||
|
||||
// 订单可打折金额,此处单位为元,精确到小数点后2位
|
||||
// 可以配合商家平台配置折扣活动,如果订单部分商品参与打折,可以将部分商品总价填写至此字段,默认全部商品可打折
|
||||
// 如果该值未传入,但传入了【订单总金额】,【不可打折金额】 则该值默认为【订单总金额】- 【不可打折金额】
|
||||
private $discountableAmount;
|
||||
|
||||
// 订单不可打折金额,此处单位为元,精确到小数点后2位,可以配合商家平台配置折扣活动,如果酒水不参与打折,则将对应金额填写至此字段
|
||||
// 如果该值未传入,但传入了【订单总金额】,【打折金额】,则该值默认为【订单总金额】-【打折金额】
|
||||
private $undiscountableAmount;
|
||||
|
||||
//买家支付宝账号
|
||||
private $buyerLogonId;
|
||||
|
||||
// 订单标题,粗略描述用户的支付目的。如“喜士多(浦东店)消费”
|
||||
private $subject;
|
||||
|
||||
// 订单描述,可以对交易或商品进行一个详细地描述,比如填写"购买商品2件共15.00元"
|
||||
private $body;
|
||||
|
||||
// 商品明细列表,需填写购买商品详细信息,
|
||||
private $goodsDetailList = array();
|
||||
|
||||
// 商户操作员编号,添加此参数可以为商户操作员做销售统
|
||||
private $operatorId;
|
||||
|
||||
// 商户门店编号,通过门店号和商家后台可以配置精准到门店的折扣信息,详询支付宝技术支持
|
||||
private $storeId;
|
||||
|
||||
// 支付宝商家平台中配置的商户门店号,详询支付宝技术支持
|
||||
private $alipayStoreId;
|
||||
|
||||
// 商户机具终端编号,当以机具方式接入支付宝时必传,详询支付宝技术支持
|
||||
private $terminalId;
|
||||
|
||||
// 业务扩展参数,目前可添加由支付宝分配的系统商编号(通过setSysServiceProviderId方法),详情请咨询支付宝技术支持
|
||||
private $extendParams = array();
|
||||
|
||||
// (推荐使用,相对时间) 支付超时时间,5m 5分钟
|
||||
private $timeExpress;
|
||||
|
||||
private $bizContent = NULL;
|
||||
|
||||
private $bizParas = array();
|
||||
|
||||
|
||||
public function setOutTradeNo($outTradeNo)
|
||||
{
|
||||
$this->outTradeNo = $outTradeNo;
|
||||
$this->bizParas['out_trade_no'] = $outTradeNo;
|
||||
}
|
||||
public function getOutTradeNo()
|
||||
{
|
||||
return $this->outTradeNo;
|
||||
}
|
||||
|
||||
public function setSellerId($sellerId)
|
||||
{
|
||||
$this->sellerId = $sellerId;
|
||||
$this->bizParas['seller_id'] = $sellerId;
|
||||
}
|
||||
|
||||
public function getSellerId()
|
||||
{
|
||||
return $this->sellerId;
|
||||
}
|
||||
|
||||
public function setTotalAmount($totalAmount)
|
||||
{
|
||||
$this->totalAmount = $totalAmount;
|
||||
$this->bizParas['total_amount'] = $totalAmount;
|
||||
}
|
||||
|
||||
public function getTotalAmount()
|
||||
{
|
||||
return $this->totalAmount;
|
||||
}
|
||||
|
||||
public function setDiscountableAmount($discountableAmount)
|
||||
{
|
||||
$this->discountableAmount = $discountableAmount;
|
||||
$this->bizParas['discountable_amount'] = $discountableAmount;
|
||||
}
|
||||
|
||||
public function getDiscountableAmount()
|
||||
{
|
||||
return $this->discountableAmount;
|
||||
}
|
||||
|
||||
public function setUndiscountableAmount($undiscountableAmount)
|
||||
{
|
||||
$this->undiscountableAmount = $undiscountableAmount;
|
||||
$this->bizParas['undiscountable_amount'] = $undiscountableAmount;
|
||||
}
|
||||
|
||||
public function getUndiscountableAmount()
|
||||
{
|
||||
return $this->undiscountableAmount;
|
||||
}
|
||||
|
||||
public function setBuyerLogonId($buyerLogonId)
|
||||
{
|
||||
$this->buyerLogonId = $buyerLogonId;
|
||||
$this->bizParas['buyer_logon_id'] = $buyerLogonId;
|
||||
}
|
||||
|
||||
public function getBuyerLogonId()
|
||||
{
|
||||
return $this->buyerLogonId;
|
||||
}
|
||||
|
||||
public function setSubject($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
$this->bizParas['subject'] = $subject;
|
||||
}
|
||||
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
public function setBody($body)
|
||||
{
|
||||
$this->body = $body;
|
||||
$this->bizParas['body'] = $body;
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function setOperatorId($operatorId)
|
||||
{
|
||||
$this->operatorId = $operatorId;
|
||||
$this->bizParas['operator_id'] = $operatorId;
|
||||
}
|
||||
|
||||
public function getOperatorId()
|
||||
{
|
||||
return $this->operatorId;
|
||||
}
|
||||
|
||||
public function setStoreId($storeId)
|
||||
{
|
||||
$this->storeId = $storeId;
|
||||
$this->bizParas['store_id'] = $storeId;
|
||||
}
|
||||
|
||||
public function getStoreId()
|
||||
{
|
||||
return $this->storeId;
|
||||
}
|
||||
|
||||
public function setTerminalId($terminalId)
|
||||
{
|
||||
$this->terminalId = $terminalId;
|
||||
$this->bizParas['terminal_id'] = $terminalId;
|
||||
}
|
||||
|
||||
public function getTerminalId()
|
||||
{
|
||||
return $this->terminalId;
|
||||
}
|
||||
|
||||
public function setTimeExpress($timeExpress)
|
||||
{
|
||||
$this->timeExpress = $timeExpress;
|
||||
$this->bizParas['timeout_express'] = $timeExpress;
|
||||
}
|
||||
|
||||
public function getTimeExpress()
|
||||
{
|
||||
return $this->timeExpress;
|
||||
}
|
||||
|
||||
public function getAlipayStoreId()
|
||||
{
|
||||
return $this->alipayStoreId;
|
||||
}
|
||||
|
||||
|
||||
public function setAlipayStoreId($alipayStoreId)
|
||||
{
|
||||
$this->alipayStoreId = $alipayStoreId;
|
||||
$this->bizParas['alipay_store_id'] = $alipayStoreId;
|
||||
}
|
||||
|
||||
public function getExtendParams()
|
||||
{
|
||||
return $this->extendParams;
|
||||
}
|
||||
|
||||
public function setExtendParams($extendParams)
|
||||
{
|
||||
$this->extendParams = $extendParams;
|
||||
$this->bizParas['extend_params'] = $extendParams;
|
||||
}
|
||||
|
||||
public function getGoodsDetailList()
|
||||
{
|
||||
return $this->goodsDetailList;
|
||||
}
|
||||
|
||||
public function setGoodsDetailList($goodsDetailList)
|
||||
{
|
||||
$this->goodsDetailList = $goodsDetailList;
|
||||
$this->bizParas['goods_detail'] = $goodsDetailList;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
/*$this->bizContent = "{";
|
||||
foreach ($this->bizParas as $k=>$v){
|
||||
$this->bizContent.= "\"".$k."\":\"".$v."\",";
|
||||
}
|
||||
$this->bizContent = substr($this->bizContent,0,-1);
|
||||
$this->bizContent.= "}";*/
|
||||
if(!empty($this->bizParas)){
|
||||
$this->bizContent = json_encode($this->bizParas,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
return $this->bizContent;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
require_once 'ContentBuilder.php';
|
||||
|
||||
class AlipayTradeQueryContentBuilder extends ContentBuilder
|
||||
{
|
||||
// 支付宝交易号,和商户订单号不能同时为空, 如果同时存在则通过tradeNo查询支付宝交易
|
||||
private $tradeNo;
|
||||
|
||||
// 商户订单号,通过此商户订单号查询当面付的交易状态
|
||||
private $outTradeNo;
|
||||
|
||||
private $bizContentarr = array();
|
||||
|
||||
private $bizContent = NULL;
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
if(!empty($this->bizContentarr)){
|
||||
$this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getOutTradeNo()
|
||||
{
|
||||
return $this->outTradeNo;
|
||||
}
|
||||
|
||||
public function setOutTradeNo($outTradeNo)
|
||||
{
|
||||
$this->outTradeNo = $outTradeNo;
|
||||
$this->bizContentarr['out_trade_no'] = $outTradeNo;
|
||||
}
|
||||
|
||||
public function getTradeNo()
|
||||
{
|
||||
return $this->tradeNo;
|
||||
}
|
||||
|
||||
public function setTradeNo($tradeNo)
|
||||
{
|
||||
$this->tradeNo = $tradeNo;
|
||||
$this->bizContentarr['trade_no'] = $tradeNo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
require_once 'ContentBuilder.php';
|
||||
|
||||
class AlipayTradeRefundContentBuilder extends ContentBuilder
|
||||
{
|
||||
// 支付宝交易号,当面付支付成功后支付宝会返回给商户系统。通过此支付宝交易号进行交易退款
|
||||
private $tradeNo;
|
||||
|
||||
// (推荐) 外部订单号,可通过外部订单号申请退款,推荐使用
|
||||
private $outTradeNo;
|
||||
|
||||
// 退款金额,该金额必须小于等于订单的支付金额,此处单位为元,精确到小数点后2位
|
||||
private $refundAmount;
|
||||
|
||||
// (可选,需要支持重复退货时必填) 商户退款请求号,相同支付宝交易号下的不同退款请求号对应同一笔交易的不同退款申请,
|
||||
// 对于相同支付宝交易号下多笔相同商户退款请求号的退款交易,支付宝只会进行一次退款
|
||||
private $outRequestNo;
|
||||
|
||||
// (必填) 退款原因,可以说明用户退款原因,方便为商家后台提供统计
|
||||
private $refundReason;
|
||||
|
||||
// (必填) 商户门店编号,退款情况下可以为商家后台提供退款权限判定和统计等作用,详询支付宝技术支持
|
||||
private $storeId;
|
||||
|
||||
// 商户操作员编号,添加此参数可以为商户操作员做销售统
|
||||
private $operatorId;
|
||||
|
||||
// 商户机具终端编号,当以机具方式接入支付宝时必传,详询支付宝技术支持
|
||||
private $terminalId;
|
||||
|
||||
private $bizContentarr = array();
|
||||
|
||||
private $bizContent = NULL;
|
||||
|
||||
/* public function __construct()
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function AlipayTradeRefundContentBuilder()
|
||||
{
|
||||
$this->__construct();
|
||||
}*/
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
if(!empty($this->bizContentarr)){
|
||||
$this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function setTradeNo($tradeNo)
|
||||
{
|
||||
$this->tradeNo = $tradeNo;
|
||||
$this->bizContentarr['trade_no'] = $tradeNo;
|
||||
}
|
||||
|
||||
public function getTradeNo()
|
||||
{
|
||||
return $this->tradeNo;
|
||||
}
|
||||
|
||||
public function setOutTradeNo($outTradeNo)
|
||||
{
|
||||
$this->outTradeNo = $outTradeNo;
|
||||
$this->bizContentarr['out_trade_no'] = $outTradeNo;
|
||||
}
|
||||
|
||||
public function getOutTradeNo()
|
||||
{
|
||||
return $this->outTradeNo;
|
||||
}
|
||||
|
||||
public function setOperatorId($operatorId)
|
||||
{
|
||||
$this->operatorId = $operatorId;
|
||||
$this->bizContentarr['operator_id'] = $operatorId;
|
||||
}
|
||||
|
||||
public function getOperatorId()
|
||||
{
|
||||
return $this->operatorId;
|
||||
}
|
||||
|
||||
public function setOutRequestNo($outRequestNo)
|
||||
{
|
||||
$this->outRequestNo = $outRequestNo;
|
||||
$this->bizContentarr['out_request_no'] = $outRequestNo;
|
||||
}
|
||||
|
||||
public function getOutRequestNo()
|
||||
{
|
||||
return $this->outRequestNo;
|
||||
}
|
||||
|
||||
public function setRefundAmount($refundAmount)
|
||||
{
|
||||
$this->refundAmount = $refundAmount;
|
||||
$this->bizContentarr['refund_amount'] = $refundAmount;
|
||||
}
|
||||
|
||||
public function getRefundAmount()
|
||||
{
|
||||
return $this->refundAmount;
|
||||
}
|
||||
|
||||
public function setRefundReason($refundReason)
|
||||
{
|
||||
$this->refundReason = $refundReason;
|
||||
$this->bizContentarr['refund_reason'] = $refundReason;
|
||||
}
|
||||
|
||||
public function getRefundReason()
|
||||
{
|
||||
return $this->refundReason;
|
||||
}
|
||||
|
||||
public function setStoreId($storeId)
|
||||
{
|
||||
$this->storeId = $storeId;
|
||||
$this->bizContentarr['store_id'] = $storeId;
|
||||
}
|
||||
|
||||
public function getStoreId()
|
||||
{
|
||||
return $this->storeId;
|
||||
}
|
||||
|
||||
public function setTerminalId($terminalId)
|
||||
{
|
||||
$this->terminalId = $terminalId;
|
||||
$this->bizContentarr['terminal_id'] =$terminalId;
|
||||
}
|
||||
|
||||
public function getTerminalId()
|
||||
{
|
||||
return $this->terminalId;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/* *
|
||||
* 功能:支付宝手机网站支付接口(alipay.trade.wap.pay)接口业务参数封装
|
||||
* 版本:2.0
|
||||
* 修改日期:2016-11-01
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
*/
|
||||
|
||||
|
||||
class AlipayTradeWapPayContentBuilder
|
||||
{
|
||||
|
||||
// 订单描述,可以对交易或商品进行一个详细地描述,比如填写"购买商品2件共15.00元"
|
||||
private $body;
|
||||
|
||||
// 订单标题,粗略描述用户的支付目的。
|
||||
private $subject;
|
||||
|
||||
// 商户订单号.
|
||||
private $outTradeNo;
|
||||
|
||||
// (推荐使用,相对时间) 支付超时时间,5m 5分钟
|
||||
private $timeExpress;
|
||||
|
||||
// 订单总金额,整形,此处单位为元,精确到小数点后2位,不能超过1亿元
|
||||
private $totalAmount;
|
||||
|
||||
// 如果该字段为空,则默认为与支付宝签约的商户的PID,也就是appid对应的PID
|
||||
private $sellerId;
|
||||
|
||||
// 产品标示码,固定值:QUICK_WAP_PAY
|
||||
private $productCode;
|
||||
|
||||
private $bizContentarr = array();
|
||||
|
||||
private $bizContent = NULL;
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
if(!empty($this->bizContentarr)){
|
||||
$this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bizContentarr['productCode'] = "QUICK_WAP_PAY";
|
||||
}
|
||||
|
||||
public function AlipayTradeWapPayContentBuilder()
|
||||
{
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function setBody($body)
|
||||
{
|
||||
$this->body = $body;
|
||||
$this->bizContentarr['body'] = $body;
|
||||
}
|
||||
|
||||
public function setSubject($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
$this->bizContentarr['subject'] = $subject;
|
||||
}
|
||||
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
public function getOutTradeNo()
|
||||
{
|
||||
return $this->outTradeNo;
|
||||
}
|
||||
|
||||
public function setOutTradeNo($outTradeNo)
|
||||
{
|
||||
$this->outTradeNo = $outTradeNo;
|
||||
$this->bizContentarr['out_trade_no'] = $outTradeNo;
|
||||
}
|
||||
|
||||
public function setTimeExpress($timeExpress)
|
||||
{
|
||||
$this->timeExpress = $timeExpress;
|
||||
$this->bizContentarr['timeout_express'] = $timeExpress;
|
||||
}
|
||||
|
||||
public function getTimeExpress()
|
||||
{
|
||||
return $this->timeExpress;
|
||||
}
|
||||
|
||||
public function setTotalAmount($totalAmount)
|
||||
{
|
||||
$this->totalAmount = $totalAmount;
|
||||
$this->bizContentarr['total_amount'] = $totalAmount;
|
||||
}
|
||||
|
||||
public function getTotalAmount()
|
||||
{
|
||||
return $this->totalAmount;
|
||||
}
|
||||
|
||||
public function setSellerId($sellerId)
|
||||
{
|
||||
$this->sellerId = $sellerId;
|
||||
$this->bizContentarr['seller_id'] = $sellerId;
|
||||
}
|
||||
|
||||
public function getSellerId()
|
||||
{
|
||||
return $this->sellerId;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
36
plugins/alipay/inc/model/builder/ContentBuilder.php
Normal file
36
plugins/alipay/inc/model/builder/ContentBuilder.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/6/27
|
||||
* Time: 下午3:31
|
||||
*/
|
||||
class ContentBuilder
|
||||
{
|
||||
//第三方应用授权令牌
|
||||
private $appAuthToken;
|
||||
|
||||
//异步通知地址(仅扫码支付使用)
|
||||
private $notifyUrl;
|
||||
|
||||
public function setAppAuthToken($appAuthToken)
|
||||
{
|
||||
$this->appAuthToken = $appAuthToken;
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl = $notifyUrl;
|
||||
}
|
||||
|
||||
public function getAppAuthToken()
|
||||
{
|
||||
return $this->appAuthToken;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
}
|
||||
61
plugins/alipay/inc/model/builder/ExtendParams.php
Normal file
61
plugins/alipay/inc/model/builder/ExtendParams.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: airwalk
|
||||
* Date: 16/5/19
|
||||
* Time: 下午3:56
|
||||
*/
|
||||
|
||||
class ExtendParams
|
||||
{
|
||||
// 系统商编号
|
||||
private $sysServiceProviderId;
|
||||
|
||||
//使用花呗分期要进行的分期数,非必填项
|
||||
private $hbFqNum;
|
||||
|
||||
//使用花呗分期需要卖家承担的手续费比例的百分值
|
||||
private $hbFqSellerPercent;
|
||||
|
||||
private $extendParamsArr = array();
|
||||
|
||||
public function getExtendParams()
|
||||
{
|
||||
if(!empty($this->extendParamsArr)) {
|
||||
return $this->extendParamsArr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSysServiceProviderId()
|
||||
{
|
||||
return $this->sysServiceProviderId;
|
||||
}
|
||||
|
||||
public function setSysServiceProviderId($sysServiceProviderId)
|
||||
{
|
||||
$this->sysServiceProviderId = $sysServiceProviderId;
|
||||
$this->extendParamsArr['sys_service_provider_id'] = $sysServiceProviderId;
|
||||
}
|
||||
|
||||
public function getHbFqNum()
|
||||
{
|
||||
return $this->hbFqNum;
|
||||
}
|
||||
|
||||
public function setHbFqNum($hbFqNum)
|
||||
{
|
||||
$this->hbFqNum = $hbFqNum;
|
||||
$this->extendParamsArr['hb_fq_num'] = $hbFqNum;
|
||||
}
|
||||
|
||||
public function getHbFqSellerPercent()
|
||||
{
|
||||
return $this->hbFqSellerPercent;
|
||||
}
|
||||
|
||||
public function setHbFqSellerPercent($hbFqSellerPercent)
|
||||
{
|
||||
$this->hbFqSellerPercent = $hbFqSellerPercent;
|
||||
$this->extendParamsArr['hb_fq_seller_percent'] = $hbFqSellerPercent;
|
||||
}
|
||||
}
|
||||
129
plugins/alipay/inc/model/builder/GoodsDetail.php
Normal file
129
plugins/alipay/inc/model/builder/GoodsDetail.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
class GoodsDetail
|
||||
{
|
||||
// 商品编号(国标)
|
||||
private $goodsId;
|
||||
|
||||
//支付宝定义的统一商品编号
|
||||
private $alipayGoodsId;
|
||||
|
||||
// 商品名称
|
||||
private $goodsName;
|
||||
|
||||
// 商品数量
|
||||
private $quantity;
|
||||
|
||||
// 商品价格,此处单位为元,精确到小数点后2位
|
||||
private $price;
|
||||
|
||||
// 商品类别
|
||||
private $goodsCategory;
|
||||
|
||||
// 商品详情
|
||||
private $body;
|
||||
|
||||
private $goodsDetail = array();
|
||||
|
||||
//单个商品json字符串
|
||||
//private $goodsDetailStr = NULL;
|
||||
|
||||
//获取单个商品的json字符串
|
||||
public function getGoodsDetail()
|
||||
{
|
||||
return $this->goodsDetail;
|
||||
/*$this->goodsDetailStr = "{";
|
||||
foreach ($this->goodsDetail as $k => $v){
|
||||
$this->goodsDetailStr.= "\"".$k."\":\"".$v."\",";
|
||||
}
|
||||
$this->goodsDetailStr = substr($this->goodsDetailStr,0,-1);
|
||||
$this->goodsDetailStr.= "}";
|
||||
return $this->goodsDetailStr;*/
|
||||
}
|
||||
|
||||
public function setGoodsId($goodsId)
|
||||
{
|
||||
$this->goodsId = $goodsId;
|
||||
$this->goodsDetail['goods_id'] = $goodsId;
|
||||
}
|
||||
|
||||
public function getGoodsId()
|
||||
{
|
||||
return $this->goodsId;
|
||||
}
|
||||
|
||||
public function setAlipayGoodsId($alipayGoodsId)
|
||||
{
|
||||
$this->alipayGoodsId = $alipayGoodsId;
|
||||
$this->goodsDetail['alipay_goods_id'] = $alipayGoodsId;
|
||||
}
|
||||
|
||||
public function getAlipayGoodsId()
|
||||
{
|
||||
return $this->alipayGoodsId;
|
||||
}
|
||||
|
||||
public function setGoodsName($goodsName)
|
||||
{
|
||||
$this->goodsName = $goodsName;
|
||||
$this->goodsDetail['goods_name'] = $goodsName;
|
||||
}
|
||||
|
||||
public function getGoodsName()
|
||||
{
|
||||
return $this->goodsName;
|
||||
}
|
||||
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
$this->goodsDetail['quantity'] = $quantity;
|
||||
}
|
||||
|
||||
public function getQuantity()
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
public function setPrice($price)
|
||||
{
|
||||
$this->price = $price;
|
||||
$this->goodsDetail['price'] = $price;
|
||||
}
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setGoodsCategory($goodsCategory)
|
||||
{
|
||||
$this->goodsCategory = $goodsCategory;
|
||||
$this->goodsDetail['goods_category'] = $goodsCategory;
|
||||
}
|
||||
|
||||
public function getGoodsCategory()
|
||||
{
|
||||
return $this->goodsCategory;
|
||||
}
|
||||
|
||||
public function setBody($body)
|
||||
{
|
||||
$this->body = $body;
|
||||
$this->goodsDetail['body'] = $body;
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
161
plugins/alipay/inc/model/builder/RoyaltyDetailInfo.php
Normal file
161
plugins/alipay/inc/model/builder/RoyaltyDetailInfo.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/20
|
||||
* Time: 上午11:33
|
||||
*/
|
||||
|
||||
class RoyaltyDetailInfo
|
||||
{
|
||||
//分账序列号,表示分账执行的顺序,必须为正整数
|
||||
private $serialNo;
|
||||
|
||||
//接受分账金额的账户类型:默认值为userId。
|
||||
//userId:支付宝账号对应的支付宝唯一用户号。
|
||||
//bankIndex:分账到银行账户的银行编号。目前暂时只支持分账到一个银行编号。
|
||||
//storeId:分账到门店对应的银行卡编号。
|
||||
private $transInType;
|
||||
|
||||
//(必填)分账批次号 分账批次号。 目前需要和转入账号类型为bankIndex配合使用
|
||||
private $batchNo;
|
||||
|
||||
//商户分账的外部关联号,用于关联到每一笔分账信息,商户需保证其唯一性。
|
||||
//如果为空,该值则默认为“商户网站唯一订单号+分账序列号”
|
||||
private $outRelationId;
|
||||
|
||||
//(必填)要分账的账户类型,默认值为userId
|
||||
//目前只支持userId:支付宝账号对应的支付宝唯一用户号
|
||||
private $transOutType;
|
||||
|
||||
//(必填)如果转出账号类型为userId,本参数为要分账的支付宝账号对应的支付宝唯一用户号。
|
||||
//以2088开头的纯16位数字。
|
||||
private $transOut;
|
||||
|
||||
//(必填)如果转入账号类型为userId,本参数为接受分账金额的支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字。
|
||||
//如果转入账号类型为bankIndex,本参数为28位的银行编号(商户和支付宝签约时确定)
|
||||
//如果转入账号类型为storeId,本参数为商户的门店ID。
|
||||
private $transIn;
|
||||
|
||||
//(必填)分账的金额,单位为元
|
||||
private $amount;
|
||||
|
||||
//分账描述信息
|
||||
private $desc;
|
||||
|
||||
private $royaltyDetailInfo = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setTransInType("userId");
|
||||
$this->setTransOutType("userId");
|
||||
}
|
||||
|
||||
public function RoyaltyDetailInfo(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function getRoyaltyDetailInfo()
|
||||
{
|
||||
return $this->royaltyDetailInfo;
|
||||
}
|
||||
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function getBatchNo()
|
||||
{
|
||||
return $this->batchNo;
|
||||
}
|
||||
|
||||
public function getDesc()
|
||||
{
|
||||
return $this->desc;
|
||||
}
|
||||
|
||||
public function getOutRelationId()
|
||||
{
|
||||
return $this->outRelationId;
|
||||
}
|
||||
|
||||
public function getSerialNo()
|
||||
{
|
||||
return $this->serialNo;
|
||||
}
|
||||
|
||||
public function getTransIn()
|
||||
{
|
||||
return $this->transIn;
|
||||
}
|
||||
|
||||
public function getTransInType()
|
||||
{
|
||||
return $this->transInType;
|
||||
}
|
||||
|
||||
public function getTransOut()
|
||||
{
|
||||
return $this->transOut;
|
||||
}
|
||||
|
||||
public function getTransOutType()
|
||||
{
|
||||
return $this->transOutType;
|
||||
}
|
||||
|
||||
public function setAmount($amount)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
$this->royaltyDetailInfo['amount'] = $amount;
|
||||
}
|
||||
|
||||
public function setBatchNo($batchNo)
|
||||
{
|
||||
$this->batchNo = $batchNo;
|
||||
$this->royaltyDetailInfo['batch_no'] = $batchNo;
|
||||
}
|
||||
|
||||
public function setDesc($desc)
|
||||
{
|
||||
$this->desc = $desc;
|
||||
$this->royaltyDetailInfo['desc'] = $desc;
|
||||
}
|
||||
|
||||
public function setOutRelationId($outRelationId)
|
||||
{
|
||||
$this->outRelationId = $outRelationId;
|
||||
$this->royaltyDetailInfo['out_relation_id'] = $outRelationId;
|
||||
}
|
||||
|
||||
public function setSerialNo($serialNo)
|
||||
{
|
||||
$this->serialNo = $serialNo;
|
||||
$this->royaltyDetailInfo['serial_no'] = $serialNo;
|
||||
}
|
||||
|
||||
public function setTransIn($transIn)
|
||||
{
|
||||
$this->transIn = $transIn;
|
||||
$this->royaltyDetailInfo['trans_in'] = $transIn;
|
||||
}
|
||||
|
||||
public function setTransInType($transInType)
|
||||
{
|
||||
$this->transInType = $transInType;
|
||||
$this->royaltyDetailInfo['trans_in_type'] = $transInType;
|
||||
}
|
||||
|
||||
public function setTransOut($transOut)
|
||||
{
|
||||
$this->transOut = $transOut;
|
||||
$this->royaltyDetailInfo['trans_out'] = $transOut;
|
||||
}
|
||||
|
||||
public function setTransOutType($transOutType)
|
||||
{
|
||||
$this->transOutType = $transOutType;
|
||||
$this->royaltyDetailInfo['trans_out_type'] = $transOutType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.fund.account.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2019-11-08 12:17:16
|
||||
*/
|
||||
class AlipayFundAccountQueryRequest
|
||||
{
|
||||
/**
|
||||
* 支付宝资金账户资产查询接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.fund.account.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.fund.trans.common.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2019-10-19 09:32:00
|
||||
*/
|
||||
class AlipayFundTransCommonQueryRequest
|
||||
{
|
||||
/**
|
||||
* 转账业务单据查询接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.fund.trans.common.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.fund.trans.toaccount.transfer request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2019-06-17 11:15:01
|
||||
*/
|
||||
class AlipayFundTransToaccountTransferRequest
|
||||
{
|
||||
/**
|
||||
* 单笔转账到支付宝账户接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.fund.trans.toaccount.transfer";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.fund.trans.uni.transfer request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2019-10-23 15:09:00
|
||||
*/
|
||||
class AlipayFundTransUniTransferRequest
|
||||
{
|
||||
/**
|
||||
* 支付宝转账支付接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.fund.trans.uni.transfer";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.system.oauth.token request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-07-13 17:18:06
|
||||
*/
|
||||
class AlipaySystemOauthTokenRequest
|
||||
{
|
||||
/**
|
||||
* 授权码,用户对应用授权后得到。
|
||||
**/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* 值为authorization_code时,代表用code换取;值为refresh_token时,代表用refresh_token换取
|
||||
**/
|
||||
private $grantType;
|
||||
|
||||
/**
|
||||
* 刷新令牌,上次换取访问令牌时得到。见出参的refresh_token字段
|
||||
**/
|
||||
private $refreshToken;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->apiParas["code"] = $code;
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setGrantType($grantType)
|
||||
{
|
||||
$this->grantType = $grantType;
|
||||
$this->apiParas["grant_type"] = $grantType;
|
||||
}
|
||||
|
||||
public function getGrantType()
|
||||
{
|
||||
return $this->grantType;
|
||||
}
|
||||
|
||||
public function setRefreshToken($refreshToken)
|
||||
{
|
||||
$this->refreshToken = $refreshToken;
|
||||
$this->apiParas["refresh_token"] = $refreshToken;
|
||||
}
|
||||
|
||||
public function getRefreshToken()
|
||||
{
|
||||
return $this->refreshToken;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.system.oauth.token";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
plugins/alipay/inc/model/request/AlipayTradeCloseRequest.php
Normal file
118
plugins/alipay/inc/model/request/AlipayTradeCloseRequest.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.close request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2016-11-09 22:08:22
|
||||
*/
|
||||
class AlipayTradeCloseRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单交易关闭接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.close";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
plugins/alipay/inc/model/request/AlipayTradeCreateRequest.php
Normal file
118
plugins/alipay/inc/model/request/AlipayTradeCreateRequest.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.create request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2019-07-15 17:17:13
|
||||
*/
|
||||
class AlipayTradeCreateRequest
|
||||
{
|
||||
/**
|
||||
* 商户通过该接口进行交易的创建下单
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.create";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.fastpay.refund.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2017-03-23 19:11:54
|
||||
*/
|
||||
class AlipayTradeFastpayRefundQueryRequest
|
||||
{
|
||||
/**
|
||||
* 商户可使用该接口查询自已通过alipay.trade.refund提交的退款请求是否执行成功。
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.fastpay.refund.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
plugins/alipay/inc/model/request/AlipayTradePagePayRequest.php
Normal file
118
plugins/alipay/inc/model/request/AlipayTradePagePayRequest.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.page.pay request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2017-04-06 15:55:36
|
||||
*/
|
||||
class AlipayTradePagePayRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单下单并支付页面接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.page.pay";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
119
plugins/alipay/inc/model/request/AlipayTradePrecreateRequest.php
Normal file
119
plugins/alipay/inc/model/request/AlipayTradePrecreateRequest.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.precreate request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2017-01-09 15:29:09
|
||||
*/
|
||||
class AlipayTradePrecreateRequest
|
||||
{
|
||||
/**
|
||||
* 收银员通过收银台或商户后台调用支付宝接口,生成二维码后,展示给伤脑筋户,由用户扫描二维码完成订单支付。
|
||||
修改路由策略到R
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.precreate";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
119
plugins/alipay/inc/model/request/AlipayTradeQueryRequest.php
Normal file
119
plugins/alipay/inc/model/request/AlipayTradeQueryRequest.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2017-01-09 15:37:43
|
||||
*/
|
||||
class AlipayTradeQueryRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单线下交易查询
|
||||
修改路由策略到R
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
plugins/alipay/inc/model/request/AlipayTradeRefundRequest.php
Normal file
118
plugins/alipay/inc/model/request/AlipayTradeRefundRequest.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.refund request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2017-01-13 19:12:23
|
||||
*/
|
||||
class AlipayTradeRefundRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单交易退款接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.refund";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
plugins/alipay/inc/model/request/AlipayTradeWapPayRequest.php
Normal file
118
plugins/alipay/inc/model/request/AlipayTradeWapPayRequest.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.wap.pay request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2016-11-17 11:46:00
|
||||
*/
|
||||
class AlipayTradeWapPayRequest
|
||||
{
|
||||
/**
|
||||
* 手机网站支付接口2.0
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.wap.pay";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.user.certify.open.certify request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2019-07-11 19:50:01
|
||||
*/
|
||||
class AlipayUserCertifyOpenCertifyRequest
|
||||
{
|
||||
/**
|
||||
* 开放认证开始认证
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.user.certify.open.certify";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.user.certify.open.initialize request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2019-06-05 18:35:01
|
||||
*/
|
||||
class AlipayUserCertifyOpenInitializeRequest
|
||||
{
|
||||
/**
|
||||
* 支付宝开放认证初始化服务
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.user.certify.open.initialize";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.user.certify.open.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2019-01-07 20:51:15
|
||||
*/
|
||||
class AlipayUserCertifyOpenQueryRequest
|
||||
{
|
||||
/**
|
||||
* 支付宝开放认证查询
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.user.certify.open.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
103
plugins/alipay/inc/model/request/AlipayUserInfoShareRequest.php
Normal file
103
plugins/alipay/inc/model/request/AlipayUserInfoShareRequest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.user.info.share request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-07-13 17:18:06
|
||||
*/
|
||||
class AlipayUserInfoShareRequest
|
||||
{
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.user.info.share";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
44
plugins/alipay/inc/model/result/AlipayF2FPrecreateResult.php
Normal file
44
plugins/alipay/inc/model/result/AlipayF2FPrecreateResult.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
class AlipayF2FPrecreateResult
|
||||
{
|
||||
private $tradeStatus;
|
||||
private $response;
|
||||
|
||||
public function __construct($response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function AlipayF2FPrecreateResult($response)
|
||||
{
|
||||
$this->__construct($response);
|
||||
}
|
||||
|
||||
public function setTradeStatus($tradeStatus)
|
||||
{
|
||||
$this->tradeStatus = $tradeStatus;
|
||||
}
|
||||
|
||||
public function getTradeStatus()
|
||||
{
|
||||
return $this->tradeStatus;
|
||||
}
|
||||
|
||||
public function setResponse($response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
44
plugins/alipay/inc/model/result/AlipayF2FQueryResult.php
Normal file
44
plugins/alipay/inc/model/result/AlipayF2FQueryResult.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
class AlipayF2FQueryResult
|
||||
{
|
||||
private $tradeStatus;
|
||||
private $response;
|
||||
|
||||
public function __construct($response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function AlipayF2FPayResult($response)
|
||||
{
|
||||
$this->__construct($response);
|
||||
}
|
||||
|
||||
public function setTradeStatus($tradeStatus)
|
||||
{
|
||||
$this->tradeStatus = $tradeStatus;
|
||||
}
|
||||
|
||||
public function getTradeStatus()
|
||||
{
|
||||
return $this->tradeStatus;
|
||||
}
|
||||
|
||||
public function setResponse($response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
44
plugins/alipay/inc/model/result/AlipayF2FRefundResult.php
Normal file
44
plugins/alipay/inc/model/result/AlipayF2FRefundResult.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xudong.ding
|
||||
* Date: 16/5/19
|
||||
* Time: 下午2:09
|
||||
*/
|
||||
class AlipayF2FRefundResult
|
||||
{
|
||||
private $tradeStatus;
|
||||
private $response;
|
||||
|
||||
public function __construct($response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function AlipayF2FPayResult($response)
|
||||
{
|
||||
$this->__construct($response);
|
||||
}
|
||||
|
||||
public function setTradeStatus($tradeStatus)
|
||||
{
|
||||
$this->tradeStatus = $tradeStatus;
|
||||
}
|
||||
|
||||
public function getTradeStatus()
|
||||
{
|
||||
return $this->tradeStatus;
|
||||
}
|
||||
|
||||
public function setResponse($response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
46
plugins/alipay/notify.php
Normal file
46
plugins/alipay/notify.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/AlipayTradeService.php");
|
||||
|
||||
|
||||
//计算得出通知验证结果
|
||||
$alipaySevice = new AlipayTradeService($config);
|
||||
//$alipaySevice->writeLog(var_export($_POST,true));
|
||||
$verify_result = $alipaySevice->check($_POST);
|
||||
|
||||
if($verify_result) {//验证成功
|
||||
//商户订单号
|
||||
|
||||
$out_trade_no = daddslashes($_POST['out_trade_no']);
|
||||
|
||||
//支付宝交易号
|
||||
|
||||
$trade_no = daddslashes($_POST['trade_no']);
|
||||
|
||||
//交易状态
|
||||
$trade_status = $_POST['trade_status'];
|
||||
|
||||
//买家支付宝
|
||||
$buyer_id = daddslashes($_POST['buyer_id']);
|
||||
|
||||
//交易金额
|
||||
$total_amount = $_POST['total_amount'];
|
||||
|
||||
if($_POST['trade_status'] == 'TRADE_FINISHED') {
|
||||
//退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
|
||||
}
|
||||
else if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
|
||||
if($out_trade_no == TRADE_NO && round($total_amount,2)==round($order['money'],2) && $order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='".TRADE_NO."'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`buyer` ='$buyer_id',`date` =NOW() where `trade_no`='".TRADE_NO."'");
|
||||
processOrder($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "success";
|
||||
}
|
||||
else {
|
||||
//验证失败
|
||||
echo "fail";
|
||||
170
plugins/alipay/qrcode.php
Normal file
170
plugins/alipay/qrcode.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/*
|
||||
* 支付宝当面付扫码支付
|
||||
*/
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
@header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
$sitename=htmlspecialchars(base64_decode($_GET['sitename']));
|
||||
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){
|
||||
include(SYSTEM_ROOT.'pages/wxopen.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(PAY_ROOT."inc/model/builder/AlipayTradePrecreateContentBuilder.php");
|
||||
require_once(PAY_ROOT."inc/AlipayTradeService.php");
|
||||
|
||||
// 创建请求builder,设置请求参数
|
||||
$qrPayRequestBuilder = new AlipayTradePrecreateContentBuilder();
|
||||
$qrPayRequestBuilder->setOutTradeNo(TRADE_NO);
|
||||
$qrPayRequestBuilder->setTotalAmount($order['money']);
|
||||
$qrPayRequestBuilder->setSubject($ordername);
|
||||
|
||||
// 调用qrPay方法获取当面付应答
|
||||
$qrPay = new AlipayTradeService($config);
|
||||
$qrPayResult = $qrPay->qrPay($qrPayRequestBuilder);
|
||||
|
||||
// 根据状态值进行业务处理
|
||||
$status = $qrPayResult->getTradeStatus();
|
||||
$response = $qrPayResult->getResponse();
|
||||
if($status == 'SUCCESS'){
|
||||
$code_url = $response->qr_code;
|
||||
}elseif($status == 'FAILED'){
|
||||
sysmsg('支付宝创建订单二维码失败!['.$response->sub_code.']'.$response->sub_msg);
|
||||
}else{
|
||||
print_r($response);
|
||||
sysmsg('系统异常,状态未知!');
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>支付宝扫码支付 - <?php echo $sitename?></title>
|
||||
<link href="/assets/css/alipay_pay.css" rel="stylesheet" media="screen">
|
||||
</head>
|
||||
<body>
|
||||
<div class="body">
|
||||
<h1 class="mod-title">
|
||||
<span class="ico-wechat"></span><span class="text">支付宝扫码支付</span>
|
||||
</h1>
|
||||
<div class="mod-ct">
|
||||
<div class="order">
|
||||
</div>
|
||||
<div class="amount">¥<?php echo $order['money']?></div>
|
||||
<div class="qr-image" id="qrcode">
|
||||
</div>
|
||||
|
||||
<div class="detail" id="orderDetail">
|
||||
<dl class="detail-ct" style="display: none;">
|
||||
<dt>购买物品</dt>
|
||||
<dd id="productName"><?php echo $order['name']?></dd>
|
||||
<dt>商户订单号</dt>
|
||||
<dd id="billId"><?php echo $order['trade_no']?></dd>
|
||||
<dt>创建时间</dt>
|
||||
<dd id="createTime"><?php echo $order['addtime']?></dd>
|
||||
</dl>
|
||||
<a href="javascript:void(0)" class="arrow"><i class="ico-arrow"></i></a>
|
||||
</div>
|
||||
<div class="tip">
|
||||
<span class="dec dec-left"></span>
|
||||
<span class="dec dec-right"></span>
|
||||
<div class="ico-scan"></div>
|
||||
<div class="tip-text">
|
||||
<p>请使用支付宝扫一扫</p>
|
||||
<p>扫描二维码完成支付</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tip-text">
|
||||
</div>
|
||||
</div>
|
||||
<?php if(checkmobile()==true){?>
|
||||
<div class="foot">
|
||||
<div class="inner">
|
||||
<div id="J_downloadInteraction" class="download-interaction download-interaction-opening">
|
||||
<div class="inner-interaction">
|
||||
<p class="download-opening">正在打开支付宝<span class="download-opening-1">.</span><span class="download-opening-2">.</span><span class="download-opening-3">.</span></p>
|
||||
<p class="download-asking">如果没有打开支付宝,<a id="J_downloadBtn" href="javascript:;" onclick="openAli();">请点此重新唤起</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }?>
|
||||
<script src="/assets/js/qcloud_util.js"></script>
|
||||
<script src="/assets/js/jquery-qrcode.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/layer/2.3/layer.js"></script>
|
||||
<script>
|
||||
var code_url = '<?php echo $code_url?>';
|
||||
$('#qrcode').qrcode({
|
||||
text: code_url,
|
||||
width: 230,
|
||||
height: 230,
|
||||
foreground: "#000000",
|
||||
background: "#ffffff",
|
||||
typeNumber: -1
|
||||
});
|
||||
// 订单详情
|
||||
$('#orderDetail .arrow').click(function (event) {
|
||||
if ($('#orderDetail').hasClass('detail-open')) {
|
||||
$('#orderDetail .detail-ct').slideUp(500, function () {
|
||||
$('#orderDetail').removeClass('detail-open');
|
||||
});
|
||||
} else {
|
||||
$('#orderDetail .detail-ct').slideDown(500, function () {
|
||||
$('#orderDetail').addClass('detail-open');
|
||||
});
|
||||
}
|
||||
});
|
||||
// 检查是否支付完成
|
||||
function loadmsg() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "/getshop.php",
|
||||
timeout: 10000, //ajax请求超时时间10s
|
||||
data: {type: "alipay", trade_no: "<?php echo $order['trade_no']?>"}, //post数据
|
||||
success: function (data, textStatus) {
|
||||
//从服务器得到数据,显示数据并继续查询
|
||||
if (data.code == 1) {
|
||||
layer.msg('支付成功,正在跳转中...', {icon: 16,shade: 0.01,time: 15000});
|
||||
setTimeout(window.location.href=data.backurl, 1000);
|
||||
}else{
|
||||
setTimeout("loadmsg()", 4000);
|
||||
}
|
||||
},
|
||||
//Ajax请求超时,继续查询
|
||||
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus == "timeout") {
|
||||
setTimeout("loadmsg()", 1000);
|
||||
} else { //异常
|
||||
setTimeout("loadmsg()", 4000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function openAli(){
|
||||
var scheme = 'alipays://platformapi/startapp?saId=10000007&qrcode=';
|
||||
scheme += encodeURIComponent(code_url);
|
||||
|
||||
if(navigator.userAgent.indexOf("Safari") > -1){
|
||||
window.location.href = scheme;
|
||||
}
|
||||
else{
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.style.display = "none";
|
||||
iframe.src = scheme;
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
}
|
||||
window.onload = function(){
|
||||
openAli();
|
||||
setTimeout("loadmsg()", 2000);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
29
plugins/alipay/refund.php
Normal file
29
plugins/alipay/refund.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* 支付宝退款接口
|
||||
*/
|
||||
if(!defined('IN_REFUND'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/model/builder/AlipayTradeRefundContentBuilder.php");
|
||||
require_once(PAY_ROOT."inc/AlipayTradeService.php");
|
||||
|
||||
// 创建请求builder,设置请求参数
|
||||
$requestBuilder = new AlipayTradeRefundContentBuilder();
|
||||
$requestBuilder->setTradeNo($order['api_trade_no']);
|
||||
$requestBuilder->setRefundAmount($order['realmoney']);
|
||||
|
||||
// 调用退款接口
|
||||
$trade = new AlipayTradeService($config);
|
||||
$refundResult = $trade->refund($requestBuilder);
|
||||
|
||||
// 根据状态值进行业务处理
|
||||
$status = $refundResult->getTradeStatus();
|
||||
$response = $refundResult->getResponse();
|
||||
if($status == 'SUCCESS'){
|
||||
$result = ['code'=>0, 'trade_no'=>$response->trade_no, 'refund_fee'=>$response->refund_fee, 'refund_time'=>$response->gmt_refund_pay, 'buyer'=>$response->buyer_user_id];
|
||||
}elseif($status == 'FAILED'){
|
||||
$result = ['code'=>-1, 'msg'=>'['.$response->sub_code.']'.$response->sub_msg];
|
||||
}else{
|
||||
$result = ['code'=>-1, 'msg'=>'未知错误'];
|
||||
}
|
||||
return $result;
|
||||
44
plugins/alipay/return.php
Normal file
44
plugins/alipay/return.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
@header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
require_once(PAY_ROOT."inc/AlipayTradeService.php");
|
||||
|
||||
|
||||
//计算得出通知验证结果
|
||||
$alipaySevice = new AlipayTradeService($config);
|
||||
//$alipaySevice->writeLog(var_export($_POST,true));
|
||||
$verify_result = $alipaySevice->check($_GET);
|
||||
|
||||
if($verify_result) {//验证成功
|
||||
//商户订单号
|
||||
|
||||
$out_trade_no = daddslashes($_GET['out_trade_no']);
|
||||
|
||||
//支付宝交易号
|
||||
|
||||
$trade_no = daddslashes($_GET['trade_no']);
|
||||
|
||||
//交易金额
|
||||
$total_amount = $_GET['total_amount'];
|
||||
|
||||
if($out_trade_no == TRADE_NO && round($total_amount,2)==round($order['money'],2)){
|
||||
$url=creat_callback($order);
|
||||
|
||||
if($order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='".TRADE_NO."'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='".TRADE_NO."'");
|
||||
processOrder($order,false);
|
||||
}
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}else{
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}
|
||||
}else{
|
||||
sysmsg('订单信息校验失败');
|
||||
}
|
||||
}
|
||||
else {
|
||||
//验证失败
|
||||
sysmsg('支付宝返回验证失败!');
|
||||
45
plugins/alipay/submit.php
Normal file
45
plugins/alipay/submit.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false && !$submit2){
|
||||
echo "<script>window.location.href='/submit2.php?typeid={$order['type']}&trade_no={$trade_no}';</script>";exit;
|
||||
}
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){
|
||||
include(SYSTEM_ROOT.'pages/wxopen.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if(in_array('3',$channel['apptype']) && !in_array('1',$channel['apptype']) && !in_array('2',$channel['apptype'])){
|
||||
echo "<script>window.location.href='/pay/alipay/qrcode/{$trade_no}/?sitename={$sitename}';</script>";
|
||||
}else{
|
||||
|
||||
if(!empty($conf['localurl_alipay']) && !strpos($conf['localurl_alipay'],$_SERVER['HTTP_HOST'])){
|
||||
echo "<script>window.location.href='{$conf['localurl_alipay']}submit2.php?typeid={$order['type']}&trade_no={$trade_no}';</script>";exit;
|
||||
}
|
||||
|
||||
if(checkmobile()==true && in_array('2',$channel['apptype'])){
|
||||
require_once(PAY_ROOT."inc/model/builder/AlipayTradeWapPayContentBuilder.php");
|
||||
require_once(PAY_ROOT."inc/AlipayTradeService.php");
|
||||
|
||||
//¹¹Ôì²ÎÊý
|
||||
$payRequestBuilder = new AlipayTradeWapPayContentBuilder();
|
||||
$payRequestBuilder->setSubject($ordername);
|
||||
$payRequestBuilder->setTotalAmount($order['money']);
|
||||
$payRequestBuilder->setOutTradeNo($trade_no);
|
||||
|
||||
$aop = new AlipayTradeService($config);
|
||||
echo $aop->wapPay($payRequestBuilder);
|
||||
}else{
|
||||
require_once(PAY_ROOT."inc/model/builder/AlipayTradePagePayContentBuilder.php");
|
||||
require_once(PAY_ROOT."inc/AlipayTradeService.php");
|
||||
|
||||
//¹¹Ôì²ÎÊý
|
||||
$payRequestBuilder = new AlipayTradePagePayContentBuilder();
|
||||
$payRequestBuilder->setSubject($ordername);
|
||||
$payRequestBuilder->setTotalAmount($order['money']);
|
||||
$payRequestBuilder->setOutTradeNo($trade_no);
|
||||
|
||||
$aop = new AlipayTradeService($config);
|
||||
echo $aop->pagePay($payRequestBuilder);
|
||||
}
|
||||
}
|
||||
21
plugins/codepay/config.ini
Normal file
21
plugins/codepay/config.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
[config]
|
||||
;支付插件英文名称,需和目录名称一致,不能有重复
|
||||
name = "codepay"
|
||||
|
||||
;支付插件显示名称
|
||||
showname = "码支付"
|
||||
|
||||
;支付插件作者
|
||||
author = "码支付"
|
||||
|
||||
;支付插件作者链接
|
||||
link = "https://codepay.fateqq.com/"
|
||||
|
||||
;支付插件支持的支付方式,多种方式用英文,隔开,可选的有alipay,qqpay,wxpay,bank
|
||||
types = "alipay,qqpay,wxpay"
|
||||
|
||||
;支付插件要求传入的参数以及参数显示名称,可选的有appid,appkey,appsecret,appurl,appmchid
|
||||
inputs = "appid:商户ID,appkey:商户密钥"
|
||||
|
||||
;支付插件要求传入的支付方式参数
|
||||
select = ""
|
||||
33
plugins/codepay/inc/codepay_config.php
Normal file
33
plugins/codepay/inc/codepay_config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
#码支付接口配置
|
||||
$codepay_config['id'] = $channel['appid'];
|
||||
$codepay_config['key'] = $channel['appkey'];
|
||||
|
||||
//字符编码格式 目前支持 gbk GB2312 或 utf-8 保证跟文档编码一致 建议使用utf-8
|
||||
$codepay_config['chart'] = strtolower('utf-8');
|
||||
|
||||
//是否启用免挂机模式 1为启用. 未开通请勿更改否则资金无法及时到账
|
||||
$codepay_config['act'] = "0"; //认证版则开启 一般情况都为0
|
||||
|
||||
|
||||
/**订单支付页面显示方式
|
||||
* 1: GET框架云端支付 (简单 兼容性强 自动升级 1分钟可集成)
|
||||
* 2: POST表单到云端支付 (简单 兼容性强 自动升级)
|
||||
* 3:自定义开发模式 (默认 复杂 需要一定开发能力 手动升级 html/codepay_diy_order.php修改收银台代码)
|
||||
* 4:高级模式(复杂 需要较强的开发能力 手动升级 html/codepay_supper_order.php修改收银台代码)
|
||||
*/
|
||||
$codepay_config['page'] = 4; //支付页面展示方式
|
||||
|
||||
//支付页面风格样式 仅针对$codepay_config['page'] 参数为 1或2 才会有用。
|
||||
$codepay_config['style'] = 1; //暂时保留的功能 后期会生效 留意官网发布的风格编号
|
||||
|
||||
|
||||
//二维码超时设置 单位:秒
|
||||
$codepay_config['outTime'] = 300;//360秒=6分钟 最小值60 不建议太长 否则会影响其他人支付
|
||||
|
||||
//最低金额限制
|
||||
$codepay_config['min'] = 0.01;
|
||||
|
||||
//$codepay_config["qrcode_url"] = "./codepay/qrcode.php"; //使用本地二维码
|
||||
|
||||
$codepay_config['pay_type'] = 1;
|
||||
54
plugins/codepay/inc/qrcode.php
Normal file
54
plugins/codepay/inc/qrcode.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* 从本地获取二维码软件版专用。(默认为显示云端上传的二维码)
|
||||
* 注意:
|
||||
* 如果你提交的订单为100元 但展示的是1元的二维码 那么订单会不存在 不下发通知
|
||||
* 如使用的是自定义金额的收款码用户未按金额约定支付 都会是订单不存在。
|
||||
* Date: 2017/2/14
|
||||
* Time: 21:51
|
||||
*/
|
||||
|
||||
$money = number_format((float)$_GET['money'], 2, '.', ''); //金额统一保留2位小时
|
||||
$tag = (int)$_GET['tag'];
|
||||
$type = (int)$_GET['type'];
|
||||
if ($type <= 0) $type = 1;
|
||||
if ($money <= 0) {//这是什么状况 金额都没有。展示no.png
|
||||
header('Location: img/no.png');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数转为二维码文件名 (我们只给一个参考 具体根据个人实际开发)
|
||||
* @param $money 金额
|
||||
* @param int $type 支付类型
|
||||
* @param int $tag 支付宝备注
|
||||
* @param int $act 二维码规则方式
|
||||
* @return string 返回二维码路径
|
||||
*
|
||||
*默认路径格式为:qr/支付方式/金额_备注.png 支付宝则为:qr/支付方式/金额_备注.png
|
||||
* 比如:100元 微信为/qr/3/100.png 支付宝则为qr/1/100.00_0.png 其中100.00_0.png _0表示备注0 默认为0
|
||||
|
||||
*act参数为1则格式为:qr/支付方式/金额整数部分/金额小数部分.png 支付宝则为:qr/支付方式/金额整数部分/金额小数部分_备注.png
|
||||
*比如:100元 小数部分则是00 100元微信QQ路径为:qr/3/100/00.png 100元支付为:qr/3/100/00_0.png
|
||||
*/
|
||||
function moneyToFileName($money, $type = 1, $tag = 0, $act = 0)
|
||||
{
|
||||
if ($act == 1) { //act参数为1则使用的是将金额分成多个文件夹形式
|
||||
$money_arr = explode(".", $money); //将金额小数点后面部分分开
|
||||
$name1 = $money_arr[0];
|
||||
$name2 = count($money_arr) <= 1 ? '00' : $money_arr[1];
|
||||
$fileName = $type == 1 ? "qr/{$type}/{$name1}/{$name2}_{$tag}.png" : "qr/{$type}/{$name1}/{$name2}.png";
|
||||
} else { //默认方式 qr/3/100.00.png 支付宝则为qr/1/100.00_0.png
|
||||
$fileName = $type == 1 ? "qr/{$type}/{$money}_{$tag}.png" : "qr/{$type}/{$money}.png";
|
||||
}
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
|
||||
$qrcode_filename = moneyToFileName($money, $type, $tag, 0); //根据参数生成默认金额二维码地址
|
||||
if (!file_exists($qrcode_filename)) { //该金额二维码不存在 亲。
|
||||
//检查你是否有默认收款码 有则使用,没有那别人根本无法付款
|
||||
$index_fileName = "qr/{$type}/index.png";
|
||||
$qrcode_filename = file_exists($index_fileName) ? $index_fileName : 'img/no.png';
|
||||
}
|
||||
header('Location: ' . $qrcode_filename); //跳转到二维码真实地址
|
||||
44
plugins/codepay/notify.php
Normal file
44
plugins/codepay/notify.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/* *
|
||||
* 码支付异步通知页面
|
||||
*/
|
||||
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
require_once(PAY_ROOT."inc/codepay_config.php");
|
||||
ksort($_POST); //排序post参数
|
||||
reset($_POST); //内部指针指向数组中的第一个元素
|
||||
$sign = '';
|
||||
foreach ($_POST AS $key => $val) {
|
||||
if ($val == '') continue;
|
||||
if ($key != 'sign') {
|
||||
if ($sign != '') {
|
||||
$sign .= "&";
|
||||
$urls .= "&";
|
||||
}
|
||||
$sign .= "$key=$val"; //拼接为url参数形式
|
||||
$urls .= "$key=" . urlencode($val); //拼接为url参数形式
|
||||
}
|
||||
}
|
||||
|
||||
if (!$_POST['pay_no'] || md5($sign . $codepay_config['key']) != $_POST['sign']) { //不合法的数据 KEY密钥为你的密钥
|
||||
exit('fail');
|
||||
} else { //合法的数据
|
||||
|
||||
$out_trade_no = daddslashes($_POST['param']);
|
||||
|
||||
//流水号
|
||||
$trade_no = daddslashes($_POST['pay_no']);
|
||||
|
||||
$price = (float)$_POST['price'];
|
||||
|
||||
if($out_trade_no == TRADE_NO && round($price,2)==round($order['money'],2) && $order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='$out_trade_no'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='$out_trade_no'");
|
||||
processOrder($order);
|
||||
}
|
||||
}
|
||||
|
||||
exit('success');
|
||||
}
|
||||
|
||||
?>
|
||||
234
plugins/codepay/qrcode.php
Normal file
234
plugins/codepay/qrcode.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/codepay_config.php");
|
||||
|
||||
@header('Content-Type: text/html; charset=UTF-8');
|
||||
$qr=''; //初始化一个默认的二维码
|
||||
|
||||
$codepay_path="https://codepay.fateqq.com";
|
||||
|
||||
$typename = $DB->getColumn("SELECT name FROM pre_type WHERE id='{$order['type']}' LIMIT 1");
|
||||
|
||||
if ($typename == 'wxpay') {
|
||||
$typeName = '微信';
|
||||
$type = 3;
|
||||
} else if ($typename == 'qqpay' || $typename == 'tenpay') {
|
||||
$typeName = 'QQ';
|
||||
$type = 2;
|
||||
} else {
|
||||
$type = 1;
|
||||
$typeName = '支付宝';
|
||||
}
|
||||
|
||||
$price = $order['money'];
|
||||
$param = TRADE_NO;
|
||||
|
||||
$pay_id = $clientip;
|
||||
$data = array(
|
||||
"id" => $codepay_config['id'],//平台ID号
|
||||
"type" => $type,//支付方式
|
||||
"price" => $price,//原价
|
||||
"pay_id" => $pay_id, //可以是用户ID,站内商户订单号,用户名
|
||||
"param" => $param,//自定义参数
|
||||
// "https" => 1,//启用HTTPS
|
||||
"act" => $codepay_config['act'],
|
||||
"outTime" => $codepay_config['outTime'],//二维码超时设置
|
||||
"page" => $codepay_config['page'],//付款页面展示方式
|
||||
"return_url" => $siteurl.'pay/codepay/return/'.TRADE_NO.'/',//付款后附带加密参数跳转到该页面
|
||||
"notify_url" => $conf['localurl'].'pay/codepay/notify/'.TRADE_NO.'/',//付款后通知该页面处理业务
|
||||
"style" => $codepay_config['style'],//付款页面风格
|
||||
"user_ip" => $clientip,//用户IP
|
||||
"out_trade_no" => $param,//单号去重复
|
||||
"createTime" => time(),//服务器时间
|
||||
"qrcode_url" => $codepay_config['qrcode_url'],//本地化二维码
|
||||
"chart" => strtolower('utf-8')//字符编码方式
|
||||
//其他业务参数根据在线开发文档,添加参数.文档地址:https://codepay.fateqq.com/apiword/
|
||||
//如"参数名"=>"参数值"
|
||||
);
|
||||
function create_link($params,$codepay_key,$host=""){
|
||||
ksort($params); //重新排序$data数组
|
||||
reset($params); //内部指针指向数组中的第一个元素
|
||||
$sign = '';
|
||||
$urls = '';
|
||||
foreach ($params AS $key => $val) {
|
||||
if ($val == '') continue;
|
||||
if ($key != 'sign') {
|
||||
if ($sign != '') {
|
||||
$sign .= "&";
|
||||
$urls .= "&";
|
||||
}
|
||||
$sign .= "$key=$val"; //拼接为url参数形式
|
||||
$urls .= "$key=" . urlencode($val); //拼接为url参数形式
|
||||
}
|
||||
}
|
||||
|
||||
$key = md5($sign . $codepay_key);//替换为自己的密钥
|
||||
$query = $urls . '&sign=' . $key; //创建订单所需的参数
|
||||
$apiHost=$host?$host:"http://api2.xiuxiu888.com/creat_order/?";
|
||||
$url = $apiHost.$query; //支付页面
|
||||
return array("url"=>$url,"query"=>$query,"sign"=>$sign,"param"=>$urls);
|
||||
}
|
||||
$back=create_link($data,$codepay_config['key']);
|
||||
|
||||
$user_data = array(
|
||||
"return_url" => $siteurl.'pay/codepay/return/'.TRADE_NO.'/',
|
||||
"type" => $type,
|
||||
"outTime" => $codepay_config["outTime"],
|
||||
"codePay_id" => $codepay_config["id"],
|
||||
"out_trade_no" => $param,
|
||||
"price" => $price,
|
||||
'money'=>$price,
|
||||
'order_id'=>$param,
|
||||
"subject"=>$row['name']
|
||||
); //传给网页JS去执行
|
||||
|
||||
|
||||
$user_data["qrcode_url"] = $codepay_config["qrcode_url"];
|
||||
|
||||
//中间那log 默认为8秒后隐藏
|
||||
//改为自己的替换img目录下的use_开头的图片 你要保证你的二维码遮挡不会影响扫码
|
||||
//二维码容错率决定你能遮挡多少部分
|
||||
$user_data["logShowTime"] = $user_data["qrcode_url"]?1:8*1000;
|
||||
|
||||
|
||||
$codepay_json = get_curl($back['url']);
|
||||
|
||||
if(empty($codepay_json)){
|
||||
$data['call']="callback";
|
||||
$data['page']="3";
|
||||
$back=create_link($data,$codepay_config['key']);
|
||||
$codepay_html='<script src="'.$back['url'].'"></script>';
|
||||
}else{
|
||||
$codepay_data = json_decode($codepay_json);
|
||||
$qr = $codepay_data ? $codepay_data->qrcode : '';
|
||||
$user_data["money"]=$codepay_data&&$codepay_data->money ? $codepay_data->money : $price;
|
||||
$codepay_html="<script>callback({$codepay_json})</script>";
|
||||
}
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $codepay_config['chart'] ?>">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta name="apple-mobile-web-app-capable" content="no"/>
|
||||
<meta name="apple-touch-fullscreen" content="yes"/>
|
||||
<meta name="format-detection" content="telephone=no,email=no"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="white">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<title><?php echo $typeName ?>扫码支付</title>
|
||||
<link href="<?php echo $codepay_path?>/css/wechat_pay.css" rel="stylesheet" media="screen">
|
||||
<link href="//cdn.staticfile.org/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
|
||||
<link href="//cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="body">
|
||||
<h1 class="mod-title">
|
||||
<span class="ico_log ico-<?php echo $type ?>"></span>
|
||||
</h1>
|
||||
|
||||
<div class="mod-ct">
|
||||
<div class="order" style="color:red;font-size:16px">请务必规定时间内支付下面显示的金额
|
||||
</div>
|
||||
|
||||
<div class="amount" style="position: relative;" ><span id="money">¥<?php echo $price ?></span><div style="position: absolute;font-size: 10px;top: 29px;left: 75%;"><a href="#" class="copy" id="copy" data-clipboard-text="<?php echo $user_data['money']?>">复制金额</a></div></div>
|
||||
<div class="qrcode-img-wrapper" data-role="qrPayImgWrapper">
|
||||
<div data-role="qrPayImg" class="qrcode-img-area">
|
||||
<div class="ui-loading qrcode-loading" data-role="qrPayImgLoading" style="display: none;">加载中</div>
|
||||
<div style="position: relative;display: inline-block;">
|
||||
<img id='show_qrcode' alt="加载中..." src="<?php echo $qr ?>" width="210" height="210" style="display: block;">
|
||||
<img onclick="$('#use').hide()" id="use" src="<?php echo $codepay_path?>/img/use_<?php echo $type ?>.png"
|
||||
style="position: absolute;top: 50%;left: 50%;width:32px;height:32px;margin-left: -21px;margin-top: -21px">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 这里加一些自己的提示-->
|
||||
<div class="time-item" id="msg">
|
||||
<h1>二维码过期时间</h1>
|
||||
<strong id="hour_show">0时</strong>
|
||||
<strong id="minute_show">0分</strong>
|
||||
<strong id="second_show">0秒</strong>
|
||||
</div>
|
||||
|
||||
<div class="tip">
|
||||
<div class="ico-scan"></div>
|
||||
<div class="tip-text">
|
||||
<p>请使用<?php echo $typeName ?>扫一扫</p>
|
||||
<p>扫描二维码完成支付</p>
|
||||
<p><div id="kf" style="display:none;"></div></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail" id="orderDetail">
|
||||
<dl class="detail-ct" id="desc" style="display: none;">
|
||||
|
||||
|
||||
</dl>
|
||||
<a href="javascript:void(0)" class="arrow"><i class="ico-arrow"></i></a>
|
||||
</div>
|
||||
|
||||
<div class="tip-text">
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="foot">
|
||||
<div class="inner">
|
||||
<p>手机用户可保存上方二维码到手机中</p>
|
||||
<p>在<?php echo $typeName ?>扫一扫中选择“相册”即可</p>
|
||||
<p><div id="kfqq"></div></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="copyRight"></div>
|
||||
<!--注意下面加载顺序 顺序错乱会影响业务-->
|
||||
<script src="<?php echo $codepay_path?>/js/jquery-1.10.2.min.js"></script>
|
||||
<!--[if lt IE 8]>
|
||||
<script src="<?php echo $codepay_path?>/js/json3.min.js"></script><![endif]-->
|
||||
<script>
|
||||
var user_data =<?php echo json_encode($user_data);?>
|
||||
</script>
|
||||
<script src="<?php echo $codepay_path?>/js/notify.js"></script>
|
||||
<script src="<?php echo $codepay_path?>/js/codepay_util.js?v=2.1"></script>
|
||||
<?php echo $codepay_html;?>
|
||||
<script src="//cdn.staticfile.org/toastr.js/latest/js/toastr.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/clipboard.js/1.7.1/clipboard.min.js"></script>
|
||||
<script>
|
||||
setTimeout(function () {
|
||||
$('#use').hide()
|
||||
}, user_data.logShowTime || 10000);
|
||||
|
||||
|
||||
check_pay = function () {
|
||||
$.get("/getshop.php?trade_no=" + user_data.out_trade_no + "&r=" + Math.random(1), function (result) {
|
||||
if (result.code == 1) {
|
||||
alert('您所购买的商品已付款成功,感谢购买!');
|
||||
window.location.href = result.backurl;
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
check_pay() }, 3000);//3秒检测一次自己的数据是否成功
|
||||
}
|
||||
|
||||
}, 'json');
|
||||
}
|
||||
check_pay();
|
||||
var clipboard = new Clipboard('.copy');
|
||||
clipboard.on('success', function (e) {
|
||||
toastr.success("复制成功,可扫码付款时候粘贴到金额栏付款");
|
||||
|
||||
});
|
||||
clipboard.on('error', function(e) {
|
||||
document.querySelector('.copy');
|
||||
toastr.warning("复制失败,请记住下必须付款的金额 不能多不能少否则不能成功");
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
45
plugins/codepay/return.php
Normal file
45
plugins/codepay/return.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/* *
|
||||
* 码支付同步通知页面
|
||||
*/
|
||||
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
require_once(PAY_ROOT."inc/codepay_config.php");
|
||||
ksort($_GET); //排序get参数
|
||||
reset($_GET); //内部指针指向数组中的第一个元素
|
||||
$sign = '';
|
||||
foreach ($_GET AS $key => $val) {
|
||||
if ($val == '') continue;
|
||||
if ($key != 'sign') {
|
||||
if ($sign != '') {
|
||||
$sign .= "&";
|
||||
$urls .= "&";
|
||||
}
|
||||
$sign .= "$key=$val"; //拼接为url参数形式
|
||||
$urls .= "$key=" . urlencode($val); //拼接为url参数形式
|
||||
}
|
||||
}
|
||||
if (!$_GET['pay_no'] || md5($sign . $codepay_config['key']) != $_GET['sign']) { //不合法的数据 KEY密钥为你的密钥
|
||||
sysmsg('验证失败!');
|
||||
} else { //合法的数据
|
||||
$out_trade_no = daddslashes($_GET['param']);
|
||||
//流水号
|
||||
$trade_no = daddslashes($_GET['pay_no']);
|
||||
$price = (float)$_GET['price'];
|
||||
|
||||
if($out_trade_no == TRADE_NO && round($price,2)==round($order['money'],2)){
|
||||
$url=creat_callback($order);
|
||||
if($order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='$out_trade_no'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='$out_trade_no'");
|
||||
processOrder($order,false);
|
||||
}
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}else{
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}
|
||||
}else{
|
||||
sysmsg('订单信息校验失败');
|
||||
}
|
||||
}
|
||||
?>
|
||||
5
plugins/codepay/submit.php
Normal file
5
plugins/codepay/submit.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
echo "<script>window.location.href='/pay/codepay/qrcode/{$trade_no}/?sitename={$sitename}';</script>";
|
||||
|
||||
21
plugins/epay/config.ini
Normal file
21
plugins/epay/config.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
[config]
|
||||
;支付插件英文名称,需和目录名称一致,不能有重复
|
||||
name = "epay"
|
||||
|
||||
;支付插件显示名称
|
||||
showname = "彩虹易支付"
|
||||
|
||||
;支付插件作者
|
||||
author = "彩虹"
|
||||
|
||||
;支付插件作者链接
|
||||
link = "http://blog.cccyun.cc/"
|
||||
|
||||
;支付插件支持的支付方式,多种方式用英文,隔开,可选的有alipay,qqpay,wxpay,bank
|
||||
types = "alipay,qqpay,wxpay,bank"
|
||||
|
||||
;支付插件要求传入的参数以及参数显示名称,可选的有appid,appkey,appsecret,appurl,appmchid
|
||||
inputs = "appurl:接口地址,appid:商户ID,appkey:商户密钥"
|
||||
|
||||
;支付插件要求传入的支付方式参数
|
||||
select = ""
|
||||
28
plugins/epay/inc/epay.config.php
Normal file
28
plugins/epay/inc/epay.config.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/* *
|
||||
* 配置文件
|
||||
*/
|
||||
|
||||
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||
//商户ID
|
||||
$alipay_config['partner'] = $channel['appid'];
|
||||
|
||||
//商户KEY
|
||||
$alipay_config['key'] = $channel['appkey'];
|
||||
|
||||
|
||||
//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
||||
|
||||
|
||||
//签名方式 不需修改
|
||||
$alipay_config['sign_type'] = strtoupper('MD5');
|
||||
|
||||
//字符编码格式 目前支持 gbk 或 utf-8
|
||||
$alipay_config['input_charset']= strtolower('utf-8');
|
||||
|
||||
//访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
|
||||
$alipay_config['transport'] = 'http';
|
||||
|
||||
//支付API地址
|
||||
$alipay_config['apiurl'] = $channel['appurl'];
|
||||
?>
|
||||
168
plugins/epay/inc/epay_core.function.php
Normal file
168
plugins/epay/inc/epay_core.function.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/* *
|
||||
* 支付宝接口公用函数
|
||||
* 详细:该类是请求、通知返回两个文件所调用的公用函数核心处理文件
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-19
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
* @param $para 需要拼接的数组
|
||||
* return 拼接完成以后的字符串
|
||||
*/
|
||||
function createLinkstring($para) {
|
||||
$arg = "";
|
||||
foreach ($para as $key=>$val) {
|
||||
$arg.=$key."=".$val."&";
|
||||
}
|
||||
//去掉最后一个&字符
|
||||
$arg = substr($arg,0,-1);
|
||||
|
||||
return $arg;
|
||||
}
|
||||
/**
|
||||
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
|
||||
* @param $para 需要拼接的数组
|
||||
* return 拼接完成以后的字符串
|
||||
*/
|
||||
function createLinkstringUrlencode($para) {
|
||||
$arg = "";
|
||||
foreach ($para as $key=>$val) {
|
||||
$arg.=$key."=".urlencode($val)."&";
|
||||
}
|
||||
//去掉最后一个&字符
|
||||
$arg = substr($arg,0,-1);
|
||||
|
||||
return $arg;
|
||||
}
|
||||
/**
|
||||
* 除去数组中的空值和签名参数
|
||||
* @param $para 签名参数组
|
||||
* return 去掉空值与签名参数后的新签名参数组
|
||||
*/
|
||||
function paraFilter($para) {
|
||||
$para_filter = array();
|
||||
foreach ($para as $key=>$val) {
|
||||
if($key == "sign" || $key == "sign_type" || $val == "")continue;
|
||||
else $para_filter[$key] = $para[$key];
|
||||
}
|
||||
return $para_filter;
|
||||
}
|
||||
/**
|
||||
* 对数组排序
|
||||
* @param $para 排序前的数组
|
||||
* return 排序后的数组
|
||||
*/
|
||||
function argSort($para) {
|
||||
ksort($para);
|
||||
reset($para);
|
||||
return $para;
|
||||
}
|
||||
/**
|
||||
* 写日志,方便测试(看网站需求,也可以改成把记录存入数据库)
|
||||
* 注意:服务器需要开通fopen配置
|
||||
* @param $word 要写入日志里的文本内容 默认值:空值
|
||||
*/
|
||||
function logResult($word='') {
|
||||
$fp = fopen("log.txt","a");
|
||||
flock($fp, LOCK_EX) ;
|
||||
fwrite($fp,"执行日期:".strftime("%Y%m%d%H%M%S",time())."\n".$word."\n");
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取数据,POST模式
|
||||
* 注意:
|
||||
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了
|
||||
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem'
|
||||
* @param $url 指定URL完整路径地址
|
||||
* @param $cacert_url 指定当前工作目录绝对路径
|
||||
* @param $para 请求的数据
|
||||
* @param $input_charset 编码格式。默认值:空值
|
||||
* return 远程输出的数据
|
||||
*/
|
||||
function getHttpResponsePOST($url, $cacert_url, $para, $input_charset = '') {
|
||||
|
||||
if (trim($input_charset) != '') {
|
||||
$url = $url."_input_charset=".$input_charset;
|
||||
}
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//SSL证书认证
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);//严格认证
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
|
||||
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
|
||||
curl_setopt($curl,CURLOPT_POST,true); // post传输数据
|
||||
curl_setopt($curl,CURLOPT_POSTFIELDS,$para);// post传输数据
|
||||
$responseText = curl_exec($curl);
|
||||
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容
|
||||
curl_close($curl);
|
||||
|
||||
return $responseText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取数据,GET模式
|
||||
* 注意:
|
||||
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了
|
||||
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem'
|
||||
* @param $url 指定URL完整路径地址
|
||||
* @param $cacert_url 指定当前工作目录绝对路径
|
||||
* return 远程输出的数据
|
||||
*/
|
||||
function getHttpResponseGET($url,$cacert_url) {
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
|
||||
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//SSL证书认证
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);//严格认证
|
||||
$responseText = curl_exec($curl);
|
||||
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容
|
||||
curl_close($curl);
|
||||
|
||||
return $responseText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现多种字符编码方式
|
||||
* @param $input 需要编码的字符串
|
||||
* @param $_output_charset 输出的编码格式
|
||||
* @param $_input_charset 输入的编码格式
|
||||
* return 编码后的字符串
|
||||
*/
|
||||
function charsetEncode($input,$_output_charset ,$_input_charset) {
|
||||
$output = "";
|
||||
if(!isset($_output_charset) )$_output_charset = $_input_charset;
|
||||
if($_input_charset == $_output_charset || $input ==null ) {
|
||||
$output = $input;
|
||||
} elseif (function_exists("mb_convert_encoding")) {
|
||||
$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
|
||||
} elseif(function_exists("iconv")) {
|
||||
$output = iconv($_input_charset,$_output_charset,$input);
|
||||
} else die("sorry, you have no libs support for charset change.");
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* 实现多种字符解码方式
|
||||
* @param $input 需要解码的字符串
|
||||
* @param $_output_charset 输出的解码格式
|
||||
* @param $_input_charset 输入的解码格式
|
||||
* return 解码后的字符串
|
||||
*/
|
||||
function charsetDecode($input,$_input_charset ,$_output_charset) {
|
||||
$output = "";
|
||||
if(!isset($_input_charset) )$_input_charset = $_input_charset ;
|
||||
if($_input_charset == $_output_charset || $input ==null ) {
|
||||
$output = $input;
|
||||
} elseif (function_exists("mb_convert_encoding")) {
|
||||
$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
|
||||
} elseif(function_exists("iconv")) {
|
||||
$output = iconv($_input_charset,$_output_charset,$input);
|
||||
} else die("sorry, you have no libs support for charset changes.");
|
||||
return $output;
|
||||
}
|
||||
?>
|
||||
41
plugins/epay/inc/epay_md5.function.php
Normal file
41
plugins/epay/inc/epay_md5.function.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/* *
|
||||
* MD5
|
||||
* 详细:MD5加密
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-19
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 签名字符串
|
||||
* @param $prestr 需要签名的字符串
|
||||
* @param $key 私钥
|
||||
* return 签名结果
|
||||
*/
|
||||
function md5Sign($prestr, $key) {
|
||||
$prestr = $prestr . $key;
|
||||
return md5($prestr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证签名
|
||||
* @param $prestr 需要签名的字符串
|
||||
* @param $sign 签名结果
|
||||
* @param $key 私钥
|
||||
* return 签名结果
|
||||
*/
|
||||
function md5Verify($prestr, $sign, $key) {
|
||||
$prestr = $prestr . $key;
|
||||
$mysgin = md5($prestr);
|
||||
|
||||
if($mysgin == $sign) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
117
plugins/epay/inc/epay_notify.class.php
Normal file
117
plugins/epay/inc/epay_notify.class.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/* *
|
||||
* 类名:EpayNotify
|
||||
* 功能:彩虹易支付通知处理类
|
||||
* 详细:处理易支付接口通知返回
|
||||
*/
|
||||
|
||||
require_once(PAY_ROOT."inc/epay_core.function.php");
|
||||
require_once(PAY_ROOT."inc/epay_md5.function.php");
|
||||
|
||||
class AlipayNotify {
|
||||
|
||||
var $alipay_config;
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->alipay_config = $alipay_config;
|
||||
$this->http_verify_url = $this->alipay_config['apiurl'].'api.php?';
|
||||
}
|
||||
function AlipayNotify($alipay_config) {
|
||||
$this->__construct($alipay_config);
|
||||
}
|
||||
/**
|
||||
* 针对notify_url验证消息是否是支付宝发出的合法消息
|
||||
* @return 验证结果
|
||||
*/
|
||||
function verifyNotify(){
|
||||
if(empty($_GET)) {//判断POST来的数组是否为空
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
//生成签名结果
|
||||
$isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
|
||||
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
|
||||
$responseTxt = 'true';
|
||||
//$responseTxt = $this->getResponse($_GET["trade_no"]);
|
||||
|
||||
//验证
|
||||
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
|
||||
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
|
||||
if (preg_match("/true$/i",$responseTxt) && $isSign) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对return_url验证消息是否是支付宝发出的合法消息
|
||||
* @return 验证结果
|
||||
*/
|
||||
function verifyReturn(){
|
||||
if(empty($_GET)) {//判断POST来的数组是否为空
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
//生成签名结果
|
||||
$isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
|
||||
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
|
||||
$responseTxt = 'true';
|
||||
//$responseTxt = $this->getResponse($_GET["trade_no"]);
|
||||
|
||||
//验证
|
||||
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
|
||||
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
|
||||
if (preg_match("/true$/i",$responseTxt) && $isSign) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取返回时的签名验证结果
|
||||
* @param $para_temp 通知返回来的参数数组
|
||||
* @param $sign 返回的签名结果
|
||||
* @return 签名验证结果
|
||||
*/
|
||||
function getSignVeryfy($para_temp, $sign) {
|
||||
//除去待签名参数数组中的空值和签名参数
|
||||
$para_filter = paraFilter($para_temp);
|
||||
|
||||
//对待签名参数数组排序
|
||||
$para_sort = argSort($para_filter);
|
||||
|
||||
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
$prestr = createLinkstring($para_sort);
|
||||
|
||||
$isSgin = false;
|
||||
$isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
|
||||
|
||||
return $isSgin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取远程服务器ATN结果,验证返回URL
|
||||
* @param $notify_id 通知校验ID
|
||||
* @return 服务器ATN结果
|
||||
* 验证结果集:
|
||||
* invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空
|
||||
* true 返回正确信息
|
||||
* false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟
|
||||
*/
|
||||
function getResponse($trade_no) {
|
||||
$partner = trim($this->alipay_config['partner']);
|
||||
$veryfy_url = $this->http_verify_url."act=order&pid=" . $partner . "&trade_no=" . $trade_no;
|
||||
$responseTxt = getHttpResponseGET($veryfy_url);
|
||||
$arr = json_encode($responseTxt,true);
|
||||
if($arr['status']==1){
|
||||
return 'true';
|
||||
}else{
|
||||
return 'false';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
114
plugins/epay/inc/epay_submit.class.php
Normal file
114
plugins/epay/inc/epay_submit.class.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/* *
|
||||
* 类名:EpaySubmit
|
||||
* 功能:彩虹易支付接口请求提交类
|
||||
* 详细:构造易支付接口表单HTML文本,获取远程HTTP数据
|
||||
*/
|
||||
|
||||
require_once(PAY_ROOT."inc/epay_core.function.php");
|
||||
require_once(PAY_ROOT."inc/epay_md5.function.php");
|
||||
|
||||
class AlipaySubmit {
|
||||
|
||||
var $alipay_config;
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->alipay_config = $alipay_config;
|
||||
$this->alipay_gateway_new = $this->alipay_config['apiurl'].'submit.php?';
|
||||
$this->alipay_qrcode = $this->alipay_config['apiurl'].'qrcode.php?';
|
||||
}
|
||||
function AlipaySubmit($alipay_config) {
|
||||
$this->__construct($alipay_config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成签名结果
|
||||
* @param $para_sort 已排序要签名的数组
|
||||
* return 签名结果字符串
|
||||
*/
|
||||
function buildRequestMysign($para_sort) {
|
||||
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
$prestr = createLinkstring($para_sort);
|
||||
|
||||
$mysign = md5Sign($prestr, $this->alipay_config['key']);
|
||||
|
||||
return $mysign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成要请求给支付宝的参数数组
|
||||
* @param $para_temp 请求前的参数数组
|
||||
* @return 要请求的参数数组
|
||||
*/
|
||||
function buildRequestPara($para_temp) {
|
||||
//除去待签名参数数组中的空值和签名参数
|
||||
$para_filter = paraFilter($para_temp);
|
||||
|
||||
//对待签名参数数组排序
|
||||
$para_sort = argSort($para_filter);
|
||||
|
||||
//生成签名结果
|
||||
$mysign = $this->buildRequestMysign($para_sort);
|
||||
|
||||
//签名结果与签名方式加入请求提交参数组中
|
||||
$para_sort['sign'] = $mysign;
|
||||
$para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type']));
|
||||
|
||||
return $para_sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成要请求给支付宝的参数数组
|
||||
* @param $para_temp 请求前的参数数组
|
||||
* @return 要请求的参数数组字符串
|
||||
*/
|
||||
function buildRequestParaToString($para_temp) {
|
||||
//待请求参数数组
|
||||
$para = $this->buildRequestPara($para_temp);
|
||||
|
||||
//把参数组中所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
|
||||
$request_data = createLinkstringUrlencode($para);
|
||||
|
||||
return $request_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立请求,以表单HTML形式构造(默认)
|
||||
* @param $para_temp 请求参数数组
|
||||
* @param $method 提交方式。两个值可选:post、get
|
||||
* @param $button_name 确认按钮显示文字
|
||||
* @return 提交表单HTML文本
|
||||
*/
|
||||
function buildRequestForm($para_temp, $method='POST', $button_name='正在跳转') {
|
||||
//待请求参数数组
|
||||
$para = $this->buildRequestPara($para_temp);
|
||||
|
||||
$sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->alipay_gateway_new."_input_charset=".trim(strtolower($this->alipay_config['input_charset']))."' method='".$method."'>";
|
||||
foreach ($para as $key=>$val) {
|
||||
$sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>";
|
||||
}
|
||||
|
||||
//submit按钮控件请不要含有name属性
|
||||
$sHtml = $sHtml."<input type='submit' value='".$button_name."'></form>";
|
||||
|
||||
$sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>";
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立请求,以URL形式构造
|
||||
* @param $para_temp 请求参数数组
|
||||
* @return 提交的URL链接
|
||||
*/
|
||||
function buildRequestUrl($para_temp) {
|
||||
//待请求参数数组字符串
|
||||
$request_data = $this->buildRequestPara($para_temp);
|
||||
|
||||
//远程获取数据
|
||||
$url = $this->alipay_qrcode.http_build_query($request_data);
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
?>
|
||||
41
plugins/epay/notify.php
Normal file
41
plugins/epay/notify.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/epay.config.php");
|
||||
require_once(PAY_ROOT."inc/epay_notify.class.php");
|
||||
|
||||
//计算得出通知验证结果
|
||||
$alipayNotify = new AlipayNotify($alipay_config);
|
||||
$verify_result = $alipayNotify->verifyNotify();
|
||||
|
||||
if($verify_result) {//验证成功
|
||||
//商户订单号
|
||||
$out_trade_no = daddslashes($_GET['out_trade_no']);
|
||||
|
||||
//支付宝交易号
|
||||
$trade_no = daddslashes($_GET['trade_no']);
|
||||
|
||||
//交易状态
|
||||
$trade_status = $_GET['trade_status'];
|
||||
|
||||
//交易金额
|
||||
$money = $_GET['money'];
|
||||
|
||||
if ($_GET['trade_status'] == 'TRADE_SUCCESS') {
|
||||
//付款完成后,支付宝系统发送该交易状态通知
|
||||
if($out_trade_no == TRADE_NO && round($money,2)==round($order['money'],2) && $order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='$out_trade_no'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='$out_trade_no'");
|
||||
processOrder($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "success";
|
||||
}
|
||||
else {
|
||||
//验证失败
|
||||
echo "fail";
|
||||
}
|
||||
|
||||
?>
|
||||
50
plugins/epay/return.php
Normal file
50
plugins/epay/return.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/epay.config.php");
|
||||
require_once(PAY_ROOT."inc/epay_notify.class.php");
|
||||
|
||||
@header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
//计算得出通知验证结果
|
||||
$alipayNotify = new AlipayNotify($alipay_config);
|
||||
$verify_result = $alipayNotify->verifyReturn();
|
||||
if($verify_result) {
|
||||
//商户订单号
|
||||
$out_trade_no = daddslashes($_GET['out_trade_no']);
|
||||
|
||||
//支付宝交易号
|
||||
$trade_no = daddslashes($_GET['trade_no']);
|
||||
|
||||
//交易状态
|
||||
$trade_status = $_GET['trade_status'];
|
||||
|
||||
//交易金额
|
||||
$money = $_GET['money'];
|
||||
|
||||
if($_GET['trade_status'] == 'TRADE_SUCCESS') {
|
||||
if($out_trade_no == TRADE_NO && round($money,2)==round($order['money'],2)){
|
||||
$url=creat_callback($order);
|
||||
if($order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='$out_trade_no'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='$out_trade_no'");
|
||||
processOrder($order,false);
|
||||
}
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}else{
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}
|
||||
}else{
|
||||
sysmsg('订单信息校验失败');
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "trade_status=".$_GET['trade_status'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
//验证失败
|
||||
echo('验证失败!');
|
||||
}
|
||||
|
||||
?>
|
||||
18
plugins/epay/submit.php
Normal file
18
plugins/epay/submit.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/epay.config.php");
|
||||
require_once(PAY_ROOT."inc/epay_submit.class.php");
|
||||
$parameter = array(
|
||||
"pid" => trim($alipay_config['partner']),
|
||||
"type" => $order['typename'],
|
||||
"notify_url" => $conf['localurl'].'pay/epay/notify/'.TRADE_NO.'/',
|
||||
"return_url" => $siteurl.'pay/epay/return/'.TRADE_NO.'/',
|
||||
"out_trade_no" => $trade_no,
|
||||
"name" => $order['name'],
|
||||
"money" => $order['money']
|
||||
);
|
||||
//建立请求
|
||||
$alipaySubmit = new AlipaySubmit($alipay_config);
|
||||
$html_text = $alipaySubmit->buildRequestForm($parameter);
|
||||
echo $html_text;
|
||||
21
plugins/jdpay/config.ini
Normal file
21
plugins/jdpay/config.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
[config]
|
||||
;支付插件英文名称,需和目录名称一致,不能有重复
|
||||
name = "jdpay"
|
||||
|
||||
;支付插件显示名称
|
||||
showname = "京东支付"
|
||||
|
||||
;支付插件作者
|
||||
author = "京东"
|
||||
|
||||
;支付插件作者链接
|
||||
link = "https://www.jdpay.com/"
|
||||
|
||||
;支付插件支持的支付方式,多种方式用英文,隔开,可选的有alipay,qqpay,wxpay,bank
|
||||
types = "jdpay"
|
||||
|
||||
;支付插件要求传入的参数以及参数显示名称,可选的有appid,appkey,appsecret,appurl,appmchid
|
||||
inputs = "appid:商户号,appkey:商户DES密钥"
|
||||
|
||||
;支付插件要求传入的支付方式参数
|
||||
select = ""
|
||||
46
plugins/jdpay/inc/cert/config.ini
Normal file
46
plugins/jdpay/inc/cert/config.ini
Normal file
@@ -0,0 +1,46 @@
|
||||
[wepay]
|
||||
;======================= 商户开通的商户号
|
||||
merchantNum=22294531
|
||||
|
||||
;======================= 商户DES密钥
|
||||
desKey=ta4E/aspLA3lgFGKmNDNRYU92RkZ4w2t
|
||||
|
||||
;=======================京东支付在线支付PC端请求地址
|
||||
serverPayUrl=https://wepay.jd.com/jdpay/saveOrder
|
||||
|
||||
;=======================京东支付在线支付H5端请求地址
|
||||
;serverPayUrl=https://h5pay.jd.com/jdpay/saveOrder
|
||||
|
||||
;=======================京东查询服务地址
|
||||
serverQueryUrl=https://paygate.jd.com/service/query
|
||||
|
||||
;=======================退款服务地址
|
||||
refundUrl=https://paygate.jd.com/service/refund
|
||||
|
||||
;=======================callback地址
|
||||
callbackUrl=http://localhost/jdPay2Demo/com/jdjr/pay/demo/action/CallBack.php
|
||||
|
||||
;=======================notify地址
|
||||
notifyUrl=http://localhost/jdPay2Demo/com/jdjr/pay/demo/action/AsnyNotify.php
|
||||
|
||||
;======================扫码创建订单
|
||||
uniorderUrl= https://paygate.jd.com/service/uniorder
|
||||
|
||||
;======================交易号查退款
|
||||
queryRefundUrl=https://paygate.jd.com/service/queryRefund
|
||||
|
||||
;==========撤销地址
|
||||
revokeUrl=https://paygate.jd.com/service/revoke
|
||||
|
||||
;=========付款码支付
|
||||
fkmPayUrl=https://paygate.jd.com/service/fkmPay
|
||||
|
||||
;=========用户关系查询地址
|
||||
getUserRelationUrl=https://paygate.jd.com/service/getUserRelation
|
||||
|
||||
;=========用户关系解绑地址
|
||||
cancelUserRelationUrl=https://paygate.jd.com/service/cancelUserRelation
|
||||
|
||||
;=========白条策略查询地址
|
||||
queryBaiTiaoFQUrl=https://paygate.jd.com/service/queryBaiTiaoFQ
|
||||
|
||||
18
plugins/jdpay/inc/cert/seller_rsa_private_key.pem
Normal file
18
plugins/jdpay/inc/cert/seller_rsa_private_key.pem
Normal file
@@ -0,0 +1,18 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALXf6twUqul1TATO
|
||||
+5nA66p2wjnRd+g96IXpfV6Sf8WXxwizGj+L19LQYRBXpZHmRh82prJ48d0FcHbo
|
||||
CiN8pKutnuZrrKYhvORysOc5bVli0hcCn1TfYDoUWJ1UhjUQloqZKWjUz6LV9QY6
|
||||
bIZ1W4+Hmw6HK1bfFwUq0WzIGkJNAgMBAAECgYBlIFQeev9tP+M86TnMjBB9f/sO
|
||||
2wGpCIM5slIbO6n/3By3IZ7+pmsitOrDg3h0X22t/V1C7yzMkDGwa+T3Rl7ogwc4
|
||||
UNVj0ZQorOTx3OEPx3nP1yT3zmJ9djKaHKAmee4XmhQHdqqIuMT2XQaqatBzcsnP
|
||||
+Jnw/WVOsIJIqMeFAQJBAP9yq4hE+UfM/YSXZ5JR33k9RolUUq8S/elmeJIDo/3N
|
||||
2qDmzLjOr9iEZHxioc8JOxubtZ0BxA+NdfKz4v0BSpkCQQC2RIrAPRj9vOk6GfT9
|
||||
W1hbJ4GdnzTb+4vp3RDQQ3x9JGXzWFlg8xJT1rNgM8R95Gkxn3KGnYHJQTLlCsIy
|
||||
2FnVAkAWXolM3pVhxz6wHL4SHx9Ns6L4payz7hrUFIgcaTs0H5G0o2FsEZVuhXFz
|
||||
PwPiaHGHomQOAriTkBSzEzOeaj2JAkEAtYUFefZfETQ2QbrgFgIGuKFboJKRnhOi
|
||||
f8G9oOvU6vx43CS8vqTVN9G2yrRDl+0GJnlZIV9zhe78tMZGKUT2EQJAHQawBKGl
|
||||
XlMe49Fo24yOy5DvKeohobjYqzJAtbqaAH7iIQTpOZx91zUcL/yG4dWS6r+wGO7Z
|
||||
1RKpupOJLKG3lA==
|
||||
-----END PRIVATE KEY-----
|
||||
|
||||
|
||||
6
plugins/jdpay/inc/cert/wy_rsa_public_key.pem
Normal file
6
plugins/jdpay/inc/cert/wy_rsa_public_key.pem
Normal file
@@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCKE5N2xm3NIrXON8Zj19GNtLZ8
|
||||
xwEQ6uDIyrS3S03UhgBJMkGl4msfq4Xuxv6XUAN7oU1XhV3/xtabr9rXto4Ke3d6
|
||||
WwNbxwXnK5LSgsQc1BhT5NcXHXpGBdt7P8NMez5qGieOKqHGvT0qvjyYnYA29a8Z
|
||||
4wzNR7vAVHp36uD5RwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
34
plugins/jdpay/inc/common/HttpUtils.php
Normal file
34
plugins/jdpay/inc/common/HttpUtils.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HTTP工具类
|
||||
*
|
||||
* @author wywangzhenlong
|
||||
*
|
||||
*/
|
||||
class HttpUtils {
|
||||
|
||||
public function http_post_data($url, $data_string ) {
|
||||
|
||||
$TIMEOUT = 30; //超时时间(秒)
|
||||
|
||||
$ch = curl_init ();
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $TIMEOUT);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $TIMEOUT-2);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml;charset=utf-8'));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$return_content = curl_exec($ch);
|
||||
$return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
return array (
|
||||
$return_code,
|
||||
$return_content
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
18
plugins/jdpay/inc/common/RSAUtils.php
Normal file
18
plugins/jdpay/inc/common/RSAUtils.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
class RSAUtils{
|
||||
public static function encryptByPrivateKey($data) {
|
||||
$pi_key = openssl_pkey_get_private(file_get_contents(PAY_ROOT.'inc/cert/seller_rsa_private_key.pem'));//这个函数可用来判断私钥是否是可用的,可用返回资源id Resource id
|
||||
$encrypted="";
|
||||
openssl_private_encrypt($data,$encrypted,$pi_key,OPENSSL_PKCS1_PADDING);//私钥加密
|
||||
$encrypted = base64_encode($encrypted);//加密后的内容通常含有特殊字符,需要编码转换下,在网络间通过url传输时要注意base64编码是否是url安全的
|
||||
return $encrypted;
|
||||
}
|
||||
|
||||
public static function decryptByPublicKey($data) {
|
||||
$pu_key = openssl_pkey_get_public(file_get_contents(PAY_ROOT.'inc/cert/wy_rsa_public_key.pem'));//这个函数可用来判断公钥是否是可用的,可用返回资源id Resource id
|
||||
$decrypted = "";
|
||||
$data = base64_decode($data);
|
||||
openssl_public_decrypt($data,$decrypted,$pu_key);//公钥解密
|
||||
return $decrypted;
|
||||
}
|
||||
}
|
||||
49
plugins/jdpay/inc/common/SignUtil.php
Normal file
49
plugins/jdpay/inc/common/SignUtil.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
include PAY_ROOT.'inc/common/RSAUtils.php';
|
||||
|
||||
/**
|
||||
* 签名
|
||||
*
|
||||
*
|
||||
*/
|
||||
class SignUtil {
|
||||
|
||||
// public static $unSignKeyList = array (
|
||||
// "merchantSign",
|
||||
// "version",
|
||||
// "successCallbackUrl",
|
||||
// "forPayLayerUrl"
|
||||
// );
|
||||
public static function signWithoutToHex($params,$unSignKeyList) {
|
||||
ksort($params);
|
||||
$sourceSignString = SignUtil::signString ( $params, $unSignKeyList );
|
||||
//echo "sourceSignString=".htmlspecialchars($sourceSignString)."<br/>";
|
||||
//error_log("=========>sourceSignString:".$sourceSignString, 0);
|
||||
$sha256SourceSignString = hash ( "sha256", $sourceSignString);
|
||||
//error_log($sha256SourceSignString, 0);
|
||||
//echo "sha256SourceSignString=".htmlspecialchars($sha256SourceSignString)."<br/>";
|
||||
return RSAUtils::encryptByPrivateKey ($sha256SourceSignString);
|
||||
}
|
||||
|
||||
public static function sign($params,$unSignKeyList) {
|
||||
ksort($params);
|
||||
$sourceSignString = SignUtil::signString ( $params, $unSignKeyList );
|
||||
//error_log($sourceSignString, 0);
|
||||
$sha256SourceSignString = hash ( "sha256", $sourceSignString);
|
||||
//error_log($sha256SourceSignString, 0);
|
||||
return RSAUtils::encryptByPrivateKey ($sha256SourceSignString);
|
||||
}
|
||||
|
||||
public static function signString($data, $unSignKeyList) {
|
||||
$linkStr="";
|
||||
$isFirst=true;
|
||||
ksort($data);
|
||||
foreach($data as $key=>$value){
|
||||
if($value=="" || in_array($key, $unSignKeyList)) continue;
|
||||
$linkStr.=$key."=".$value."&";
|
||||
}
|
||||
return substr($linkStr,0,-1);
|
||||
}
|
||||
}
|
||||
59
plugins/jdpay/inc/common/TDESUtil.php
Normal file
59
plugins/jdpay/inc/common/TDESUtil.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
class TDESUtil {
|
||||
|
||||
/**
|
||||
* 将元数据进行补位后进行3DES加密
|
||||
* <p/>
|
||||
* 补位后 byte[] = 描述有效数据长度(int)的byte[]+原始数据byte[]+补位byte[]
|
||||
*
|
||||
* @param
|
||||
* sourceData 元数据字符串
|
||||
* @return 返回3DES加密后的16进制表示的字符串
|
||||
*/
|
||||
public static function encrypt2HexStr($keys, $sourceData) {
|
||||
$length = strlen($sourceData);
|
||||
$result = '';
|
||||
for($i = 0; $i < 4; $i ++) {
|
||||
$shift = (4 - 1 - $i) * 8;
|
||||
$result .= chr(($length >> $shift) & 0x000000FF);
|
||||
}
|
||||
$result .= $sourceData;
|
||||
$add = 8 - ($length+4) % 8;
|
||||
if($add>0){
|
||||
for($i=0; $i<$add; $i++){
|
||||
$result .= chr(0);
|
||||
}
|
||||
}
|
||||
$desdata = self::encrypt( $result, $keys );
|
||||
return bin2hex( $desdata );
|
||||
}
|
||||
|
||||
/**
|
||||
* 3DES 解密 进行了补位的16进制表示的字符串数据
|
||||
*
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public static function decrypt4HexStr($keys, $data) {
|
||||
$unDesResult = self::decrypt(hex2bin($data),$keys);
|
||||
|
||||
$length=0;
|
||||
for($i = 0; $i < 4; $i ++) {
|
||||
$shift = (4 - 1 - $i) * 8;
|
||||
$length += (ord($unDesResult[$i]) & 0x000000FF) << $shift;
|
||||
}
|
||||
$result = substr($unDesResult, 4, $length);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 加密算法
|
||||
public static function encrypt($input, $key) {
|
||||
return openssl_encrypt($input, 'des-ede3', $key, OPENSSL_NO_PADDING, "");
|
||||
}
|
||||
// 解密算法
|
||||
public static function decrypt($encrypted, $key) {
|
||||
return openssl_decrypt($encrypted, 'des-ede3', $key, OPENSSL_NO_PADDING, "");
|
||||
}
|
||||
}
|
||||
123
plugins/jdpay/inc/common/XMLUtil.php
Normal file
123
plugins/jdpay/inc/common/XMLUtil.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
include PAY_ROOT.'inc/common/RSAUtils.php';
|
||||
include PAY_ROOT.'inc/common/TDESUtil.php';
|
||||
|
||||
class XMLUtil{
|
||||
public static function arrtoxml($arr,$dom=0,$item=0){
|
||||
//ksort($arr);
|
||||
if (!$dom){
|
||||
|
||||
$dom = new DOMDocument("1.0","UTF-8");
|
||||
}
|
||||
if(!$item){
|
||||
$item = $dom->createElement("jdpay");
|
||||
$item = $dom->appendChild($item);
|
||||
}
|
||||
|
||||
foreach ($arr as $key=>$val){
|
||||
$itemx = $dom->createElement(is_string($key)?$key:"item");
|
||||
$itemx = $item->appendChild($itemx);
|
||||
if (!is_array($val)){
|
||||
$text = $dom->createTextNode($val);
|
||||
$text = $itemx->appendChild($text);
|
||||
|
||||
}else {
|
||||
XMLUtil::arrtoxml($val,$dom,$itemx);
|
||||
}
|
||||
}
|
||||
return $dom;
|
||||
}
|
||||
|
||||
public static function xmlToString($dom){
|
||||
$xmlStr = $dom->saveXML();
|
||||
$xmlStr = str_replace("\r", "", $xmlStr);
|
||||
$xmlStr = str_replace("\n", "", $xmlStr);
|
||||
$xmlStr = str_replace("\t", "", $xmlStr);
|
||||
$xmlStr = preg_replace("/>\s+</", "><", $xmlStr);
|
||||
$xmlStr = preg_replace("/\s+\/>/", "/>", $xmlStr);
|
||||
$xmlStr = str_replace("=utf-8", "=UTF-8", $xmlStr);
|
||||
return $xmlStr;
|
||||
}
|
||||
|
||||
public static function encryptReqXml($param){
|
||||
$dom = XMLUtil::arrtoxml($param);
|
||||
$xmlStr = XMLUtil::xmlToString($dom);
|
||||
//echo "源串:".htmlspecialchars($xmlStr)."<br/>";
|
||||
$sha256SourceSignString = hash("sha256", $xmlStr);
|
||||
//echo "摘要:".$sha256SourceSignString."<br/>";
|
||||
$sign = RSAUtils::encryptByPrivateKey($sha256SourceSignString);
|
||||
$rootDom = $dom->getElementsByTagName("jdpay");
|
||||
$signDom = $dom->createElement("sign");
|
||||
$signDom = $rootDom[0]->appendChild($signDom);
|
||||
$signText = $dom->createTextNode($sign);
|
||||
$signText = $signDom->appendChild($signText);
|
||||
$data = XMLUtil::xmlToString($dom);
|
||||
//echo "封装后:".htmlspecialchars($data)."<br/>";
|
||||
|
||||
$desKey = Confid_desKey;
|
||||
$keys = base64_decode($desKey);
|
||||
$encrypt = TDESUtil::encrypt2HexStr($keys, $data);
|
||||
//echo "3DES后:".$encrypt."<br/>";
|
||||
$encrypt = base64_encode($encrypt);
|
||||
//echo "base64后:".$encrypt."<br/>";
|
||||
$reqParam;
|
||||
$reqParam["version"]=$param["version"];
|
||||
$reqParam["merchant"]=$param["merchant"];
|
||||
$reqParam["encrypt"]=$encrypt;
|
||||
$reqDom = XMLUtil::arrtoxml($reqParam,0,0);
|
||||
$reqXmlStr = XMLUtil::xmlToString($reqDom);
|
||||
//echo htmlspecialchars($reqXmlStr)."<br/>";
|
||||
return $reqXmlStr;
|
||||
}
|
||||
|
||||
public static function decryptResXml($resultData,&$resData){
|
||||
$resultXml = simplexml_load_string($resultData);
|
||||
$resultObj = json_decode(json_encode($resultXml),TRUE);
|
||||
$encryptStr = $resultObj["encrypt"];
|
||||
$encryptStr=base64_decode($encryptStr);
|
||||
$desKey = Confid_desKey;
|
||||
$keys = base64_decode($desKey);
|
||||
$reqBody = TDESUtil::decrypt4HexStr($keys, $encryptStr);
|
||||
//echo "请求返回encrypt Des解密后:".$reqBody."\n";
|
||||
|
||||
$bodyXml = simplexml_load_string($reqBody);
|
||||
//echo "请求返回encrypt Des解密后:".$bodyXml->saveXML()."\n";
|
||||
$resData = json_decode(json_encode($bodyXml),TRUE);
|
||||
|
||||
$inputSign = $resData["sign"];
|
||||
// $bodyDom = XMLUtil::arrtoxml($bodyObj,0,0);
|
||||
// $rootDom = $bodyDom->getElementsByTagName("jdpay");
|
||||
// $signNodelist = $rootDom[0]->getElementsByTagName("sign");
|
||||
// $rootDom[0]->removeChild($signNodelist[0]);
|
||||
|
||||
// $reqBodyStr = XMLUtil::xmlToString($bodyDom);
|
||||
|
||||
$startIndex = strpos($reqBody,"<sign>");
|
||||
$endIndex = strpos($reqBody,"</sign>");
|
||||
|
||||
if($startIndex!=false && $endIndex!=false){
|
||||
$xmls = substr($reqBody, 0,$startIndex);
|
||||
$xmle = substr($reqBody,$endIndex+7,strlen($reqBody));
|
||||
$xml=$xmls.$xmle;
|
||||
}
|
||||
|
||||
//echo "本地摘要原串:".$xml."\n";
|
||||
$sha256SourceSignString = hash("sha256", $xml);
|
||||
//echo "本地摘要:".$sha256SourceSignString."\n";
|
||||
|
||||
$decryptStr = RSAUtils::decryptByPublicKey($inputSign);
|
||||
//echo "解密后摘要:".$decryptStr."\n";
|
||||
if($decryptStr==$sha256SourceSignString){
|
||||
//echo "验签成功<br/>";
|
||||
$flag=true;
|
||||
}else{
|
||||
//echo "验签失败<br/>";
|
||||
$flag=false;
|
||||
}
|
||||
$resData["version"]=$resultObj["version"];
|
||||
$resData["merchant"]=$resultObj["merchant"];
|
||||
$resData["result"]=$resultObj["result"];
|
||||
//echo var_dump($resData);
|
||||
return $flag;
|
||||
}
|
||||
}
|
||||
27
plugins/jdpay/notify.php
Normal file
27
plugins/jdpay/notify.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/* *
|
||||
* 京东支付异步通知页面
|
||||
*/
|
||||
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
require_once(PAY_ROOT."inc/common/XMLUtil.php");
|
||||
|
||||
define("Confid_desKey",$channel['appkey']);
|
||||
$xml = file_get_contents("php://input");
|
||||
$flag = XMLUtil::decryptResXml($xml, $param);
|
||||
//var_dump($flag);
|
||||
if($flag){
|
||||
echo "success";
|
||||
$trade_no = daddslashes($param["tradeNum"]);
|
||||
$out_trade_no = daddslashes($param["tradeNum"]);
|
||||
if($param["status"]==2) {
|
||||
if($out_trade_no == TRADE_NO && $param["amount"]==strval($order['money']*100) && $order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='".TRADE_NO."'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='".TRADE_NO."'");
|
||||
processOrder($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo "error";
|
||||
}
|
||||
39
plugins/jdpay/refund.php
Normal file
39
plugins/jdpay/refund.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
* 京东支付退款接口
|
||||
*/
|
||||
if(!defined('IN_REFUND'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/common/XMLUtil.php");
|
||||
require_once(PAY_ROOT."inc/common/HttpUtils.php");
|
||||
|
||||
define("Confid_desKey",$channel['appkey']);
|
||||
|
||||
$param["version"]="V2.0";
|
||||
$param["merchant"]=$channel['appid'];
|
||||
$param["tradeNum"]=$order['trade_no'].rand(000,999);
|
||||
$param["oTradeNum"]=$order['api_trade_no'];
|
||||
$param["amount"]=$order['realmoney']*100;
|
||||
$param["currency"]="CNY";
|
||||
|
||||
$reqXmlStr = XMLUtil::encryptReqXml($param);
|
||||
$url = 'https://paygate.jd.com/service/refund';
|
||||
|
||||
$httputil = new HttpUtils();
|
||||
list ( $return_code, $return_content ) = $httputil->http_post_data($url, $reqXmlStr);
|
||||
//echo $return_content."\n";
|
||||
|
||||
$flag=XMLUtil::decryptResXml($return_content,$resData);
|
||||
//echo var_dump($resData);
|
||||
|
||||
if($flag){
|
||||
if($resData['status'] == "1"){
|
||||
$result = ['code'=>0, 'trade_no'=>$resData['oTradeNum'], 'refund_fee'=>$resData['amount']];
|
||||
}else{
|
||||
$result = ['code'=>-1, 'msg'=>'['.$resData['result']['code'].']'.$resData['result']['desc']];
|
||||
}
|
||||
}else{
|
||||
$result = ['code'=>-1, 'msg'=>'验签失败'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
57
plugins/jdpay/return.php
Normal file
57
plugins/jdpay/return.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/* *
|
||||
* 京东支付同步通知页面
|
||||
*/
|
||||
|
||||
require_once('./includes/common.php');
|
||||
require_once(PAY_ROOT."inc/common/SignUtil.php");
|
||||
require_once(PAY_ROOT."inc/common/TDESUtil.php");
|
||||
|
||||
$desKey = $channel['appkey'];
|
||||
$keys = base64_decode($desKey);
|
||||
$param = array();
|
||||
if(!empty($_POST["tradeNum"])){
|
||||
$param["tradeNum"]=TDESUtil::decrypt4HexStr($keys, $_POST["tradeNum"]);
|
||||
}
|
||||
if(!empty($_POST["amount"])){
|
||||
$param["amount"]=TDESUtil::decrypt4HexStr($keys, $_POST["amount"]);
|
||||
}
|
||||
if(!empty($_POST["currency"])){
|
||||
$param["currency"]=TDESUtil::decrypt4HexStr($keys, $_POST["currency"]);
|
||||
}
|
||||
if(!empty($_POST["tradeTime"])){
|
||||
$param["tradeTime"]=TDESUtil::decrypt4HexStr($keys, $_POST["tradeTime"]);
|
||||
}
|
||||
if(!empty($_POST["status"])){
|
||||
$param["status"]=TDESUtil::decrypt4HexStr($keys, $_POST["status"]);
|
||||
}
|
||||
|
||||
$sign = $_POST["sign"];
|
||||
$strSourceData = SignUtil::signString($param, array());
|
||||
//echo "strSourceData=".htmlspecialchars($strSourceData)."<br/>";
|
||||
//$decryptBASE64Arr = base64_decode($sign);
|
||||
$decryptStr = RSAUtils::decryptByPublicKey($sign);
|
||||
//echo "decryptStr=".htmlspecialchars($decryptStr)."<br/>";
|
||||
$sha256SourceSignString = hash ( "sha256", $strSourceData);
|
||||
//echo "sha256SourceSignString=".htmlspecialchars($sha256SourceSignString)."<br/>";
|
||||
if($decryptStr == $sha256SourceSignString){
|
||||
$trade_no = daddslashes($param["tradeNum"]);
|
||||
$out_trade_no = daddslashes($param["tradeNum"]);
|
||||
if($out_trade_no == TRADE_NO && $param["amount"]==$order['money']*100 && $order['status']==0){
|
||||
$url=creat_callback($order);
|
||||
|
||||
if($order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='".TRADE_NO."'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='".TRADE_NO."'");
|
||||
processOrder($order,false);
|
||||
}
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}else{
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
}
|
||||
}else{
|
||||
sysmsg('订单信息校验失败');
|
||||
}
|
||||
}else{
|
||||
sysmsg("验证签名失败!strSourceData=".htmlspecialchars($strSourceData));
|
||||
}
|
||||
65
plugins/jdpay/submit.php
Normal file
65
plugins/jdpay/submit.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false && !$submit2){
|
||||
echo "<script>window.location.href='/submit2.php?typeid={$order['type']}&trade_no={$trade_no}';</script>";exit;
|
||||
}
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){
|
||||
include(SYSTEM_ROOT.'pages/wxopen.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(PAY_ROOT."inc/common/SignUtil.php");
|
||||
require_once(PAY_ROOT."inc/common/TDESUtil.php");
|
||||
|
||||
if(checkmobile()==true){
|
||||
$oriUrl = 'https://h5pay.jd.com/jdpay/saveOrder';
|
||||
}else{
|
||||
$oriUrl = 'https://wepay.jd.com/jdpay/saveOrder';
|
||||
}
|
||||
|
||||
$param=array();
|
||||
$param["version"]='V2.0';
|
||||
$param["merchant"]=$channel['appid'];
|
||||
$param["tradeNum"]=$trade_no;
|
||||
$param["tradeName"]=$ordername;
|
||||
$param["tradeTime"]= date('YmdHis');
|
||||
$param["amount"]= strval($order['money']*100);
|
||||
$param["currency"]= 'CNY';
|
||||
$param["callbackUrl"]= $siteurl.'pay/jdpay/return/'.TRADE_NO.'/';
|
||||
$param["notifyUrl"]= $conf['localurl'].'pay/jdpay/notify/'.TRADE_NO.'/';
|
||||
$param["ip"]= $clientip;
|
||||
$param["userId"]= '';
|
||||
$param["orderType"]= '1';
|
||||
$unSignKeyList = array("sign");
|
||||
$desKey = $channel['appkey'];
|
||||
$sign = SignUtil::signWithoutToHex($param, $unSignKeyList);
|
||||
//echo $sign."<br/>";
|
||||
$param["sign"] = $sign;
|
||||
$keys = base64_decode($desKey);
|
||||
|
||||
$param["tradeNum"]=TDESUtil::encrypt2HexStr($keys, $param["tradeNum"]);
|
||||
if($param["tradeName"] != null && $param["tradeName"]!=""){
|
||||
$param["tradeName"]=TDESUtil::encrypt2HexStr($keys, $param["tradeName"]);
|
||||
}
|
||||
$param["tradeTime"]=TDESUtil::encrypt2HexStr($keys, $param["tradeTime"]);
|
||||
$param["amount"]=TDESUtil::encrypt2HexStr($keys, $param["amount"]);
|
||||
$param["currency"]=TDESUtil::encrypt2HexStr($keys, $param["currency"]);
|
||||
$param["callbackUrl"]=TDESUtil::encrypt2HexStr($keys, $param["callbackUrl"]);
|
||||
$param["notifyUrl"]=TDESUtil::encrypt2HexStr($keys, $param["notifyUrl"]);
|
||||
$param["ip"]=TDESUtil::encrypt2HexStr($keys, $param["ip"]);
|
||||
|
||||
if($param["userId"] != null && $param["userId"]!=""){
|
||||
$param["userId"]=TDESUtil::encrypt2HexStr($keys, $param["userId"]);
|
||||
}
|
||||
if($param["orderType"] != null && $param["orderType"]!=""){
|
||||
$param["orderType"]=TDESUtil::encrypt2HexStr($keys, $param["orderType"]);
|
||||
}
|
||||
//print_R($param);exit;
|
||||
|
||||
echo '<form action="'.$oriUrl.'" method="post" id="dopay">';
|
||||
foreach($param as $k => $v) {
|
||||
echo "<input type=\"hidden\" name=\"{$k}\" value=\"{$v}\" />\n";
|
||||
}
|
||||
echo '<input type="submit" value="正在跳转"></form><script>document.getElementById("dopay").submit();</script>';
|
||||
?>
|
||||
21
plugins/micro/config.ini
Normal file
21
plugins/micro/config.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
[config]
|
||||
;支付插件英文名称,需和目录名称一致,不能有重复
|
||||
name = "micro"
|
||||
|
||||
;支付插件显示名称
|
||||
showname = "小微支付"
|
||||
|
||||
;支付插件作者
|
||||
author = "小微支付"
|
||||
|
||||
;支付插件作者链接
|
||||
link = "http://blog.cccyun.cc/"
|
||||
|
||||
;支付插件支持的支付方式,多种方式用英文,隔开,可选的有alipay,qqpay,wxpay,bank
|
||||
types = "alipay,wxpay"
|
||||
|
||||
;支付插件要求传入的参数以及参数显示名称,可选的有appid,appkey,appsecret,appurl,appmchid
|
||||
inputs = "appurl:接口地址,appid:APPID,appkey:APPKEY,appmchid:商户号MCHID"
|
||||
|
||||
;支付插件要求传入的支付方式参数
|
||||
select = ""
|
||||
32
plugins/micro/inc/micro.config.php
Normal file
32
plugins/micro/inc/micro.config.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/* *
|
||||
* 微信小微支付配置文件
|
||||
*/
|
||||
|
||||
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||
//支付API地址
|
||||
$alipay_config['apiurl'] = $channel['appurl'];
|
||||
|
||||
//商户ID
|
||||
$alipay_config['appid'] = $channel['appid'];
|
||||
|
||||
//商户KEY
|
||||
$alipay_config['key'] = $channel['appkey'];
|
||||
|
||||
//MCHID
|
||||
$alipay_config['mchid'] = $channel['appmchid'];
|
||||
|
||||
|
||||
//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
||||
|
||||
|
||||
//签名方式 不需修改
|
||||
$alipay_config['sign_type'] = strtoupper('MD5');
|
||||
|
||||
//字符编码格式 目前支持 gbk 或 utf-8
|
||||
$alipay_config['input_charset']= strtolower('utf-8');
|
||||
|
||||
//访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
|
||||
$alipay_config['transport'] = 'http';
|
||||
|
||||
?>
|
||||
168
plugins/micro/inc/micro_core.function.php
Normal file
168
plugins/micro/inc/micro_core.function.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/* *
|
||||
* 支付宝接口公用函数
|
||||
* 详细:该类是请求、通知返回两个文件所调用的公用函数核心处理文件
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-19
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
* @param $para 需要拼接的数组
|
||||
* return 拼接完成以后的字符串
|
||||
*/
|
||||
function createLinkstring($para) {
|
||||
$arg = "";
|
||||
foreach ($para as $key=>$val) {
|
||||
$arg.=$key."=".$val."&";
|
||||
}
|
||||
//去掉最后一个&字符
|
||||
$arg = substr($arg,0,-1);
|
||||
|
||||
return $arg;
|
||||
}
|
||||
/**
|
||||
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
|
||||
* @param $para 需要拼接的数组
|
||||
* return 拼接完成以后的字符串
|
||||
*/
|
||||
function createLinkstringUrlencode($para) {
|
||||
$arg = "";
|
||||
foreach ($para as $key=>$val) {
|
||||
$arg.=$key."=".urlencode($val)."&";
|
||||
}
|
||||
//去掉最后一个&字符
|
||||
$arg = substr($arg,0,-1);
|
||||
|
||||
return $arg;
|
||||
}
|
||||
/**
|
||||
* 除去数组中的空值和签名参数
|
||||
* @param $para 签名参数组
|
||||
* return 去掉空值与签名参数后的新签名参数组
|
||||
*/
|
||||
function paraFilter($para) {
|
||||
$para_filter = array();
|
||||
foreach ($para as $key=>$val) {
|
||||
if($key == "sign" || $key == "sign_type" || $val == "")continue;
|
||||
else $para_filter[$key] = $para[$key];
|
||||
}
|
||||
return $para_filter;
|
||||
}
|
||||
/**
|
||||
* 对数组排序
|
||||
* @param $para 排序前的数组
|
||||
* return 排序后的数组
|
||||
*/
|
||||
function argSort($para) {
|
||||
ksort($para);
|
||||
reset($para);
|
||||
return $para;
|
||||
}
|
||||
/**
|
||||
* 写日志,方便测试(看网站需求,也可以改成把记录存入数据库)
|
||||
* 注意:服务器需要开通fopen配置
|
||||
* @param $word 要写入日志里的文本内容 默认值:空值
|
||||
*/
|
||||
function logResult($word='') {
|
||||
$fp = fopen("log.txt","a");
|
||||
flock($fp, LOCK_EX) ;
|
||||
fwrite($fp,"执行日期:".strftime("%Y%m%d%H%M%S",time())."\n".$word."\n");
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取数据,POST模式
|
||||
* 注意:
|
||||
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了
|
||||
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem'
|
||||
* @param $url 指定URL完整路径地址
|
||||
* @param $cacert_url 指定当前工作目录绝对路径
|
||||
* @param $para 请求的数据
|
||||
* @param $input_charset 编码格式。默认值:空值
|
||||
* return 远程输出的数据
|
||||
*/
|
||||
function getHttpResponsePOST($url, $cacert_url, $para, $input_charset = '') {
|
||||
|
||||
if (trim($input_charset) != '') {
|
||||
$url = $url."_input_charset=".$input_charset;
|
||||
}
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//SSL证书认证
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);//严格认证
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
|
||||
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
|
||||
curl_setopt($curl,CURLOPT_POST,true); // post传输数据
|
||||
curl_setopt($curl,CURLOPT_POSTFIELDS,$para);// post传输数据
|
||||
$responseText = curl_exec($curl);
|
||||
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容
|
||||
curl_close($curl);
|
||||
|
||||
return $responseText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取数据,GET模式
|
||||
* 注意:
|
||||
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了
|
||||
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem'
|
||||
* @param $url 指定URL完整路径地址
|
||||
* @param $cacert_url 指定当前工作目录绝对路径
|
||||
* return 远程输出的数据
|
||||
*/
|
||||
function getHttpResponseGET($url,$cacert_url) {
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
|
||||
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//SSL证书认证
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);//严格认证
|
||||
$responseText = curl_exec($curl);
|
||||
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容
|
||||
curl_close($curl);
|
||||
|
||||
return $responseText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现多种字符编码方式
|
||||
* @param $input 需要编码的字符串
|
||||
* @param $_output_charset 输出的编码格式
|
||||
* @param $_input_charset 输入的编码格式
|
||||
* return 编码后的字符串
|
||||
*/
|
||||
function charsetEncode($input,$_output_charset ,$_input_charset) {
|
||||
$output = "";
|
||||
if(!isset($_output_charset) )$_output_charset = $_input_charset;
|
||||
if($_input_charset == $_output_charset || $input ==null ) {
|
||||
$output = $input;
|
||||
} elseif (function_exists("mb_convert_encoding")) {
|
||||
$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
|
||||
} elseif(function_exists("iconv")) {
|
||||
$output = iconv($_input_charset,$_output_charset,$input);
|
||||
} else die("sorry, you have no libs support for charset change.");
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* 实现多种字符解码方式
|
||||
* @param $input 需要解码的字符串
|
||||
* @param $_output_charset 输出的解码格式
|
||||
* @param $_input_charset 输入的解码格式
|
||||
* return 解码后的字符串
|
||||
*/
|
||||
function charsetDecode($input,$_input_charset ,$_output_charset) {
|
||||
$output = "";
|
||||
if(!isset($_input_charset) )$_input_charset = $_input_charset ;
|
||||
if($_input_charset == $_output_charset || $input ==null ) {
|
||||
$output = $input;
|
||||
} elseif (function_exists("mb_convert_encoding")) {
|
||||
$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
|
||||
} elseif(function_exists("iconv")) {
|
||||
$output = iconv($_input_charset,$_output_charset,$input);
|
||||
} else die("sorry, you have no libs support for charset changes.");
|
||||
return $output;
|
||||
}
|
||||
?>
|
||||
41
plugins/micro/inc/micro_md5.function.php
Normal file
41
plugins/micro/inc/micro_md5.function.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/* *
|
||||
* MD5
|
||||
* 详细:MD5加密
|
||||
* 版本:3.3
|
||||
* 日期:2012-07-19
|
||||
* 说明:
|
||||
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 签名字符串
|
||||
* @param $prestr 需要签名的字符串
|
||||
* @param $key 私钥
|
||||
* return 签名结果
|
||||
*/
|
||||
function md5Sign($prestr, $key) {
|
||||
$prestr = $prestr . $key;
|
||||
return md5($prestr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证签名
|
||||
* @param $prestr 需要签名的字符串
|
||||
* @param $sign 签名结果
|
||||
* @param $key 私钥
|
||||
* return 签名结果
|
||||
*/
|
||||
function md5Verify($prestr, $sign, $key) {
|
||||
$prestr = $prestr . $key;
|
||||
$mysgin = md5($prestr);
|
||||
|
||||
if($mysgin == $sign) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
118
plugins/micro/inc/micro_notify.class.php
Normal file
118
plugins/micro/inc/micro_notify.class.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/* *
|
||||
* 类名:EpayNotify
|
||||
* 功能:彩虹易支付通知处理类
|
||||
* 详细:处理易支付接口通知返回
|
||||
*/
|
||||
|
||||
require_once(PAY_ROOT."inc/micro_core.function.php");
|
||||
require_once(PAY_ROOT."inc/micro_md5.function.php");
|
||||
|
||||
class AlipayNotify {
|
||||
|
||||
var $alipay_config;
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->alipay_config = $alipay_config;
|
||||
$this->http_verify_url = $this->alipay_config['apiurl'].'api/query';
|
||||
}
|
||||
function AlipayNotify($alipay_config) {
|
||||
$this->__construct($alipay_config);
|
||||
}
|
||||
/**
|
||||
* 针对notify_url验证消息是否是支付宝发出的合法消息
|
||||
* @return 验证结果
|
||||
*/
|
||||
function verifyNotify(){
|
||||
if(empty($_POST)) {//判断POST来的数组是否为空
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
//生成签名结果
|
||||
$isSign = $this->getSignVeryfy($_POST, $_POST["sign"]);
|
||||
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
|
||||
$responseTxt = true;
|
||||
//$responseTxt = $this->getResponse($_POST["trade_no"]);
|
||||
|
||||
//验证
|
||||
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
|
||||
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
|
||||
if ($responseTxt && $isSign) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对return_url验证消息是否是支付宝发出的合法消息
|
||||
* @return 验证结果
|
||||
*/
|
||||
function verifyReturn(){
|
||||
if(empty($_GET)) {//判断GET来的数组是否为空
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$responseTxt = $this->getResponse($_GET["out_trade_no"]);
|
||||
|
||||
//验证
|
||||
if ($responseTxt) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取返回时的签名验证结果
|
||||
* @param $para_temp 通知返回来的参数数组
|
||||
* @param $sign 返回的签名结果
|
||||
* @return 签名验证结果
|
||||
*/
|
||||
function getSignVeryfy($para_temp, $sign) {
|
||||
//除去待签名参数数组中的空值和签名参数
|
||||
$para_filter = paraFilter($para_temp);
|
||||
|
||||
//对待签名参数数组排序
|
||||
$para_sort = argSort($para_filter);
|
||||
|
||||
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
$prestr = createLinkstring($para_sort);
|
||||
|
||||
$isSgin = false;
|
||||
$isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
|
||||
|
||||
return $isSgin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取远程服务器ATN结果,验证返回URL
|
||||
* @param $notify_id 通知校验ID
|
||||
* @return 服务器ATN结果
|
||||
* 验证结果集:
|
||||
* invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空
|
||||
* true 返回正确信息
|
||||
* false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟
|
||||
*/
|
||||
function getResponse($out_trade_no) {
|
||||
$param = [
|
||||
'appid'=> $this->alipay_config['appid'],
|
||||
'out_trade_no' => $out_trade_no,
|
||||
];
|
||||
$sign = '';
|
||||
foreach ($param as $k => $v) {
|
||||
if($v) $sign .= $k . '=' . $v . '&';
|
||||
}
|
||||
$param['sign'] = md5(rtrim($sign, '&') . $this->alipay_config['key']);
|
||||
$data = get_curl($this->http_verify_url,http_build_query($param));
|
||||
$arr = json_decode($data,true);
|
||||
if(isset($arr['code'])&&$arr['code']==1){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
96
plugins/micro/inc/micro_submit.class.php
Normal file
96
plugins/micro/inc/micro_submit.class.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/* *
|
||||
* 类名:EpaySubmit
|
||||
* 功能:彩虹易支付接口请求提交类
|
||||
* 详细:构造易支付接口表单HTML文本,获取远程HTTP数据
|
||||
*/
|
||||
require_once(PAY_ROOT."inc/micro_core.function.php");
|
||||
require_once(PAY_ROOT."inc/micro_md5.function.php");
|
||||
|
||||
class AlipaySubmit {
|
||||
|
||||
var $alipay_config;
|
||||
|
||||
function __construct($alipay_config){
|
||||
$this->alipay_config = $alipay_config;
|
||||
$this->alipay_gateway_new = $this->alipay_config['apiurl'].'api/payment';
|
||||
}
|
||||
function AlipaySubmit($alipay_config) {
|
||||
$this->__construct($alipay_config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成签名结果
|
||||
* @param $para_sort 已排序要签名的数组
|
||||
* return 签名结果字符串
|
||||
*/
|
||||
function buildRequestMysign($para_sort) {
|
||||
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
|
||||
$prestr = createLinkstring($para_sort);
|
||||
|
||||
$mysign = md5Sign($prestr, $this->alipay_config['key']);
|
||||
|
||||
return $mysign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成要请求给支付宝的参数数组
|
||||
* @param $para_temp 请求前的参数数组
|
||||
* @return 要请求的参数数组
|
||||
*/
|
||||
function buildRequestPara($para_temp) {
|
||||
//除去待签名参数数组中的空值和签名参数
|
||||
$para_filter = paraFilter($para_temp);
|
||||
|
||||
//对待签名参数数组排序
|
||||
$para_sort = argSort($para_filter);
|
||||
|
||||
//生成签名结果
|
||||
$mysign = $this->buildRequestMysign($para_sort);
|
||||
|
||||
//签名结果与签名方式加入请求提交参数组中
|
||||
$para_sort['sign'] = $mysign;
|
||||
|
||||
return $para_sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成要请求给支付宝的参数数组
|
||||
* @param $para_temp 请求前的参数数组
|
||||
* @return 要请求的参数数组字符串
|
||||
*/
|
||||
function buildRequestParaToString($para_temp) {
|
||||
//待请求参数数组
|
||||
$para = $this->buildRequestPara($para_temp);
|
||||
|
||||
//把参数组中所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
|
||||
$request_data = createLinkstringUrlencode($para);
|
||||
|
||||
return $request_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立请求,以表单HTML形式构造(默认)
|
||||
* @param $para_temp 请求参数数组
|
||||
* @param $method 提交方式。两个值可选:post、get
|
||||
* @param $button_name 确认按钮显示文字
|
||||
* @return 提交表单HTML文本
|
||||
*/
|
||||
function buildRequestForm($para_temp, $method='POST', $button_name='正在跳转') {
|
||||
//待请求参数数组
|
||||
$para = $this->buildRequestPara($para_temp);
|
||||
|
||||
$sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->alipay_gateway_new."' method='".$method."'>";
|
||||
while (list ($key, $val) = each ($para)) {
|
||||
$sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>";
|
||||
}
|
||||
|
||||
//submit按钮控件请不要含有name属性
|
||||
$sHtml = $sHtml."<input type='submit' value='".$button_name."'></form>";
|
||||
|
||||
$sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>";
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
}
|
||||
?>
|
||||
38
plugins/micro/notify.php
Normal file
38
plugins/micro/notify.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/micro.config.php");
|
||||
require_once(PAY_ROOT."inc/micro_notify.class.php");
|
||||
|
||||
//计算得出通知验证结果
|
||||
$alipayNotify = new AlipayNotify($alipay_config);
|
||||
$verify_result = $alipayNotify->verifyNotify();
|
||||
|
||||
if($verify_result) {//验证成功
|
||||
//商户订单号
|
||||
$out_trade_no = daddslashes($_POST['out_trade_no']);
|
||||
|
||||
//支付宝交易号
|
||||
$trade_no = daddslashes($_POST['trade_no']);
|
||||
|
||||
//金额
|
||||
$money = $_POST['money'];
|
||||
|
||||
if ($_POST['status'] == 1) {
|
||||
//付款完成后,支付宝系统发送该交易状态通知
|
||||
if($out_trade_no == TRADE_NO && round($money,2)==round($order['money'],2) && $order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='$out_trade_no'")){
|
||||
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date` =NOW() where `trade_no`='$out_trade_no'");
|
||||
processOrder($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "success";
|
||||
}
|
||||
else {
|
||||
//验证失败
|
||||
echo "fail";
|
||||
}
|
||||
|
||||
?>
|
||||
54
plugins/micro/return.php
Normal file
54
plugins/micro/return.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/micro.config.php");
|
||||
require_once(PAY_ROOT."inc/micro_notify.class.php");
|
||||
|
||||
@header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
$url=creat_callback($srow);
|
||||
|
||||
if ($order['status']==1) {
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
exit;
|
||||
}else{
|
||||
$alipayNotify = new AlipayNotify($alipay_config);
|
||||
$verify_result = $alipayNotify->verifyReturn();
|
||||
if($verify_result){
|
||||
if($order['status']==0){
|
||||
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='$out_trade_no'")){
|
||||
$DB->exec("update `pre_order` set `endtime` ='$date',`date` =NOW() where `trade_no`='$out_trade_no'");
|
||||
processOrder($order,false);
|
||||
}
|
||||
}
|
||||
echo '<script>window.location.href="'.$url['return'].'";</script>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
|
||||
<link href="//cdn.staticfile.org/ionic/1.3.2/css/ionic.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="bar bar-header bar-light" align-title="center">
|
||||
<h1 class="title">支付结果页面</h1>
|
||||
</div>
|
||||
<div class="has-header" style="padding: 5px;position: absolute;width: 100%;">
|
||||
<div class="text-center" style="color: #a09ee5;">
|
||||
<i class="icon ion-close-circled" style="font-size: 80px;"></i><br>
|
||||
<span>支付未完成</span>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
document.querySelector('body').addEventListener('touchmove', function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
19
plugins/micro/submit.php
Normal file
19
plugins/micro/submit.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
if(!defined('IN_PLUGIN'))exit();
|
||||
|
||||
require_once(PAY_ROOT."inc/micro.config.php");
|
||||
require_once(PAY_ROOT."inc/micro_submit.class.php");
|
||||
$parameter = array(
|
||||
"appid" => trim($alipay_config['appid']),
|
||||
"type" => $order['typename']=='alipay'?'alipay':'cashier',
|
||||
"notify_url" => $conf['localurl'].'pay/micro/notify/'.TRADE_NO.'/',
|
||||
"return_url" => $siteurl.'pay/micro/return/'.TRADE_NO.'/',
|
||||
"out_trade_no" => $trade_no,
|
||||
"name" => $order['name'],
|
||||
"money" => $order['money'],
|
||||
"mchid" => trim($alipay_config['mchid'])
|
||||
);
|
||||
//建立请求
|
||||
$alipaySubmit = new AlipaySubmit($alipay_config);
|
||||
$html_text = $alipaySubmit->buildRequestForm($parameter);
|
||||
echo $html_text;
|
||||
25
plugins/qqpay/cert/apiclient_cert.pem
Normal file
25
plugins/qqpay/cert/apiclient_cert.pem
Normal file
@@ -0,0 +1,25 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEHjCCA4egAwIBAgIFAPpX1NAwDQYJKoZIhvcNAQEFBQAwgakxCzAJBgNVBAYT
|
||||
AkNOMRIwEAYDVQQIEwlHVUFOR0RPTkcxETAPBgNVBAcTCFNIRU5aSEVOMRMwEQYD
|
||||
VQQKEwp0ZW5wYXkuY29tMR0wGwYDVQQLExRUZW5wYXkuY29tIENBIENlbnRlcjEb
|
||||
MBkGA1UEAxMSVGVucGF5LmNvbSBSb290IENBMSIwIAYJKoZIhvcNAQkBFhNzZXJ2
|
||||
aWNlQHRlbmNlbnQuY29tMB4XDTE5MTIxNjA1MjYwNVoXDTIwMTIxNTA1MjYwNVow
|
||||
NzELMAkGA1UEBhMCQ04xEzARBgNVBAseCgBBAFAASYvBTmYxEzARBgNVBAMTCjE0
|
||||
MDUwNTA2MDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQChqjQlY0T9
|
||||
irgysbN+KalvE0h4jhqyA3JYnOwlU0Wx5nZkw1mZQ/HHsKSx3Pg3fg6xV67GjtTB
|
||||
KMt5vHSZ8TTLZULNAuyKOWmKfW2JCpOzDEAkSp2zf/5IjOi4Tsmr4oXernxtmyLK
|
||||
VmFRbLAZUJz0eBBN9puP8rWPKGVILm1DOH9pJa5YjSi1x/YtyytXfjt6yybaoKN6
|
||||
piVAg22qVmFZAgtl6emnajHVYPjdAJhto07aNr+x33XcGXF4OiZKzNIctHeUBULG
|
||||
iTVtwE4XDVHFk7BP4RqyTKvYEK8f9STe4eenvCJsaQKQx3cFG98F7dMv+uiDJr2D
|
||||
bKohwO9aCmvxAgMBAAGjggE9MIIBOTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQf
|
||||
Fh0iQ0VTLUNBIEdlbmVyYXRlIENlcnRpZmljYXRlIjAdBgNVHQ4EFgQUVQb/1YCw
|
||||
f2Qa4tAQ2NYm4hmCJ5Ywgd4GA1UdIwSB1jCB04AUjNT3yuA8Gk/Mbnlvf811nF23
|
||||
fNihga+kgawwgakxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHVUFOR0RPTkcxETAP
|
||||
BgNVBAcTCFNIRU5aSEVOMRMwEQYDVQQKEwp0ZW5wYXkuY29tMR0wGwYDVQQLExRU
|
||||
ZW5wYXkuY29tIENBIENlbnRlcjEbMBkGA1UEAxMSVGVucGF5LmNvbSBSb290IENB
|
||||
MSIwIAYJKoZIhvcNAQkBFhNzZXJ2aWNlQHRlbmNlbnQuY29tggkArsVrh+ek+2Yw
|
||||
DQYJKoZIhvcNAQEFBQADgYEANPf3klU9cc3zYVPDCNL8UTxSUIClUh+twLnNjxhi
|
||||
V/7hd93g6mEmTOOREjAXI1h9JzO10Uw23JVZ+HbefqtCYS4IUsDF+r2X6oORz448
|
||||
ScQoM0emBh/QuNT40gOXoHi0+tWBXEhAY4o3Cjo7umIdo8N7ys+8XL2vKe1Mx1Ga
|
||||
jZc=
|
||||
-----END CERTIFICATE-----
|
||||
28
plugins/qqpay/cert/apiclient_key.pem
Normal file
28
plugins/qqpay/cert/apiclient_key.pem
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQChqjQlY0T9irgy
|
||||
sbN+KalvE0h4jhqyA3JYnOwlU0Wx5nZkw1mZQ/HHsKSx3Pg3fg6xV67GjtTBKMt5
|
||||
vHSZ8TTLZULNAuyKOWmKfW2JCpOzDEAkSp2zf/5IjOi4Tsmr4oXernxtmyLKVmFR
|
||||
bLAZUJz0eBBN9puP8rWPKGVILm1DOH9pJa5YjSi1x/YtyytXfjt6yybaoKN6piVA
|
||||
g22qVmFZAgtl6emnajHVYPjdAJhto07aNr+x33XcGXF4OiZKzNIctHeUBULGiTVt
|
||||
wE4XDVHFk7BP4RqyTKvYEK8f9STe4eenvCJsaQKQx3cFG98F7dMv+uiDJr2DbKoh
|
||||
wO9aCmvxAgMBAAECggEBAIT2JI8/dwWEavyetH6mK0lEtc0ZKxGPziLdZUdJlr+7
|
||||
SVKUbIOmoxtWyA3VLH0Pe2wWLpP18zuunrNP8SKPhJlofil5JyyEDa6ufEFC5rlS
|
||||
8QooKE3yjiQDaH/1pN5unyXHomTPPCzoIIBEgQ1BBOX4PYixs74Po43LbomQTaMD
|
||||
bPgqSRzhi/diKCgBFuzgEthh3P6HdzUImZ7i8x1n0Fceu8Ynn9nng1WgcKvmbnti
|
||||
nuG4C0HERiLxB8IGfPB8ahFT5Qp529e8OVz3zhC3ea6Z29keDDS7hDf1tknEMMTw
|
||||
583Cnpb3Q8f2fUX3al0NA66yigy5B99T7Pgc8EUmQgECgYEAzVDOGJXkD86kk2ZR
|
||||
0+9fUDIIf95ZJCTrCX/4leCBxPo4VR8OtHvo6GpIhyhqXa2icHXm94prCF6LYLfG
|
||||
EPnFUdf/CRGSI8kIIJjK8oUT8MSdw0jDHLJoK7RHOasHytRkNfkujdk0v1F2gjn0
|
||||
ka6pd1/myJ1+h5jEGk2onfkcWyECgYEAyZLURVxm24HRUoQtimMw2+wed4IUHBB2
|
||||
Cye9ixQQka34ayj4ik5YYiceIfEKxQa8hxONaSqCy5SrcmtN3o9tBcp1Rj3y6bZ+
|
||||
slnlCdbX43/NNOzQsYGKIg5DRX/R8xnPO9q4jT004tUbmFV6WXHsg51TMGBeQQ6g
|
||||
gV75WrrZRtECgYAffOwOwzY14mhFHuUfzs9cWkAJdE1RiMPvMgwq2EKutf1buKal
|
||||
sXc35cz3xZACi/Wkr8BbaIQfxXg0vhqHUfccJTc86c/y4wr3DNfbN+OmAlF7uLYL
|
||||
uaTWRxDBXGSWi9pOmMe2A4DecpztPfwvN41P/IpFbDoSi7BPpGdeyuy5YQKBgFSy
|
||||
NjECt1FKRbrHQR9huDjgCJksdeio3gCn7ROQFbowgC3+pBfw/WAYkaevUVgiEXss
|
||||
MwHaU+TYjgVgovJ+D1AclpQyGWwsOyYTcZJlzIaRv5aaXsIG7RSMK6X7JCtiT9oV
|
||||
d/AYpK0e4B5s5CDLJpbStw6fn1r0m2pgjqOZ2QvRAoGAWpfRMRCNmL0S418cwYTy
|
||||
sNl3JzOkIz2+PQdys6zlQ69wXpUsZZzxQSINxm0bnHGBP1oxZnOwpGx2j/bc5/cc
|
||||
0h6g7V/3COKFxYU/JD7GHUYMHFrVCBrvAokETmnYYxEgEc/ZcqQnUoXRZcpDj4N3
|
||||
Cml1hpXvOFCNh7OhKZfN8d0=
|
||||
-----END PRIVATE KEY-----
|
||||
21
plugins/qqpay/config.ini
Normal file
21
plugins/qqpay/config.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
[config]
|
||||
;支付插件英文名称,需和目录名称一致,不能有重复
|
||||
name = "qqpay"
|
||||
|
||||
;支付插件显示名称
|
||||
showname = "QQ钱包官方支付"
|
||||
|
||||
;支付插件作者
|
||||
author = "QQ钱包"
|
||||
|
||||
;支付插件作者链接
|
||||
link = "https://qpay.qq.com/"
|
||||
|
||||
;支付插件支持的支付方式,多种方式用英文,隔开,可选的有alipay,qqpay,wxpay,bank
|
||||
types = "qqpay"
|
||||
|
||||
;支付插件要求传入的参数以及参数显示名称,可选的有appid,appkey,appsecret,appurl,appmchid
|
||||
inputs = "appid:QQ钱包商户号,appkey:QQ钱包API密钥"
|
||||
|
||||
;支付插件要求传入的支付方式参数
|
||||
select = "1:扫码支付(包含H5),2:公众号支付"
|
||||
50
plugins/qqpay/inc/qpayMch.config.php
Normal file
50
plugins/qqpay/inc/qpayMch.config.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* qpayMch.config.php
|
||||
* Created by HelloWorld
|
||||
* vers: v1.0.0
|
||||
* User: Tencent.com
|
||||
*/
|
||||
|
||||
define("QQ_MCH_ID", $channel['appid']);
|
||||
define("QQ_MCH_KEY", $channel['appkey']);
|
||||
define("QQ_OP_USERID", $conf['qq_op_userid']);
|
||||
define("QQ_OP_USERPWD", $conf['qq_op_userpwd']);
|
||||
|
||||
class QpayMchConf
|
||||
{
|
||||
/**
|
||||
* QQ钱包商户号
|
||||
*/
|
||||
const MCH_ID = QQ_MCH_ID;
|
||||
|
||||
/**
|
||||
* API密钥。
|
||||
* QQ钱包商户平台(http://qpay.qq.com/)获取
|
||||
*/
|
||||
const MCH_KEY = QQ_MCH_KEY;
|
||||
|
||||
/**
|
||||
* QQ钱包公众号APPID
|
||||
*/
|
||||
const MCH_APPID = '';
|
||||
|
||||
/**
|
||||
* API证书绝对路径
|
||||
* QQ钱包接口中,涉及资金回滚的接口会使用到商户证书,包括退款、撤销接口。商家在申请QQ钱包支付成功后,收到的相应邮件后,可以按照指引下载API证书,也可以按照以下路径下载:QQ钱包商户平台(https://qpay.qq.com/)-->账户管理-->API安全 。
|
||||
*/
|
||||
const SSLCERT_PATH = PAY_ROOT.'cert/apiclient_cert.pem';
|
||||
const SSLKEY_PATH = PAY_ROOT.'cert/apiclient_key.pem';
|
||||
|
||||
/**
|
||||
* 企业付款-操作员ID
|
||||
*/
|
||||
const OP_USERID = QQ_OP_USERID;
|
||||
|
||||
/**
|
||||
* 企业付款-操作员密码
|
||||
*/
|
||||
const OP_USERPWD = QQ_OP_USERPWD;
|
||||
|
||||
}
|
||||
46
plugins/qqpay/inc/qpayMchAPI.class.php
Normal file
46
plugins/qqpay/inc/qpayMchAPI.class.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* qpayMachAPI.php 业务调用方可做二次封装
|
||||
* Created by HelloWorld
|
||||
* vers: v1.0.0
|
||||
* User: Tencent.com
|
||||
*/
|
||||
require_once (PAY_ROOT.'inc/qpayMchUtil.class.php');
|
||||
class QpayMchAPI{
|
||||
protected $url;
|
||||
protected $isSSL;
|
||||
protected $timeout;
|
||||
|
||||
/**
|
||||
* QpayMchAPI constructor.
|
||||
*
|
||||
* @param $url 接口url
|
||||
* @param $isSSL 是否使用证书发送请求
|
||||
* @param int $timeout 超时
|
||||
*/
|
||||
public function __construct($url, $isSSL, $timeout = 5){
|
||||
$this->url = $url;
|
||||
$this->isSSL = $isSSL;
|
||||
$this->timeout = $timeout;
|
||||
}
|
||||
|
||||
public function reqQpay($params){
|
||||
$ret = array();
|
||||
//商户号
|
||||
$params["mch_id"] = QpayMchConf::MCH_ID;
|
||||
//随机字符串
|
||||
$params["nonce_str"] = QpayMchUtil::createNoncestr();
|
||||
//签名
|
||||
$params["sign"] = QpayMchUtil::getSign($params);
|
||||
//生成xml
|
||||
$xml = QpayMchUtil::arrayToXml($params);
|
||||
|
||||
if(isset($this->isSSL)){
|
||||
$ret = QpayMchUtil::reqByCurlSSLPost($xml, $this->url, $this->timeout);
|
||||
}else{
|
||||
$ret = QpayMchUtil::reqByCurlNormalPost($xml, $this->url, $this->timeout);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
149
plugins/qqpay/inc/qpayMchUtil.class.php
Normal file
149
plugins/qqpay/inc/qpayMchUtil.class.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* qpayMachAPI.php
|
||||
* Created by HelloWorld
|
||||
* vers: v1.0.0
|
||||
* User: Tencent.com
|
||||
*/
|
||||
require_once (PAY_ROOT.'inc/qpayMch.config.php');
|
||||
class QpayMchUtil {
|
||||
|
||||
/**
|
||||
* 生成随机串
|
||||
* @param int $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function createNoncestr( $length = 32 ) {
|
||||
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
$str ="";
|
||||
for ( $i = 0; $i < $length; $i++ ){
|
||||
$str.= substr($chars, mt_rand(0, strlen($chars)-1), 1);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将参数转为hash形式
|
||||
* @param $params
|
||||
* @param $urlencode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function buildQueryStr($params) {
|
||||
$arrTmp = array();
|
||||
foreach ($params as $k => $v){
|
||||
//参数为空不参与签名
|
||||
if(isset($v) && $v != '' && $k != 'sign'){
|
||||
array_push($arrTmp, "$k=$v");
|
||||
}
|
||||
}
|
||||
return implode('&', $arrTmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数签名
|
||||
* @param $params
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSign($params) {
|
||||
//第一步:对参数按照key=value的格式,并按照参数名ASCII字典序排序
|
||||
ksort($params);
|
||||
$stringA = QpayMchUtil::buildQueryStr($params);
|
||||
//第二步:拼接API密钥并md5
|
||||
$stringA = $stringA."&key=".QpayMchConf::MCH_KEY;
|
||||
$stringA = md5($stringA);
|
||||
//转成大写
|
||||
$sign = strtoupper($stringA);
|
||||
return $sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转换成xml字符串
|
||||
* @param $arr
|
||||
* @return string
|
||||
*/
|
||||
public static function arrayToXml($arr) {
|
||||
$xml = "<xml>";
|
||||
foreach ($arr as $key => $val){
|
||||
if (is_numeric($val)){
|
||||
$xml.="<$key>$val</$key>";
|
||||
}
|
||||
else
|
||||
$xml.="<$key><![CDATA[$val]]></$key>";
|
||||
}
|
||||
$xml.="</xml>";
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* xml转换成数组
|
||||
* @param $xml
|
||||
* @return array|mixed|object
|
||||
*/
|
||||
public static function xmlToArray($xml) {
|
||||
$arr = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用curl 请求接口。post方式
|
||||
* @param $params
|
||||
* @param $url
|
||||
* @param int $timeout
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public static function reqByCurlNormalPost($params, $url, $timeout = 10) {
|
||||
return QpayMchUtil::_reqByCurl($params, $url, $timeout, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用ssl证书请求接口。post方式
|
||||
* @param $params
|
||||
* @param $url
|
||||
* @param int $timeout
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public static function reqByCurlSSLPost($params, $url, $timeout = 10) {
|
||||
return QpayMchUtil::_reqByCurl($params, $url, $timeout, true);
|
||||
}
|
||||
|
||||
private static function _reqByCurl($params, $url, $timeout = 10, $needSSL = false) {
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch,CURLOPT_URL, $url);
|
||||
curl_setopt($ch,CURLOPT_TIMEOUT, $timeout);
|
||||
|
||||
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
|
||||
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
|
||||
|
||||
curl_setopt($ch,CURLOPT_HEADER,FALSE);
|
||||
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
|
||||
//是否使用ssl证书
|
||||
if(isset($needSSL) && $needSSL != false){
|
||||
curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM');
|
||||
curl_setopt($ch,CURLOPT_SSLCERT, QpayMchConf::SSLCERT_PATH);
|
||||
curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM');
|
||||
curl_setopt($ch,CURLOPT_SSLKEY, QpayMchConf::SSLKEY_PATH);
|
||||
}
|
||||
curl_setopt($ch,CURLOPT_POST, true);
|
||||
curl_setopt($ch,CURLOPT_POSTFIELDS, $params);
|
||||
$ret = curl_exec($ch);
|
||||
if($ret){
|
||||
curl_close($ch);
|
||||
//log($ret); //业务记录交互流水。注:流水日志影响性能,如请求量过大,请慎重设计日志。
|
||||
return $ret;
|
||||
}
|
||||
else {
|
||||
$error = curl_errno($ch);
|
||||
//log($error); //业务记录错误日志
|
||||
print_r($error);
|
||||
curl_close($ch);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
26
plugins/qqpay/inc/qpayNotify.class.php
Normal file
26
plugins/qqpay/inc/qpayNotify.class.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* QpayNotify.php 业务调用方可做二次封装
|
||||
* Created by HelloWorld
|
||||
* vers: v1.0.0
|
||||
* User: Tencent.com
|
||||
*/
|
||||
require_once (PAY_ROOT.'inc/qpayMchUtil.class.php');
|
||||
class QpayNotify{
|
||||
private $params;
|
||||
private $sign;
|
||||
|
||||
function getParams() {
|
||||
$post_data = file_get_contents("php://input");
|
||||
$params = QpayMchUtil::xmlToArray($post_data);
|
||||
$this->params = $params;
|
||||
$this->sign = $params['sign'];
|
||||
return $params;
|
||||
}
|
||||
|
||||
function verifySign() {
|
||||
$sign = QpayMchUtil::getSign($this->params);
|
||||
return $sign == $this->sign;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user