Browse Source

Merge branch 'yijia' of http://47.101.187.29:8081/loumengning/shop into yijia

undefined
xubinxcode 4 years ago
parent
commit
0c189cd124
4 changed files with 21 additions and 13 deletions
  1. +1
    -1
      addons/epay/controller/Api.php
  2. +13
    -5
      addons/epay/library/Service.php
  3. +3
    -2
      addons/unishop/controller/Pay.php
  4. +4
    -5
      public/index.php

+ 1
- 1
addons/epay/controller/Api.php View File

@@ -92,7 +92,7 @@ class Api extends Controller
$orderData['method'] = 'mp';
$orderData['openid'] = $openid;
$payData = Service::submitOrder($orderData);
$payData = json_decode($payData, true);
// $payData = json_decode($payData, true);
if (!isset($payData['appId'])) {
$this->error("创建订单失败,请返回重试");
}


+ 13
- 5
addons/epay/library/Service.php View File

@@ -5,6 +5,7 @@ namespace addons\epay\library;
use addons\unishop\model\Config;
use Exception;
use think\Log;
use think\Request;
use think\Response;
use think\Session;
use Yansongda\Pay\Gateways\Alipay\Alipay;
@@ -96,8 +97,11 @@ class Service
Session::delete("openid");
Session::set("wechatorderdata", $params);
$url = addon_url('epay/api/wechat', [], true, true);
header("location:{$url}");
exit;
$result = [
"trade_type"=>"MWEB",
"mweb_url"=>$url
];
return $result;
} elseif ($request->isMobile()) {
$method = 'wap';
}
@@ -126,8 +130,12 @@ class Service
//手机网页支付,跳转
$params['spbill_create_ip'] = $request->ip(0, false);
$html = $pay->driver($type)->gateway('wap')->pay($params);
header("location:{$html}");
exit;
$result = [
"trade_type"=>"MWEB",
"mweb_url"=>$html,
"referer"=>Request::instance()->server('HTTP_REFERER')
];
return $result;
break;
case 'app':
//APP支付,直接返回字符串
@@ -153,7 +161,7 @@ class Service
}
}
//返回字符串
$html = is_array($html) ? json_encode($html) : $html;
// $html = is_array($html) ? json_encode($html) : $html;
return $html;
}



+ 3
- 2
addons/unishop/controller/Pay.php View File

@@ -99,15 +99,16 @@ class Pay extends Base
$trade_type = 'wap';
}
$params = [
'amount' => bcmul($order['total_price'], 100),
'amount' => $order['total_price'],
'orderid' => $order->out_trade_no,
'type' => "wechat",
'title' => $body,
'notifyurl' => Config::getByName('notify_url')['value'],
'returnurl' => Config::getByName('ali_return_url')['value'],
'trade_type' => $trade_type,

];
return Service::submitOrder($params);
$this->success("", Service::submitOrder($params));
} catch (Exception $e) {
$this->error($e->getMessage());
}


+ 4
- 5
public/index.php View File

@@ -3,11 +3,10 @@
// 允许跨域
header('Access-Control-Allow-Origin:*');//允许跨域
header("Access-Control-Allow-Headers:*");
header("Access-Control-Allow-Methods: GET,POST,OPTION");
//if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
// header('Access-Control-Allow-Headers:platform,lang,x-requested-with,content-type,token');//浏览器页面ajax跨域请求会请求2次,第一次会发送OPTIONS预请求,不进行处理,直接exit返回,但因为下次发送真正的请求头部有带token,所以这里设置允许下次请求头带token否者下次请求无法成功
// exit("ok");
//}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
header('Access-Control-Allow-Headers:platform,lang,x-requested-with,content-type,token');//浏览器页面ajax跨域请求会请求2次,第一次会发送OPTIONS预请求,不进行处理,直接exit返回,但因为下次发送真正的请求头部有带token,所以这里设置允许下次请求头带token否者下次请求无法成功
exit("ok");
}
//
//
///**======设置跨域cookies传递===开始=====*/


Loading…
Cancel
Save