收紧微信支付能力日志边界
微信虚拟支付不可用时只记录稳定标签 补充不可用路径日志脱敏测试 更新原生壳根门禁防止能力细节泄露
This commit is contained in:
@@ -96,10 +96,7 @@ function requestOrdinaryPayment(payParams) {
|
||||
function requestVirtualPayment(payParams) {
|
||||
return new Promise((resolve) => {
|
||||
if (!canUseVirtualPayment() || typeof wx.requestVirtualPayment !== 'function') {
|
||||
console.error('[wechat-pay] requestVirtualPayment unavailable', {
|
||||
canUseVirtualPayment: canUseVirtualPayment(),
|
||||
hasRequestVirtualPayment: typeof wx.requestVirtualPayment === 'function',
|
||||
});
|
||||
logWechatPayFailure('requestVirtualPayment unavailable');
|
||||
resolve({
|
||||
status: 'fail',
|
||||
errorMessage: '当前微信基础库不支持 requestVirtualPayment',
|
||||
|
||||
@@ -133,6 +133,32 @@ describe('wechat-pay mini program payment bridge', () => {
|
||||
expect(console.error.mock.calls.flat()).not.toContain(payError);
|
||||
});
|
||||
|
||||
test('logs virtual payment unavailable without exposing capability details', async () => {
|
||||
const { requestWechatPayment } = wechatPayBridge;
|
||||
globalThis.wx.canIUse = vi.fn(() => false);
|
||||
globalThis.wx.getSystemInfoSync = vi.fn(() => ({ SDKVersion: '2.18.0' }));
|
||||
delete globalThis.wx.requestVirtualPayment;
|
||||
|
||||
await expect(
|
||||
requestWechatPayment({
|
||||
mode: 'short_series_coin',
|
||||
signData: '{}',
|
||||
paySig: 'pay-sig',
|
||||
signature: 'user-sig',
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
status: 'fail',
|
||||
errorMessage: '当前微信基础库不支持 requestVirtualPayment',
|
||||
});
|
||||
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'[wechat-pay] requestVirtualPayment unavailable',
|
||||
);
|
||||
expect(console.error.mock.calls).toContainEqual([
|
||||
'[wechat-pay] requestVirtualPayment unavailable',
|
||||
]);
|
||||
});
|
||||
|
||||
test('hides ordinary payment native failure details from H5 result', async () => {
|
||||
const { requestWechatPayment } = wechatPayBridge;
|
||||
globalThis.wx.requestPayment.mockImplementationOnce((options) => {
|
||||
|
||||
Reference in New Issue
Block a user