From 9ca6c646db49f2fbeb63d0b171371a2bc014aa37 Mon Sep 17 00:00:00 2001 From: testadmin Date: Thu, 16 Apr 2026 23:49:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(epay):=20createOrderApi=20=E8=A1=A5?= =?UTF-8?q?=E4=BC=A0=20clientip=20=E5=8F=82=E6=95=B0=EF=BC=88mapi.php=20?= =?UTF-8?q?=E5=BF=85=E5=A1=AB=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/pay/Epay.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extend/pay/Epay.php b/extend/pay/Epay.php index 9de924b..521349a 100644 --- a/extend/pay/Epay.php +++ b/extend/pay/Epay.php @@ -131,10 +131,14 @@ class Epay /** * API 模式下单(mapi.php) * + * @param string $clientIp 下单用户的 IP(mapi.php 必填,否则报 "用户IP地址(clientip)不能为空") * @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 = [ 'pid' => strval($this->config['pid'] ?? ''), 'type' => $type, @@ -144,6 +148,7 @@ class Epay 'name' => $name, 'money' => strval($amount), 'param' => $param, + 'clientip' => strval($clientIp), 'sign_type' => 'MD5', ]; $params['sign'] = $this->generateSign($params);