You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/application/wap/controller/Alipay.php

112 lines
3.8 KiB

<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\wap\controller;
use basic\WapBasic;
use service\AlipayTradeWapService;
use service\UtilService;
use service\SystemConfigService;
use service\JsonService;
use think\Log;
/**
* 支付宝支付
* Class Alipay
* @package app\wap\controller
*/
class Alipay extends WapBasic
{
protected function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$this->assign('overallShareWechat', json_encode([]));
$this->assign('userInfo', ['uid' => 0]);
}
/**
* 支付页微信端提示切换浏览器,其他浏览器直接支付
* @param string $info 加密后的支付参数
* @return mixed|void
*/
public function index($info = '', $params = false)
{
if (!$info) $this->failed('缺少支付参数');
$info = json_decode(base64_decode($info), true);
if (!$info) $this->failed('缺少支付参数');
$isWechat = UtilService::isWechatBrowser();
if ($isWechat) {
$this->assign('isWechat', $isWechat);
return $this->fetch();
} else {
Log::error();
return JsonService::successful(AlipayTradeWapService::init()->AliPayWap($info['orderId'], $info['pay_price'], $info['orderName'], $info['returnUrl'], $params));
}
}
/**
* 支付宝APP支付
* @param string $info 加密后的支付参数
* @return mixed|void
*/
public function appPay($info = '', $params = false)
{
if (!$info) return $this->failed('缺少支付参数');
$info = json_decode(base64_decode($info), true);
if (!$info) return $this->failed('缺少支付参数');
return JsonService::successful( AlipayTradeWapService::init()->AliPayApp($info['orderId'], $info['pay_price'], $info['orderName'], $params));
}
/**
* 在电脑端调起支付宝扫码支付
* @param string $info 加密后的支付参数
* @param bool $params
* @throws \Exception
*/
public function native($info = '', $params = false)
{
if (!$info) $this->failed('缺少支付参数');
$info = json_decode(base64_decode($info), true);
if (!$info) $this->failed('缺少支付参数');
if (request()->isMobile()) {
$this->failed('请不要在移动端调用该接口');
} else {
AlipayTradeWapService::init()->AliPayNative($info['orderId'], $info['pay_price'], $info['orderName'], $params);
}
}
/**
* 支付宝同步回调
* @return mixed
*/
public function alipay_success_synchro()
{
$res = AlipayTradeWapService::init()->AliPayReturn();
$result = $res['result'];
if ($result) $is_pay = true;
else $is_pay = false;
$isWechat = UtilService::isWechatBrowser();
$this->assign([
'isWechat' => $isWechat,
'is_pay' => $is_pay
]);
return $this->fetch();
}
/**
* 支付宝异步回调
*/
public function alipay_success_notify()
{
AlipayTradeWapService::handleNotify();
}
}