From 2590145a2c3868133b3bd428baea0f30ebdb4823 Mon Sep 17 00:00:00 2001 From: erio Date: Mon, 16 Mar 2026 13:47:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=98=93=E6=94=AF=E4=BB=98=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E4=BC=A0=20device=3Djump=20=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=BE=AE=E4=BF=A1H5=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=94=A4=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/payment-flow.test.ts | 8 +++----- src/lib/easy-pay/client.ts | 5 +++++ src/lib/easy-pay/provider.ts | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/__tests__/payment-flow.test.ts b/src/__tests__/payment-flow.test.ts index c141612..1e9cc3e 100644 --- a/src/__tests__/payment-flow.test.ts +++ b/src/__tests__/payment-flow.test.ts @@ -193,7 +193,7 @@ describe('Payment Flow - PC/Mobile, QR/Redirect', () => { ).toBe(true); }); - it('EasyPay does not use isMobile flag itself (delegates to frontend)', async () => { + it('EasyPay forwards isMobile to client for device=jump on mobile', async () => { mockEasyPayCreatePayment.mockResolvedValue({ code: 1, trade_no: 'EP-003', @@ -212,16 +212,14 @@ describe('Payment Flow - PC/Mobile, QR/Redirect', () => { await provider.createPayment(request); - // EasyPay client is called the same way regardless of isMobile + // EasyPay client receives isMobile so it can set device=jump expect(mockEasyPayCreatePayment).toHaveBeenCalledWith( expect.objectContaining({ outTradeNo: 'order-ep-003', paymentType: 'alipay', + isMobile: true, }), ); - // No isMobile parameter forwarded to the underlying client - const callArgs = mockEasyPayCreatePayment.mock.calls[0][0]; - expect(callArgs).not.toHaveProperty('isMobile'); }); }); diff --git a/src/lib/easy-pay/client.ts b/src/lib/easy-pay/client.ts index 597a72e..6563bdb 100644 --- a/src/lib/easy-pay/client.ts +++ b/src/lib/easy-pay/client.ts @@ -9,6 +9,7 @@ export interface CreatePaymentOptions { clientIp: string; productName: string; returnUrl?: string; + isMobile?: boolean; } function normalizeCidList(cid?: string): string | undefined { @@ -68,6 +69,10 @@ export async function createPayment(opts: CreatePaymentOptions): Promise