fix(epay): createOrderApi 补传 clientip 参数(mapi.php 必填)

This commit is contained in:
testadmin
2026-04-16 23:49:52 +08:00
parent f3eb260841
commit 9ca6c646db
+6 -1
View File
@@ -131,10 +131,14 @@ class Epay
/** /**
* API 模式下单(mapi.php * API 模式下单(mapi.php
* *
* @param string $clientIp 下单用户的 IPmapi.php 必填,否则报 "用户IP地址(clientip)不能为空"
* @return array|null * @return array|null
*/ */
public function createOrderApi($orderNo, $type, $amount, $name, $notifyUrl, $returnUrl = '', $param = '') public function createOrderApi($orderNo, $type, $amount, $name, $notifyUrl, $returnUrl = '', $param = '', $clientIp = '')
{ {
if ($clientIp === '' || $clientIp === null) {
$clientIp = \think\Request::instance()->ip();
}
$params = [ $params = [
'pid' => strval($this->config['pid'] ?? ''), 'pid' => strval($this->config['pid'] ?? ''),
'type' => $type, 'type' => $type,
@@ -144,6 +148,7 @@ class Epay
'name' => $name, 'name' => $name,
'money' => strval($amount), 'money' => strval($amount),
'param' => $param, 'param' => $param,
'clientip' => strval($clientIp),
'sign_type' => 'MD5', 'sign_type' => 'MD5',
]; ];
$params['sign'] = $this->generateSign($params); $params['sign'] = $this->generateSign($params);