This commit is contained in:
Billy 2025-10-27 17:28:55 +08:00
parent 267a76bd2c
commit 0614d5cdd9

View File

@ -115,8 +115,8 @@ class CcbPaymentService
$macParams['REGINFO'] = ''; // 客户注册信息(空字符串)
// 商品信息escape编码
// $proinfo = $this->buildProductInfo($order);
$macParams['PROINFO'] = '';
$proinfo = $this->buildProductInfo($order);
$macParams['PROINFO'] = $proinfo;
$macParams['REFERER'] = ''; // 商户URL空字符串
@ -263,7 +263,7 @@ class CcbPaymentService
Log::info('[建行支付] ' . $key . ' = ' . (strlen($value) > 100 ? substr($value, 0, 100) . '...(共' . strlen($value) . '字符)' : $value));
}
Log::info('[建行支付] MAC签名字符串(前500字符): ' . mb_substr($macSignString, 0, 500));
Log::info('[建行支付] MAC签名字符串: ' . $macSignString);
Log::info('[建行支付] 生成MAC: ' . $mac);
// 5. 构建不参与MAC的参数
@ -314,7 +314,7 @@ class CcbPaymentService
// 7.4 拼接最终支付串
$finalPaymentString = implode('&', $finalParts);
Log::info('[建行支付] 最终支付串(前500字符): ' . mb_substr($finalPaymentString, 0, 500));
Log::info('[建行支付] 最终支付串: ' . $finalPaymentString);
// 保存支付流水号到订单
Order::where('id', $orderId)->update([
@ -479,12 +479,8 @@ class CcbPaymentService
// CcbRSA::encrypt 会自动进行base64编码
$encpub = CcbRSA::encrypt($last30Chars, $servicePublicKey);
// ⚠️ 关键修复转换为URL-safe BASE64格式
// 根据文档和示例:"若密文中带有"+"、"/"符号说明少了BASE64这一步骤"
// 实际上需要将标准BASE64的 + 和 / 替换为 - 和 _
// 这样在URL传输时不会被误解析也符合建行的格式要求
$encpub = str_replace(['+', '/'], ['-', '_'], $encpub);
// ✅ 直接返回标准BASE64格式的ENCPUB
// 注意建行要求标准BASE64包含+和/不是URL-safe格式
return $encpub;
} catch (\Exception $e) {