This commit is contained in:
Billy 2025-10-27 15:26:09 +08:00
parent ec201fe0f4
commit adda69de16

View File

@ -477,7 +477,15 @@ class CcbPaymentService
// 使用服务方公钥加密这30位十六进制字符串
// CcbRSA::encrypt 会自动进行base64编码
return CcbRSA::encrypt($last30Chars, $servicePublicKey);
$encpub = CcbRSA::encrypt($last30Chars, $servicePublicKey);
// ⚠️ 关键修复转换为URL-safe BASE64格式
// 根据文档和示例:"若密文中带有"+"、"/"符号说明少了BASE64这一步骤"
// 实际上需要将标准BASE64的 + 和 / 替换为 - 和 _
// 这样在URL传输时不会被误解析也符合建行的格式要求
$encpub = str_replace(['+', '/'], ['-', '_'], $encpub);
return $encpub;
} catch (\Exception $e) {
Log::error('[建行支付] ENCPUB生成失败: ' . $e->getMessage());