锁定微信支付失败响应

微信支付失败结果不再向 H5 透出原生错误

微信支付测试覆盖普通支付失败和虚拟支付取消的稳定文案

native shell 总门禁反查微信支付结果边界
This commit is contained in:
2026-06-20 13:15:27 +08:00
parent c381f9a3eb
commit 16ae7925e2
3 changed files with 64 additions and 19 deletions
+38
View File
@@ -1874,6 +1874,41 @@ function assertWechatMiniProgramCapabilityFlows() {
}
}
function assertWechatPaymentResultBoundaries() {
const paymentSource = fs.readFileSync(
'miniprogram/host-bridge/payment.js',
'utf8',
);
const paymentTestSource = fs.readFileSync(
'miniprogram/host-bridge/payment.test.js',
'utf8',
);
for (const snippet of [
"function normalizePayError()",
"return 'wechat payment unavailable'",
]) {
if (!paymentSource.includes(snippet)) {
throw new Error(`wechat payment bridge must include ${snippet}`);
}
}
if (
paymentSource.includes('JSON.stringify({\n errCode') ||
paymentSource.includes('String(error.errMsg || error)')
) {
throw new Error('wechat payment bridge must not expose native payment errors to H5');
}
for (const snippet of [
'maps virtual payment cancel errCode to cancel result',
'hides ordinary payment native failure details from H5 result',
"errorMessage: 'wechat payment unavailable'",
]) {
if (!paymentTestSource.includes(snippet)) {
throw new Error(`wechat payment bridge test must include ${snippet}`);
}
}
}
function assertHostBridgeLayerLayout() {
assertSameList(
readDirectoryFileList(
@@ -2101,6 +2136,9 @@ assertWechatMiniProgramRouteParity();
console.log('[check:native-shells] wechat-mini-program-capability-flows');
assertWechatMiniProgramCapabilityFlows();
console.log('[check:native-shells] wechat-payment-result-boundaries');
assertWechatPaymentResultBoundaries();
console.log('[check:native-shells] h5-host-bridge-event-subscription-gates');
assertH5HostBridgeEventSubscriptionGates();