From cd983a25c3e26f27145b1b1ed75eb48fb4df4598 Mon Sep 17 00:00:00 2001 From: Billy <641833868@qq.com> Date: Mon, 27 Oct 2025 16:31:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/config/ccblife.php | 24 +-------- .../library/ccblife/CcbPaymentService.php | 50 +++++++++++-------- 2 files changed, 31 insertions(+), 43 deletions(-) diff --git a/addons/shopro/config/ccblife.php b/addons/shopro/config/ccblife.php index 0741cdd..0f96fd1 100644 --- a/addons/shopro/config/ccblife.php +++ b/addons/shopro/config/ccblife.php @@ -42,37 +42,17 @@ return [ // ========== 密钥配置 (从.env读取) ========== /** - * 商户私钥 (商户自己生成的RSA私钥) - * 用途: - * - API请求签名(MD5(明文 + 私钥)) - * - 解密建行返回的加密数据(ccbParamSJ等) - * - 解密建行API响应报文 - * 格式: BASE64格式(不含PEM头尾) 或 PEM格式(含头尾) - * - * ⚠️ 安全提示: 私钥必须严格保密,不得泄露! + * 服务方私钥 */ 'private_key' => $envVars['private_key'] ?? '', /** - * 服务方公钥 (服务方自己生成的RSA公钥) - * 用途: - * - 支付下单的MD5签名计算(PLATFORMPUB字段) - * - 用于加密商户公钥生成ENCPUB - * 格式: BASE64格式(不含PEM头尾) 或 PEM格式(含头尾) - * - * 📌 注意: 这是参与支付签名计算的服务方公钥 + * 服务方公钥 */ 'public_key' => $envVars['public_key'] ?? '', /** * 商户公钥 (商户自己生成的RSA公钥,与上面的private_key对应) - * 用途: - * - 生成ENCPUB密文(使用服务方公钥加密商户公钥后30位) - * - 提交给建行用于验证商户签名 - * 格式: BASE64格式(不含PEM头尾) 或 PEM格式(含头尾) - * - * 📌 注意: 需要将此公钥提交给建行进行配置 - * 📌 如果已上架建行生活并同步公钥,可以不再上送ENCPUB */ 'merchant_public_key' => $envVars['merchant_public_key'] ?? '', diff --git a/addons/shopro/library/ccblife/CcbPaymentService.php b/addons/shopro/library/ccblife/CcbPaymentService.php index 3c8bd77..d185d01 100644 --- a/addons/shopro/library/ccblife/CcbPaymentService.php +++ b/addons/shopro/library/ccblife/CcbPaymentService.php @@ -164,26 +164,46 @@ class CcbPaymentService $macParams['ACCOUNTBITMAP'] = $this->config['account_bitmap']; } - // 积分相关 + // ✅ 严格按照文档4.1表格顺序添加参数(第27-40位) + // 积分活动编号(第27位) if (!empty($this->config['point_avy_id'])) { $macParams['POINTAVYID'] = $this->config['point_avy_id']; } - if (!empty($this->config['fixed_point_val'])) { - $macParams['FIXEDPOINTVAL'] = $this->config['fixed_point_val']; - } - if (!empty($this->config['min_point_limit'])) { - $macParams['MINPOINTLIMIT'] = $this->config['min_point_limit']; + + // 数字人民币收款钱包编号(第28位) + if (!empty($this->config['dcep_dep_acc_no'])) { + $macParams['DCEPDEPACCNO'] = $this->config['dcep_dep_acc_no']; } - // 有价券相关 + // 有价券活动编号(第29位) if (!empty($this->config['coupon_avy_id'])) { $macParams['COUPONAVYID'] = $this->config['coupon_avy_id']; } + + // 限制信用卡支付标志(第30位) if (!empty($this->config['only_credit_pay_flag'])) { $macParams['ONLY_CREDIT_PAY_FLAG'] = $this->config['only_credit_pay_flag']; } - // 数字人民币参数 + // 固定抵扣积分值(第31位) + if (!empty($this->config['fixed_point_val'])) { + $macParams['FIXEDPOINTVAL'] = $this->config['fixed_point_val']; + } + + // 最小使用积分抵扣限制(第32位) + if (!empty($this->config['min_point_limit'])) { + $macParams['MINPOINTLIMIT'] = $this->config['min_point_limit']; + } + + // 特殊字段(中石化专用,第33-34位) + if (!empty($this->config['identity_code'])) { + $macParams['IDENTITYCODE'] = $this->config['identity_code']; + } + if (!empty($this->config['notify_url'])) { + $macParams['NOTIFY_URL'] = $this->config['notify_url']; + } + + // 数字人民币商户类型(第35-38位) if (!empty($this->config['dcep_mct_type'])) { $macParams['DCEP_MCT_TYPE'] = $this->config['dcep_mct_type']; if ($this->config['dcep_mct_type'] == '2') { @@ -198,9 +218,6 @@ class CcbPaymentService $macParams['DCEP_BRANCHID'] = $this->config['dcep_branch_id']; } } - if (!empty($this->config['dcep_dep_acc_no'])) { - $macParams['DCEPDEPACCNO'] = $this->config['dcep_dep_acc_no']; - } } // 二级商户参数 @@ -214,21 +231,12 @@ class CcbPaymentService $macParams['SUB_MCT_MCC'] = $this->config['sub_mct_mcc']; } - // 扩展域 + // 扩展域(第43位) if (!empty($this->config['extend_params'])) { // ⚠️ 不要在这里urlencode,会在构建最终支付串时统一编码 $macParams['EXTENDPARAMS'] = $this->config['extend_params']; } - // 特殊字段(中石化专用) - if (!empty($this->config['identity_code'])) { - $macParams['IDENTITYCODE'] = $this->config['identity_code']; - } - if (!empty($this->config['notify_url'])) { - // ⚠️ 不要在这里urlencode,会在构建最终支付串时统一编码 - $macParams['NOTIFY_URL'] = $this->config['notify_url']; - } - // 2. 手动构建签名字符串(不能用http_build_query,避免URL编码破坏escape格式) // ⚠️ 关键:按照建行文档4.2示例,签名字符串不进行URL编码 $signParts = [];