| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\utils\Alipay;
- use app\models\Goods;
- use app\models\Option;
- use app\constants\OptionSetting;
- use app\models\OrderDetail;
- use app\models\OrderUnion;
- use app\models\SharingReceiver;
- use app\models\Store;
- use app\models\StoreAliMini;
- use app\models\StoreMiniToken;
- use app\models\User;
- use app\modules\admin\models\AlipayThirdAppForm;
- use app\utils\Alipay\alipaySdk\aop\request\AlipayTradeRoyaltyRelationBindRequest;
- use app\utils\OrderNo;
- use Symfony\Component\HttpFoundation\Response;
- use Yansongda\Pay\Exceptions\GatewayException;
- use Yansongda\Pay\Exceptions\InvalidConfigException;
- use Yansongda\Pay\Exceptions\InvalidSignException;
- use Yansongda\Pay\Pay;
- use Yansongda\Supports\Collection;
- use yii\base\BaseObject;
- use yii\helpers\ArrayHelper;
- use yii\helpers\Json;
- use app\utils\CurlHelper;
- include_once 'alipaySdk/aop/AopClient.php';
- include_once 'alipaySdk/aop/request/AlipayMerchantItemFileUploadRequest.php';
- /**
- * Class Alipay 证书公钥模式
- * 支付宝支付相关操作
- * @package app\utils
- */
- class AlipayProfit
- {
- /**
- * @var \AopClient $aop
- */
- private static $aop;
- private static $gatewayUrl = 'https://openapi.alipay.com/gateway.do';
- public static $alipay_config;
- /**
- * 授权地址前缀
- */
- const AUTH_URL = 'https://openauth.alipay.com/oauth2/appToAppAuth.htm';
- const FLAG_REFUND = 'refund';
- const FLAG_NORMAL = 'wap';
- const FLAG_TRANSFER = 'transfer';
- private static $validFlag = [
- self::FLAG_NORMAL,
- self::FLAG_REFUND,
- self::FLAG_TRANSFER
- ];
- /**
- * 授权应用类型
- * @var string[]
- */
- private static $validAuthType = [
- 'TINYAPP',
- 'WEBAPP',
- 'MOBILEAPP',
- 'PUBLICAPP'
- ];
- /**
- * @var \Yansongda\Pay\Gateways\Alipay
- */
- public static $alipay;
- /**
- * @var string
- * 回调url
- */
- private static $notify_url = 'alipay/notify';
- public static $h5_url = 'order/order/order';
- public $mini_id;
- public $store_id;
- /**
- * @param $return_url
- * @param $level
- * 获取支付宝实例
- */
- private function __construct($store_id, $return_url = 'https://www.baidu.com', $is_app = false, $type = 0)
- {
- $store_id = !empty($store_id) ? $store_id : get_store_id();
- $this->store_id = $store_id;
- // 第三方应用代理调用支付宝相关接口
- // 相关配置为第三方应用所属,但必须加上授权token(app_auth_token)
- $alipay_config = Option::getSaasAlipay();
- $data = ['store_id' => $store_id, 'is_cancel' => 0];
- if (\Yii::$app->prod_is_dandianpu()) {
- if (self_mini() === true) {
- $data['is_use'] = 1;
- }
- } else {
- $data['is_use'] = 1;
- }
- //兼容支付宝平台运营app支付
- if ($is_app) {
- $store_token = StoreMiniToken::find()->where(['batch_status' => [2, 6], 'store_id' => $store_id])->select('app_auth_token')->asArray()->one();
- $store_mini['auth_token'] = $store_token['app_auth_token'];
- if (empty($store_mini['auth_token'])) {
- $store_mini = StoreAliMini::find()->where($data)->orderBy('id desc')->select('auth_token')->asArray()->one();
- }
- } else {
- $store_mini = StoreAliMini::find()->where($data)->orderBy('id desc')->select('auth_token')->asArray()->one();
- }
- self::$alipay_config = $alipay_config;
- $config = [
- 'app_id' => $alipay_config['app_id'],
- 'return_url' => $return_url,
- 'notify_url' => pay_notify_url(self::$notify_url),
- 'private_key' => $alipay_config['app_private_key'],
- 'log' => [ // optional
- 'file' => \Yii::$app->basePath . '/runtime/logs/alipay.log',
- 'level' => 'debug', // 建议生产环境等级调整为 info,开发环境为 debug
- 'type' => 'single', // optional, 可选 daily.
- 'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
- ],
- 'ali_public_key' => $alipay_config['alipay_public_key'],
- 'app_auth_token' => $store_mini['auth_token'] ?: Store::findOne($store_id)->app_auth_token
- // 'app_cert_public_key' => \Yii::$app->basePath. '/utils/Alipay/CRT/app_cert_public_key.crt', // 应用公钥证书路径
- // 'ali_public_key' => \Yii::$app->basePath. '/utils/Alipay/CRT/alipay_cert_public_key.crt', // 支付宝公钥证书路径
- // 'alipay_root_cert' => \Yii::$app->basePath. '/utils/Alipay/CRT/alipay_root_cert.crt', // 支付宝根证书路径
- // 'mode' => 'dev' // optional,设置此参数,将进入沙箱模式
- ];
- if ($type) {
- $key = Option::ALIPAY_CONFIG_CERT;
- if (\Yii::$app->prod_is_dandianpu() && is_h5()){
- $key = OptionSetting::ALIPAY_PAY_DANDIANPUH5;
- if(!Store::hasIncoming($store_id, 'alipay', is_h5())){
- $store_id = 0;
- }
- }
- $config_cache = Option::get($key, $store_id, 'alipay')['value'];
- $config_cache = json_decode($config_cache, true);
- if (!empty($config_cache)) {
- $config = [
- 'app_id' => $config_cache['app_id'],
- 'notify_url' => pay_notify_url(self::$notify_url),
- 'return_url' => $return_url,
- 'log' => [ // optional
- 'file' => \Yii::$app->basePath . '/runtime/logs/alipay.log',
- 'level' => 'debug', // 建议生产环境等级调整为 info,开发环境为 debug
- 'type' => 'single', // optional, 可选 daily.
- 'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
- ],
- 'private_key' => $config_cache['app_private_key'],
- 'app_cert_public_key' => $this->saveTempImage($config_cache['app_public_cert']), // 应用公钥证书路径
- 'ali_public_key' => $this->saveTempImage($config_cache['alipay_public_cert']), // 支付宝公钥证书路径
- 'alipay_root_cert' => $this->saveTempImage($config_cache['alipay_root_cert']), // 支付宝根证书路径
- ];
- }
- }
- self::$alipay = Pay::alipay($config);
- }
- /**
- * 静态方法调用construct方法
- * @param $return_url
- */
- public static function init($store_id, $return_url = '', $is_app = false, $type = 0) {
- return new self($store_id, $return_url, $is_app, $type);
- }
- //获取网络图片到临时目录
- public function saveTempImage($url)
- {
- if (strpos($url, 'http') === false) {
- $url = 'http:' . trim($url);
- }
- if (!is_dir(\Yii::$app->runtimePath . '/crt')) {
- mkdir(\Yii::$app->runtimePath . '/crt');
- }
- $save_path = \Yii::$app->runtimePath . '/crt/' . md5($url) . '.crt';
- CurlHelper::download($url, $save_path);
- return $save_path;
- }
- /**
- * app支付
- * @param $order
- * @param User $user
- * @param $subject
- * @param $balance_price
- * @param $return_url
- * @return Response | false | string | array
- */
- public static function app($order, $subject, $user, $type = '', $total_pay_price = 0,$balance_price = 0, $return_url = '') {
- self::init($order->store_id, $return_url, true);
- $order1 = $order;
- if($type == OrderNo::ORDER_UNION){
- $order = [
- 'body' => '订单合并支付',
- 'out_trade_no' => OrderNo::getOrderNo(OrderNo::ORDER_UNION),
- 'total_amount' => $balance_price > 0 ? $total_pay_price - $balance_price : $total_pay_price,
- 'subject' => count($order1) . '笔订单合并支付',
- 'extend_params' => [
- 'royalty_freeze' => 'true'
- ]
- ];
- $order_union = new OrderUnion();
- $order_union->store_id = get_store_id();
- $order_union->user_id = get_user()->id;
- $order_union->order_no = $order['out_trade_no'];
- $order_union->price = $order['total_amount'];
- $order_union->is_pay = 0;
- $order_union->created_at = time();
- $order_union->is_delete = 0;
- $order_id_list = [];
- foreach ($order1 as $value) {
- $order_id_list[] = $value->id;
- }
- $order_union->order_id_list = json_encode($order_id_list);
- if (!$order_union->save()) {
- foreach ($order_union->errors as $error) {
- return [
- 'code' => 1,
- 'msg' => $error
- ];
- }
- }
- }else{
- /** 逻辑开始 **/
- $order = [
- 'body' => $subject,
- 'out_trade_no' => $order->order_no,
- 'total_amount' => $balance_price > 0 ? ($order->pay_price - $balance_price) : $order->pay_price,
- 'subject' => $subject,
- 'extend_params' => [
- 'royalty_freeze' => 'true'
- ]
- ];
- }
- \Yii::error($order);
- try {
- $res = self::$alipay->app($order)->getContent();
- } catch (\Exception $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- if($type == OrderNo::ORDER_UNION){
- foreach($order1 as $value){
- $value->order_union_id = $order_union->id;
- $value->save();
- }
- }
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res,
- 'res' => $res
- ];
- }
- /**
- * 订单查询
- * @param $order
- * @param $type 默认:wap: 普通订单,refund:退款订单,transfer: 转账订单
- * @return array | Collection
- */
- public static function find($order, $type = 'wap') {
- if (!in_array($type, self::$validFlag)) {
- return [
- 'code' => 1,
- 'msg' => 'Params are wrong'
- ];
- }
- self::init($order->store_id);
- /** 逻辑开始 **/
- $order = [
- 'out_trade_no' => $order->order_no,
- 'query_options' => ['trade_settle_info']
- ];
- if ($type == self::FLAG_REFUND) {
- // 后端生成,唯一即可
- $order['out_request_no'] = $order->order_no;
- }
- try {
- $res = self::$alipay->find($order, $type);
- if ($res && $res->code === '10000' && $res->msg === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res->toArray()
- ];
- }
- return [
- 'code' => $res->code,
- 'msg' => $res->msg,
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * wap支付
- * @param $order
- * @param $subject
- * @param $return_url
- * @return array
- */
- public static function wap($order, $subject, $return_url = '', $type = '', $total_pay_price = 0, $balance_price = 0, $payData = []) {
- if(!$return_url){
- $return_url = pay_return_url(self::$h5_url);
- }
- self::init($order->store_id, $return_url, false, 1);
- $order1 = $order;
- if($type == OrderNo::ORDER_UNION){
- $order = [
- 'body' => '订单合并支付',
- 'out_trade_no' => OrderNo::getOrderNo(OrderNo::ORDER_UNION),
- 'total_amount' => $balance_price > 0 ? $total_pay_price - $balance_price : $total_pay_price,
- 'subject' => count($order1) . '笔订单合并支付',
- 'buyer_id' => get_user()->alipay_open_id
- ];
- $order_union = new OrderUnion();
- $order_union->store_id = get_store_id();
- $order_union->user_id = get_user()->id;
- $order_union->order_no = $order['out_trade_no'];
- $order_union->price = $order['total_amount'];
- $order_union->is_pay = 0;
- $order_union->created_at = time();
- $order_union->is_delete = 0;
- $order_id_list = [];
- foreach ($order1 as $value) {
- $order_id_list[] = $value->id;
- }
- $order_union->order_id_list = json_encode($order_id_list);
- if (!$order_union->save()) {
- foreach ($order_union->errors as $error) {
- return [
- 'code' => 1,
- 'msg' => $error
- ];
- }
- }
- }else{
- /** 逻辑开始 **/
- $order = [
- 'body' => $subject,
- 'out_trade_no' => $order->order_no,
- 'total_amount' => $order->pay_price,
- 'subject' => $subject,
- 'buyer_id' => get_user()->alipay_open_id
- ];
- }
- try {
- $res = self::$alipay->wap($order);
- if ($res->getStatusCode() == 40004 || $res->getStatusCode() == 'ACQ.CONTEXT_INCONSISTENT') {
- $order->order_no = OrderNo::getOrderNo(OrderNo::ORDER_MALL);
- $order->save();
- return self::wap($order, $subject, $return_url, $type, $total_pay_price, $balance_price, $payData);
- }
- if($type == OrderNo::ORDER_UNION){
- foreach($order1 as $value){
- $value->order_union_id = $order_union->id;
- $value->save();
- }
- }
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res->getContent()
- ];
- } catch (\Exception $e) {
- return [
- 'code' => 1,
- 'msg' => '支付失败'. $e->getMessage()
- ];
- }
- }
- /**
- * web支付
- * @param $order
- * @param $subject
- * @param $return_url
- * @return Response | false | string
- */
- public static function web($order, $subject, $return_url = '') {
- self::init($order->store_id, $return_url);
- /** 逻辑开始 **/
- $order = [
- 'body' => $subject,
- 'out_trade_no' => $order->order_no,
- 'total_amount' => $order->pay_price,
- 'subject' => $subject,
- ];
- $res = self::$alipay->web($order)->send();
- return $res->getContent();
- }
- /**
- * 扫码支付
- * @param $order
- * @param $subject
- * @param $return_url
- * @return Collection | array
- */
- public static function scan($order, $subject, $return_url = '') {
- self::init($order->store_id, $return_url);
- /** 逻辑开始 **/
- $order = [
- 'body' => $subject,
- 'out_trade_no' => $order->order_no,
- 'total_amount' => $order->pay_price,
- 'subject' => $subject,
- ];
- try {
- $res = self::$alipay->scan($order);
- if ($res && $res->code === '10000' && $res->msg === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res->toArray()
- ];
- }
- return [
- 'code' => $res->code,
- 'msg' => $res->msg,
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 付款码支付
- * @param $order
- * @param $subject 订单标题
- * @param $return_url
- * @return Collection | array
- */
- public static function scanNew($order, $subject, $return_url = '', $auth_code,$total_pay_price = 0,$balance_price = 0) {
- self::init($order->store_id,$return_url);
- /** 逻辑开始 **/
- $data = [
- 'out_trade_no' => $order->order_no,//订单号
- 'total_amount' => $balance_price > 0 ? $total_pay_price - $balance_price : $total_pay_price,
- 'subject' => $subject,// 订单标题
- 'auth_code' => $auth_code,
- 'scene' => 'bar_code',
- ];
- try {
- $res = self::$alipay->pos($data);
- if ($res && $res->code === '10000' && $res->msg === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res->toArray()
- ];
- }
- return [
- 'code' => $res->code,
- 'msg' => $res->msg,
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 转账
- * @param $order
- * @param $mail
- * @param $return_url
- * @return Collection | array
- */
- public static function transfer($order, $mail, $return_url = '') {
- if (empty($mail)) {
- return [
- 'code' => 1,
- 'msg' => 'Params are wrong'
- ];
- }
- self::init($order->store_id, $return_url);
- /** 逻辑开始 **/
- $order = [
- 'out_biz_no' => $order->order_no,
- 'total_amount' => $order->pay_price,
- 'product_code' => 'TRANS_ACCOUNT_NO_PWD',
- 'payee_info' => [
- 'identity' => $mail,
- 'identity_type' => 'ALIPAY_LOGON_ID',
- ],
- ];
- try {
- $res = self::$alipay->transfer($order);
- if ($res && $res->code === '10000' && $res->msg === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res->toArray()
- ];
- }
- return [
- 'code' => $res->code,
- 'msg' => $res->msg,
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 批量转账
- * @param $params
- * @return Collection | array
- */
- public static function batchTransfer($params) {
- self::init('');
- /** 逻辑开始 **/
- $order = [
- 'out_batch_no' => $params['out_batch_no'],
- 'product_code' => 'BATCH_API_TO_ACC_NO_PWD',
- 'biz_scene' => 'MESSAGE_BATCH_PAY',
- 'total_trans_amount' => $params['total_trans_amount'],
- 'total_count' => 1,
- 'trans_order_list' => [
- [
- 'out_biz_no' => $params['out_batch_no'],
- 'trans_amount' => $params['total_trans_amount'],
- 'payee_info' => [
- 'identity' => $params['account'],
- 'identity_type' => 'ALIPAY_LOGON_ID',
- 'name' => $params['name']
- ],
- 'remark' => $params['title']
- ],
- ],
- 'order_title' => $params['title'],
- 'remark' => '转账',
- ];
- try {
- $res = self::$alipay->batchtransfer($order);
- \Yii::error($res);
- if ($res && $res->code === '10000' && $res->msg === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res->toArray()
- ];
- }
- return [
- 'code' => $res->code,
- 'msg' => $res->msg,
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 退款
- * @param $order
- * @param $return_url
- * @param $refund_fee
- * @return Collection | array
- */
- public static function refund($order, $refund_fee, $return_url = '') {
- self::init($order->store_id, $return_url);
- /** 逻辑开始 **/
- $data = [
- 'out_trade_no' => $order->order_no,
- 'refund_amount' => $refund_fee,
- ];
- try {
- $res = self::$alipay->refund($data);
- if ($res && $res->code === '10000' && $res->msg === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res->toArray()
- ];
- }
- return [
- 'code' => $res->code,
- 'msg' => $res->msg,
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 小程序支付
- * @param $order
- * @param $subject
- * @param User $user
- * @param $return_url
- * @param $is_food
- * @return Collection | array
- */
- public static function mini($order, $subject, $user, $return_url = '', $type = '', $is_food = false, $total_pay_price = 0, $balance_price = 0, $payData = []) {
- $self = self::init($order->store_id, $return_url);
- if (!$order || ($type != OrderNo::ORDER_UNION && empty($subject)) || !$user) {
- return [
- 'code' => 1,
- 'msg' => '参数有误'
- ];
- }
- $order1 = $order;
- if ($type == OrderNo::ORDER_UNION) {
- $order = [
- 'body' => '订单合并支付',
- 'out_trade_no' => OrderNo::getOrderNo(OrderNo::ORDER_UNION),
- 'total_amount' => $balance_price > 0 ? $total_pay_price - $balance_price : $total_pay_price,
- 'subject' => count($order1) . '笔订单合并支付',
- 'buyer_id' => $user->alipay_open_id
- ];
- $order_union = new OrderUnion();
- $order_union->store_id = get_store_id();
- $order_union->user_id = get_user()->id;
- $order_union->order_no = $order['out_trade_no'];
- $order_union->price = $order['total_amount'];
- $order_union->is_pay = 0;
- $order_union->created_at = time();
- $order_union->is_delete = 0;
- $order_id_list = [];
- foreach ($order1 as $value) {
- $order_id_list[] = $value->id;
- }
- $order_union->order_id_list = json_encode($order_id_list);
- if (!$order_union->save()) {
- foreach ($order_union->errors as $error) {
- return [
- 'code' => 1,
- 'msg' => $error
- ];
- }
- }
- } else {
- try{
- $goods_detail = [];
- $details = OrderDetail::findAll(['order_id' => $order->id]);
- foreach ($details as $detail) {
- $goods = Goods::findOne($detail->goods_id);
- $goods_detail[] = [
- 'goods_id' => $goods->goods_no,
- 'goods_name' => $detail->goods_name,
- 'quantity' => $detail->num,
- 'price' => $detail->total_price / $detail->num,
- ];
- }
- } catch (\Exception $e) {
- \Yii::error([__METHOD__, $order, $e]);
- }
- $order = [
- 'body' => $subject,
- 'out_trade_no' => $order->order_no,
- 'total_amount' => $balance_price > 0 ? ($order->pay_price - $balance_price) : $order->pay_price,
- 'subject' => $subject,
- 'buyer_id' => ($user->ali_openId ?: $user->alipay_open_id),
- 'store_id' => $order->store_id
- ];
- $goods_detail && $order['goods_detail'] = $goods_detail;
- if ($is_food) {
- $order['product_code'] = 'FACE_TO_FACE_PAYMENT';
- $order['extend_params'] = [
- 'food_order_type' => 'qr_order',
- 'sys_service_provider_id' => self::$alipay_config['user_id']
- ];
- } else {
- $store = Store::findOne($order['store_id']);
- if($store->transfer_profit > 0){
- $order['extend_params'] = [
- 'royalty_freeze' => 'true'
- ];
- }
- $order['product_code'] = 'JSAPI_PAY';
- }
- }
- try {
- if($payData->ali_requireOrder && $payData->ali_sourceId){
- $form = new \app\modules\admin\models\AlipayThirdForm();
- $form->bind_store_id = $order->store_id ?: get_store_id();
- $form->mini_id = $self->mini_id;
- $openOrder = $form->AlipayOpenMiniOrderCreate($order1, $order, $payData);
- if($openOrder['code'] != 0){
- return $openOrder;
- }
- $order['product_code'] = 'JSAPI_PAY';
- $order['extend_params'] = array_merge((array)$order['extend_params'], [
- 'trade_component_order_id' => $openOrder['data'],
- ]);
- foreach($openOrder['biz_content']['order_detail']['item_infos'] as $item){
- $order['goods_detail'][] = [
- 'goods_id' => $item['goods_id'],
- 'goods_name' => $item['goods_name'],
- 'quantity' => $item['item_cnt'],
- 'price' => $item['sale_price'],
- 'out_item_id' => $item['out_item_id'],
- 'out_sku_id' => $item['out_sku_id'],
- ];
- }
- }
-
- $res = self::$alipay->mini($order);
- if ($res && $res->code === '10000' && $res->msg === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res->toArray()
- ];
- }
- if ($type == OrderNo::ORDER_UNION) {
- foreach ($order1 as $value) {
- $value->order_union_id = $value->id;
- $value->save();
- }
- }
- return [
- 'code' => $res->code,
- 'msg' => $res->msg,
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * token
- * @param $authCode
- * @return array | Collection
- */
- public static function token($authCode) {
- if (empty($authCode)) {
- return [
- 'code' => 1,
- 'msg' => 'code不能为空'
- ];
- }
- $alipay_config = Option::getSaasAlipay();
- $config = [
- 'app_id' => $alipay_config['app_id'],
- 'return_url' => 'https://quanqudao.we10.cn',
- 'notify_url' => pay_notify_url(self::$notify_url),
- 'private_key' => $alipay_config['app_private_key'],
- 'log' => [ // optional
- 'file' => \Yii::$app->basePath . '/runtime/logs/alipay.log',
- 'level' => 'debug', // 建议生产环境等级调整为 info,开发环境为 debug
- 'type' => 'single', // optional, 可选 daily.
- 'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
- ],
- 'ali_public_key' => $alipay_config['alipay_public_key'],
- // 'app_cert_public_key' => \Yii::$app->basePath. '/utils/Alipay/CRT/app_cert_public_key.crt', // 应用公钥证书路径
- // 'ali_public_key' => \Yii::$app->basePath. '/utils/Alipay/CRT/alipay_cert_public_key.crt', // 支付宝公钥证书路径
- // 'alipay_root_cert' => \Yii::$app->basePath. '/utils/Alipay/CRT/alipay_root_cert.crt', // 支付宝根证书路径
- // 'mode' => 'dev' // optional,设置此参数,将进入沙箱模式
- ];
- $alipay = Pay::alipay($config);
- $params = [
- 'grant_type' => 'authorization_code',
- 'code' => $authCode
- ];
- /** 逻辑开始 **/
- try {
- $res = $alipay->token($params)->get('alipay_open_auth_token_app_response');
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res['tokens'][0]['app_auth_token']
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 拼接授权链接供商户提供授权
- */
- public static function authLink() {
- $store_id = get_store_id();
- $app_id = Option::get('alipay_appid', 0, 'saas')['value'];
- if (empty($app_id)) {
- return [
- 'code' => 1,
- 'msg' => '服务商appid不存在'
- ];
- }
- $type = join(',', self::$validAuthType);
- $redirect_uri = \Yii::$app->request->hostInfo . '/index.php/alipay/callback';
- $callback_url = self::AUTH_URL . '?app_id=' . $app_id . '&application_type='. $type . '&redirect_uri=' . $redirect_uri . '&state=' . $store_id;
- return [
- 'code' => 0,
- 'data' => ['url' => $callback_url]
- ];
- }
- /**
- * 绑定关系
- * @param string $out_trade_no
- * @param array $receiver_list
- * @return array
- */
- public static function bind($out_trade_no, $receiver_list, $is_app = false) {
- // 绑定关系必须为真实姓名。个人账户为个人真实姓名,企业账户为企业名称
- \Yii::warning($receiver_list);
- $valid_receive_type = array_keys(SharingReceiver::$validAlipayReceiveType);
- foreach ($receiver_list as $index => $receiver) {
- if (empty($receiver['account']) || !in_array($receiver['type'], $valid_receive_type) || empty($receiver['name'])) {
- unset($receiver_list[$index]);
- \Yii::warning('<========================> 订单号:' . $out_trade_no . '添加分账关系校验参数错误:' . json_encode($receiver));
- continue;
- }
- $receiver_list[$index]['type'] = SharingReceiver::$validAlipayReceiveType[$receiver['type']];
- }
- if (empty($receiver_list)) {
- return [
- 'code' => 1,
- 'msg' => '接收方为空'
- ];
- }
- $store_id = get_store_id();
- // self::init($store_id, '', $is_app);
- $params = [
- 'receiver_list' => $receiver_list,
- 'out_request_no' => $out_trade_no
- ];
- //原来逻辑会报错验签失败,所以用新款的 START
- $data = ['store_id' => $store_id, 'is_cancel' => 0];
- if (\Yii::$app->prod_is_dandianpu()) {
- if (self_mini() === true) {
- $data['is_use'] = 1;
- }
- } else {
- $data['is_use'] = 1;
- }
- if ($is_app) {
- $store_token = StoreMiniToken::find()->where(['batch_status' => [2, 6], 'store_id' => $store_id])->select('app_auth_token')->asArray()->one();
- $store_mini['auth_token'] = $store_token['app_auth_token'];
- if (empty($store_mini['auth_token'])) {
- $store_mini = StoreAliMini::find()->where($data)->orderBy('id desc')->select('auth_token')->asArray()->one();
- }
- } else {
- $store_mini = StoreAliMini::find()->where($data)->orderBy('id desc')->select('auth_token')->asArray()->one();
- }
- $form = new AlipayThirdAppForm();
- $request = new AlipayTradeRoyaltyRelationBindRequest();
- $request->setBizContent(json_encode($params, JSON_UNESCAPED_UNICODE));
- $result = $form->miniCommon($request, null, 0, $store_mini['auth_token']);
- debug_log(ArrayHelper::toArray($result), 'Alipaybind.log');
- if ($result->code == 10000) {
- return [
- 'code' => 0,
- 'msg' => '绑定关系成功'
- ];
- } else {
- return [
- 'code' => 1,
- 'msg' => $result->sub_msg
- ];
- }
- //END
- \Yii::warning(json_encode($params));
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->bind($params)->get('alipay_trade_royalty_relation_bind_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success' && $res['result_code'] == 'SUCCESS') {
- return [
- 'code' => 0,
- 'msg' => '绑定关系成功'
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 解绑关系
- * @param string $out_trade_no
- * @param array $receiver_list
- * @return array
- */
- public static function unbind($out_trade_no, $receiver_list) {
- $valid_receive_type = array_keys(SharingReceiver::$validAlipayReceiveType);
- foreach ($receiver_list as $index => $receiver) {
- if (empty($receiver['account']) || !in_array($receiver['type'], $valid_receive_type)) {
- unset($receiver_list[$index]);
- \Yii::warning('<========================> 订单号:' . $out_trade_no . '添加分账关系校验参数错误:' . json_encode($receiver));
- }
- }
- if (empty($receiver_list)) {
- return [
- 'code' => 1,
- 'msg' => '接收方为空'
- ];
- }
- self::init(get_store_id());
- $params = [
- 'receiver_list' => $receiver_list,
- 'out_request_no' => $out_trade_no
- ];
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->unbind($params)->get('alipay_trade_royalty_relation_unbind_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success' && $res['result_code'] == 'SUCCESS') {
- return [
- 'code' => 0,
- 'msg' => '关系解绑成功'
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * queryBind
- * @param integer $page
- * @param integer $page_size
- * @param string $out_trade_no
- * @return array
- */
- public static function queryBind($out_trade_no, $page = 1, $page_size = 10) {
- if (empty($out_trade_no)) {
- return [
- 'code' => 1,
- 'msg' => '商户订单号不能为空'
- ];
- }
- self::init(get_store_id());
- $params = [
- 'page_num' => $page,
- 'page_size' => $page_size,
- 'out_request_no' => $out_trade_no
- ];
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->queryBind($params)->get('alipay_trade_royalty_relation_batchquery_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success' && $res['result_code'] == 'SUCCESS') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $res['receiver_list'],
- 'total_page_num' => $res['total_page_num'],
- 'total_record_num' => $res['total_record_num'],
- 'current_page_num' => $res['current_page_num'],
- 'current_page_size' => $res['current_page_size']
- ]
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * settle 分账结算
- * @param integer $page
- * @param integer $page_size
- * @param string $out_trade_no
- * @param array $parameters
- * @param string $is_end
- * @return array
- */
- public static function settle($out_trade_no, $alipay_trade_no, $parameters, $store_id, $is_end = 'false', $is_app = false) {
- if (empty($out_trade_no) || empty($alipay_trade_no) || empty($parameters)) {
- return [
- 'code' => 1,
- 'msg' => '参数有误'
- ];
- }
- $params = [
- 'out_request_no' => $out_trade_no,
- 'trade_no' => $alipay_trade_no,
- 'royalty_parameters' => $parameters,
- 'extend_params' => [
- 'royalty_finish' => $is_end
- ]
- ];
- self::init($store_id, '', $is_app);
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->settle($params)->get('alipay_trade_order_settle_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success'
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * qrcode 小程序二维码
- * @param string $url_param 页面地址 page/index/index
- * @param string $query_param 页面参数,示例:x=1
- * @param string $describe 二维码描述
- * @return array
- */
- public static function qrcode($url_param, $query_param, $describe) {
- if (empty($url_param) || empty($query_param) || empty($describe)) {
- return [
- 'code' => 1,
- 'msg' => '参数有误'
- ];
- }
- $params = [
- 'url_param' => $url_param,
- 'query_param' => $query_param,
- 'describe' => $describe
- ];
- self::init(get_store_id());
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->qrcode($params)->get('alipay_open_app_qrcode_create_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res['qr_code_url']
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 店铺信息图片上传
- * @param string $image_type 图片类型
- * @param string $image_content 图片内容 二进制
- * @return array
- */
- public static function image($image_type, $image_content) {
- if (empty($image_type) || empty($image_content)) {
- return [
- 'code' => 1,
- 'msg' => '参数有误'
- ];
- }
- $params = [
- 'image_type' => $image_type,
- 'image_content' => $image_content
- ];
- self::init(get_store_id());
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->image($params)->get('ant_merchant_expand_indirect_image_upload_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 创建店铺
- * @param array $params
- * @return array
- */
- public static function shop_create($params) {
- if (empty($params)) {
- return [
- 'code' => 1,
- 'msg' => '参数有误'
- ];
- }
- self::init(get_store_id());
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->shop($params)->get('ant_merchant_expand_shop_create_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res['order_id']
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 查询门店创建结果
- * @param string $order_id 订单id
- * @return array
- */
- public static function shop_query($order_id) {
- if (empty($order_id)) {
- return [
- 'code' => 1,
- 'msg' => '参数有误'
- ];
- }
- $params = [
- 'order_id' => $order_id
- ];
- self::init(get_store_id());
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->queryShop($params)->get('ant_merchant_expand_order_query_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 同步订单
- * @param array $params 订单信息
- * @return array
- */
- public static function order_sync($params, $store_id) {
- if (empty($params)) {
- return [
- 'code' => 1,
- 'msg' => '参数有误'
- ];
- }
- self::init($store_id);
- /** 逻辑开始 **/
- try {
- $res = self::$alipay->orderSync($params)->get('alipay_merchant_order_sync_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 上传商品文件
- * @param string $scene 业务场景描述
- * @param string $file_content 文件二进制字节流
- * @return array
- */
- public static function file_upload_old($file_content, $scene = 'SYNC_ORDER') {
- if (empty($file_content)) {
- return [
- 'code' => 1,
- 'msg' => '参数有误'
- ];
- }
- self::init(get_store_id());
- /** 逻辑开始 **/
- $params = [
- 'scene' => $scene,
- 'file_content' => $file_content
- ];
- try {
- $res = self::$alipay->itemUpload($params)->get('alipay_merchant_item_file_upload_response');
- \Yii::warning($res);
- if ($res && $res['code'] === '10000' && $res['msg'] === 'Success') {
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $res
- ];
- }
- return [
- 'code' => 1,
- 'msg' => $res['sub_msg'],
- 'res' => $res
- ];
- } catch (GatewayException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidSignException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- } catch (InvalidConfigException $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 原生上传图片
- * @param $image
- * @return array
- * @throws \Exception
- */
- public static function file_upload($image) {
- self::init(get_store_id());
- self::aopClient();
- $request = new \AlipayMerchantItemFileUploadRequest();
- $request->setScene("SYNC_ORDER");
- $request->setFileContent("@". $image);
- $result = self::$aop->execute ( $request, null, Store::findOne(get_store_id())->app_auth_token);
- $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
- $resultNode = $result->$responseNode;
- return (array)($resultNode);
- }
- private static function aopClient() {
- $aop = new \AopClient();
- $aop->gatewayUrl = self::$gatewayUrl;
- $aop->appId = self::$alipay_config['app_id'];
- $aop->rsaPrivateKey = self::$alipay_config['app_private_key'];
- $aop->alipayrsaPublicKey = self::$alipay_config['alipay_public_key'];
- $aop->apiVersion = '1.0';
- $aop->signType = 'RSA2';
- $aop->postCharset='utf-8';
- $aop->format='json';
- self::$aop = $aop;
- }
- }
|