Skip to content

Commit

Permalink
feat: app paid function
Browse files Browse the repository at this point in the history
  • Loading branch information
helei112g committed Nov 26, 2019
1 parent 753bb2c commit d857e00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/Gateways/Wechat/AppCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function request(array $requestParams)

$resArr = DataParser::toArray($resXml);
if (!is_array($resArr) || $resArr['return_code'] !== self::REQ_SUC) {
throw new GatewayException($resArr['return_msg'], Payment::GATEWAY_REFUSE, $resArr);
throw new GatewayException($this->getErrorMsg($resArr), Payment::GATEWAY_REFUSE, $resArr);
}

return $resArr;
Expand All @@ -67,7 +67,7 @@ protected function getSelfParams(array $requestParams)
$limitPay = '';
}
$nowTime = time();
$expireTime = self::$config->get('timeout_express', '');
$expireTime = $nowTime + self::$config->get('timeout_express', '');
$receipt = $requestParams['receipt'] ?? false;
$totalFee = bcmul($requestParams['amount'], 100, 0);

Expand All @@ -81,12 +81,13 @@ protected function getSelfParams(array $requestParams)
'total_fee' => $totalFee,
'spbill_create_ip' => $requestParams['client_ip'] ?? '',
'time_start' => date('YmdHis', $nowTime),
'time_expire' => $expireTime,
'time_expire' => date('YmdHis', $expireTime),
'goods_tag' => $requestParams['goods_tag'] ?? '',
'notify_url' => self::$config->get('notify_url', ''),
'trade_type' => 'APP',
'limit_pay' => $limitPay,
'receipt' => $receipt === true ? 'Y' : '',
'scene_info' => $requestParams['scene_info'] ?? '', // 场景信息
];

return $selfParams;
Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/Wechat/WechatBaseObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function __construct()
// 初始 微信网关地址
$this->gatewayUrl = 'https://api.mch.weixin.qq.com/%s';
if ($this->isSandbox) {
$this->gatewayUrl = 'https://apitest.mch.weixin.qq.com/sandboxnew/%s';
$this->gatewayUrl = 'https://api.mch.weixin.qq.com/sandboxnew/%s';
} elseif ($this->useBackup) {
$this->gatewayUrl = 'https://api2.mch.weixin.qq.com/%s'; // 灾备地址
}
Expand All @@ -111,7 +111,7 @@ protected function buildParams(array $requestParams = [])
{
$signType = self::$config->get('sign_type', '');
$params = [
//'appid' => self::$config->get('app_id', ''),
'appid' => self::$config->get('app_id', ''),
'mch_id' => self::$config->get('mch_id', ''),
'nonce_str' => $this->nonceStr,
'sign_type' => $signType,
Expand Down
2 changes: 1 addition & 1 deletion src/Supports/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private function getBaseOptions()
{
$options = [
'base_uri' => method_exists($this, 'getBaseUri') ? $this->getBaseUri() : '',
'timeout' => method_exists($this, 'getTimeout') ? $this->getTimeout() : 10.0,
'timeout' => method_exists($this, 'getTimeout') ? $this->getTimeout() : 30.0,
];

$options = array_merge($options, $this->options);
Expand Down

0 comments on commit d857e00

Please sign in to comment.