diff --git a/Application/Api/Controller/UserController.class.php b/Application/Api/Controller/UserController.class.php index 0676daac4..ac2c5f7bf 100755 --- a/Application/Api/Controller/UserController.class.php +++ b/Application/Api/Controller/UserController.class.php @@ -184,7 +184,7 @@ class UserController extends CommonController */ public function GetAlipayUserInfo() { - $result = (new \Library\Alipay())->GetAlipayUserInfo(I('authcode'), MyC('common_app_mini_alipay_appid')); + $result = (new \Library\AlipayAuth())->GetAlipayUserInfo(I('authcode'), MyC('common_app_mini_alipay_appid')); if($result === false) { $this->ajaxReturn('获取授权信息失败'); diff --git a/Application/Library/Alipay.class.php b/Application/Library/AlipayAuth.class.php similarity index 60% rename from Application/Library/Alipay.class.php rename to Application/Library/AlipayAuth.class.php index cb1859779..72d5a2002 100755 --- a/Application/Library/Alipay.class.php +++ b/Application/Library/AlipayAuth.class.php @@ -3,211 +3,17 @@ namespace Library; /** - * 支付宝支付驱动 + * 支付宝授权驱动 * @author Devil * @version V_1.0.0 */ -class Alipay +class AlipayAuth { /** * [__construct 构造方法] */ public function __construct(){} - /** - * [SoonPay 立即支付] - * @param [array] $data [支付信息] - */ - public function SoonPay($data, $config) - { - if(empty($data) || empty($config)) return false; - - if(APPLICATION == 'app') - { - return $this->SoonPayApp($data, $config); - } else { - if(IsMobile()) - { - $this->SoonPayMobile($data, $config); - } else { - $this->SoonPayWeb($data, $config); - } - } - } - - /** - * [SoonPayApp app支付] - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @datetime 2017-10-25T16:07:06+0800 - * @param [array] $data [参数列表] - * @param [array] $config [配置信息] - */ - private function SoonPayApp($data, $config) - { - $parameter = array( - 'app_id' => MyC('common_app_mini_alipay_appid'), - 'method' => 'alipay.trade.app.pay', - 'format' => 'JSON', - 'charset' => 'utf-8', - 'sign_type' => 'RSA2', - 'timestamp' => date('Y-m-d H:i:s'), - 'version' => '1.0', - 'notify_url' => $data['notify_url'], - ); - $biz_content = array( - 'subject' => $data['name'], - 'out_trade_no' => $data['order_sn'], - 'total_amount' => $data['total_price'], - 'product_code' => 'QUICK_MSECURITY_PAY', - ); - - // 收款账户集 - if(!empty($data['seller_id'])) - { - $biz_content['seller_id'] = $data['seller_id']; - } - $parameter['biz_content'] = json_encode($biz_content, JSON_UNESCAPED_UNICODE); - - - // 生成签名参数+签名 - $params = $this->GetParamSign($parameter); - $params['param'] .= '&sign='.urlencode($this->MyRsaSign($params['value'])); - - // 直接返回支付信息 - return $params['param']; - } - - /** - * [SoonPayMobile wap支付] - * @param [array] $data [参数列表] - * @param [array] $config [配置信息] - */ - private function SoonPayMobile($data, $config) - { - $request_token = $this->GetRequestToken($data, $config); - - $req_data = ''.$request_token.''; - $parameter = array( - 'service' => 'alipay.wap.auth.authAndExecute', - 'format' => 'xml', - 'v' => '2.0', - 'partner' => $config['id'], - 'sec_id' => 'MD5', - 'req_data' => $req_data, - 'request_token' => $request_token - ); - - $param = $this->GetParamSign($parameter, $config); - header('location:http://wappaygw.alipay.com/service/rest.htm?'.$param['param']. '&sign='.md5($param['sign'])); - - } - - /** - * [GetRequestToken 获取临时token] - * @param [array] $data [参数列表] - * @param [array] $config [配置信息] - * @return [string] [返回临时token] - */ - private function GetRequestToken($data, $config) - { - $parameter = array( - 'service' => 'alipay.wap.trade.create.direct', - 'format' => 'xml', - 'v' => '2.0', - 'partner' => $config['id'], - 'req_id' => $data['order_sn'], - 'sec_id' => 'MD5', - 'req_data' => $this->GetReqData($data, $config), - 'subject' => $data['name'], - 'out_trade_no' => $data['order_sn'], - 'total_fee' => $data['total_price'], - 'seller_account_name' => $config['name'], - 'call_back_url' => $data['call_back_url'], - 'notify_url' => $data['notify_url'], - 'out_user' => $data['out_user'], - 'merchant_url' => $data['merchant_url'], - ); - - $param = $this->GetParamSign($parameter, $config); - $ret = urldecode(file_get_contents('http://wappaygw.alipay.com/service/rest.htm?'.$param['param'].'&sign='.md5($param['sign']))); - - $para_split = explode('&',$ret); - //把切割后的字符串数组变成变量与数值组合的数组 - foreach ($para_split as $item) { - //获得第一个=字符的位置 - $nPos = strpos($item,'='); - //获得字符串长度 - $nLen = strlen($item); - //获得变量名 - $key = substr($item,0,$nPos); - //获得数值 - $value = substr($item,$nPos+1,$nLen-$nPos-1); - //放入数组中 - $para_text[$key] = $value; - } - - $req = Xml_Array($para_text['res_data']); - if(empty($req['request_token'])) - { - exit(header('location:'.__ROOT__.'index.php?g=Info&c=Prompt&f=PromptInfo&state=error&content=支付宝异常错误&url='.__ROOT__)); - } - - return $req['request_token']; - } - - private function GetReqData($data, $config) - { - return ' - '.$data['name'].' - '.$data['order_sn'].' - '.$data['total_price'].' - '.$config['name'].' - '.$data['call_back_url'].' - '.$data['notify_url'].' - '.$data['out_user'].' - '.$data['merchant_url'].' - 3600 - 0 - '; - } - - /** - * [SoonPayWeb web支付] - * @param [array] $data [订单信息] - * @param [array] $config [配置信息] - */ - private function SoonPayWeb($data, $config) - { - $parameter = array( - 'service' => 'create_direct_pay_by_user', - 'partner' => $config['id'], - '_input_charset' => ML_CHARSET, - 'notify_url' => $data['notify_url'], - 'return_url' => $data['call_back_url'], - - /* 业务参数 */ - 'subject' => $data['name'], - 'out_trade_no' => $data['order_sn'], - 'price' => $data['total_price'], - - 'quantity' => 1, - 'payment_type' => 1, - - /* 物流参数 */ - 'logistics_type' => 'EXPRESS', - 'logistics_fee' => 0, - 'logistics_payment' => 'BUYER_PAY_AFTER_RECEIVE', - - /* 买卖双方信息 */ - 'seller_email' => $config['name'] - ); - - $param = $this->GetParamSign($parameter, $config); - header('location:https://mapi.alipay.com/gateway.do?'.$param['param']. '&sign='.md5($param['sign']).'&sign_type=MD5'); - } - /** * [GetParamSign 生成参数和签名] * @param [array] $data [待生成的参数] @@ -237,61 +43,6 @@ class Alipay return $result; } - /** - * [Respond 异步处理] - * @param [array] $config [配置信息] - * @return [array|string] [成功返回数据列表,失败返回no] - */ - public function Respond($config) - { - if(empty($config)) return 'no'; - - $data = empty($_POST) ? $_GET : array_merge($_GET, $_POST); - ksort($data); - - $sign = ''; - if(isset($data['sec_id']) && $data['sec_id'] == 'MD5') - { - $data_xml = json_decode(json_encode((array) simplexml_load_string($data['notify_data'])), true); - $data = array_merge($data, $data_xml); - $sign = 'service='.$data['service'].'&v='.$data['v'].'&sec_id='.$data['sec_id'].'¬ify_data='.$data['notify_data']; - } else { - foreach($data AS $key=>$val) - { - if ($key != 'sign' && $key != 'sign_type' && $key != 'code') - { - $sign .= "$key=$val&"; - } - } - $sign = substr($sign, 0, -1); - } - - if(isset($data['sign_type']) && $data['sign_type'] == 'RSA2') - { - if(!$this->AlipayrsaVerify($sign, $data['sign'])) - { - return 'no'; - } - } else { - if(!isset($data['sign']) || md5($sign.$config['key']) != $data['sign']) - { - return 'no'; - } - } - - /* 支付状态 */ - $status = isset($data['trade_status']) ? $data['trade_status'] : $data['result']; - switch($status) - { - case 'TRADE_SUCCESS': - case 'TRADE_FINISHED': - case 'success': - return $data; - break; - } - return 'no'; - } - /** * [GetAlipayUserInfo 支付宝小程序获取用户信息] * @author Devil @@ -581,9 +332,9 @@ class Alipay * @version 1.0.0 * @datetime 2017-10-28T21:31:41+0800 * @param [string] $query [生成小程序启动参数(如:type=page&page=shop&value=5)] - * @param [string] $describe [二维码描述(默认:美啦网)] + * @param [string] $describe [二维码描述(默认:ShopXO)] */ - public function AlipayQrcodeCreate($query, $describe = '美啦网') + public function AlipayQrcodeCreate($query, $describe = 'ShopXO') { // 请求参数 $params = [ diff --git a/changelog.txt b/changelog.txt index e63bff438..49dfd4791 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,25 @@ ++=========================================================+ + ShopXO 1.0.1 Release 20181111 http://shopxo.net ++=========================================================+ +后台管理功能列表 + 1、优化轮播图片与手机端分离 + 2、新增问答/留言 + 3、新增手机端管理 + 4、新增支付宝小程序(轮播、首页导航) + 5、调整平台类别 + 6、新增支付宝小程序支付插件 + 7、优化部分BUG + +前端功能列表 + 1、购物流程优化(去掉用户选择快递) + 2、优化部分BUG + +手机端 + 1、新增支付宝小程序 + 2、支持后台配置基础信息 + 3、支持后台生成程序包 + + +=========================================================+ ShopXO 1.0.0 Release 20181111 http://shopxo.net +=========================================================+