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(); } }