Skip to content

Commit

Permalink
修复微信jsApi支付的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed Mar 13, 2020
1 parent 95d69b8 commit 7ed2a22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/wxpay/example/WxPay.JsApiPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public function GetOpenid()
//通过code获得openid
if (!isset($_GET['code'])){
//触发微信返回code码
$baseUrl = urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //.$_SERVER['QUERY_STRING']);
$https = Yii::$service->url->isHttps() ? 'https' : 'http';
$baseUrl = urlencode($https . '://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); // $_SERVER['QUERY_STRING'];
// echo $baseUrl;exit;
$url = $this->__CreateOauthUrlForCode($baseUrl);
Header("Location: $url");
exit();
Expand Down
11 changes: 11 additions & 0 deletions services/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ public function homeUrl()
{
return Yii::$app->getHomeUrl();
}

public function isHttps()
{
$homeUrl = $this->homeUrl();
if (substr($homeUrl, 0, 5) == 'https') {

return true;
}

return false;
}

/**
* get base url.
Expand Down

0 comments on commit 7ed2a22

Please sign in to comment.