锁定微信支付失败响应
微信支付失败结果不再向 H5 透出原生错误 微信支付测试覆盖普通支付失败和虚拟支付取消的稳定文案 native shell 总门禁反查微信支付结果边界
This commit is contained in:
@@ -64,21 +64,8 @@ function resolvePayStatus(error) {
|
||||
return errCode === -2 || /cancel/i.test(errMsg) ? 'cancel' : 'fail';
|
||||
}
|
||||
|
||||
function normalizePayError(error) {
|
||||
if (!error) {
|
||||
return '';
|
||||
}
|
||||
if (typeof error === 'string') {
|
||||
return error;
|
||||
}
|
||||
try {
|
||||
return JSON.stringify({
|
||||
errCode: error.errCode,
|
||||
errMsg: error.errMsg,
|
||||
});
|
||||
} catch (_error) {
|
||||
return String(error.errMsg || error);
|
||||
}
|
||||
function normalizePayError() {
|
||||
return 'wechat payment unavailable';
|
||||
}
|
||||
|
||||
function requestOrdinaryPayment(payParams) {
|
||||
|
||||
@@ -125,10 +125,7 @@ describe('wechat-pay mini program payment bridge', () => {
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
status: 'cancel',
|
||||
errorMessage: JSON.stringify({
|
||||
errCode: -2,
|
||||
errMsg: 'requestVirtualPayment:fail cancel',
|
||||
}),
|
||||
errorMessage: 'wechat payment unavailable',
|
||||
});
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'[wechat-pay] requestVirtualPayment failed',
|
||||
@@ -136,6 +133,29 @@ describe('wechat-pay mini program payment bridge', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('hides ordinary payment native failure details from H5 result', async () => {
|
||||
const { requestWechatPayment } = wechatPayBridge;
|
||||
globalThis.wx.requestPayment.mockImplementationOnce((options) => {
|
||||
options.fail?.({
|
||||
errCode: 1001,
|
||||
errMsg: 'requestPayment:fail private native detail',
|
||||
});
|
||||
});
|
||||
|
||||
await expect(
|
||||
requestWechatPayment({
|
||||
timeStamp: '1777110165',
|
||||
nonceStr: 'nonce',
|
||||
package: 'prepay_id=wx-prepay',
|
||||
signType: 'RSA',
|
||||
paySign: 'signature',
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
status: 'fail',
|
||||
errorMessage: 'wechat payment unavailable',
|
||||
});
|
||||
});
|
||||
|
||||
test('notifies previous web-view after virtual payment', () => {
|
||||
const { notifyPreviousWebView } = wechatPayBridge;
|
||||
const previousPage = {
|
||||
|
||||
Reference in New Issue
Block a user