1 Commits

Author SHA1 Message Date
erio
2590145a2c fix: 易支付移动端传 device=jump 以支持微信H5支付唤起 2026-03-16 13:47:56 +08:00
3 changed files with 9 additions and 5 deletions

View File

@@ -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');
});
});

View File

@@ -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<EasyPay
params.cid = cid;
}
if (opts.isMobile) {
params.device = 'jump';
}
const sign = generateSign(params, env.EASY_PAY_PKEY);
params.sign = sign;
params.sign_type = 'MD5';

View File

@@ -29,6 +29,7 @@ export class EasyPayProvider implements PaymentProvider {
clientIp: request.clientIp || '127.0.0.1',
productName: request.subject,
returnUrl: request.returnUrl,
isMobile: request.isMobile,
});
return {