fix: 易支付移动端传 device=jump 以支持微信H5支付唤起
This commit is contained in:
@@ -193,7 +193,7 @@ describe('Payment Flow - PC/Mobile, QR/Redirect', () => {
|
|||||||
).toBe(true);
|
).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({
|
mockEasyPayCreatePayment.mockResolvedValue({
|
||||||
code: 1,
|
code: 1,
|
||||||
trade_no: 'EP-003',
|
trade_no: 'EP-003',
|
||||||
@@ -212,16 +212,14 @@ describe('Payment Flow - PC/Mobile, QR/Redirect', () => {
|
|||||||
|
|
||||||
await provider.createPayment(request);
|
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(mockEasyPayCreatePayment).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
outTradeNo: 'order-ep-003',
|
outTradeNo: 'order-ep-003',
|
||||||
paymentType: 'alipay',
|
paymentType: 'alipay',
|
||||||
|
isMobile: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// No isMobile parameter forwarded to the underlying client
|
|
||||||
const callArgs = mockEasyPayCreatePayment.mock.calls[0][0];
|
|
||||||
expect(callArgs).not.toHaveProperty('isMobile');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export interface CreatePaymentOptions {
|
|||||||
clientIp: string;
|
clientIp: string;
|
||||||
productName: string;
|
productName: string;
|
||||||
returnUrl?: string;
|
returnUrl?: string;
|
||||||
|
isMobile?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeCidList(cid?: string): string | undefined {
|
function normalizeCidList(cid?: string): string | undefined {
|
||||||
@@ -68,6 +69,10 @@ export async function createPayment(opts: CreatePaymentOptions): Promise<EasyPay
|
|||||||
params.cid = cid;
|
params.cid = cid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.isMobile) {
|
||||||
|
params.device = 'jump';
|
||||||
|
}
|
||||||
|
|
||||||
const sign = generateSign(params, env.EASY_PAY_PKEY);
|
const sign = generateSign(params, env.EASY_PAY_PKEY);
|
||||||
params.sign = sign;
|
params.sign = sign;
|
||||||
params.sign_type = 'MD5';
|
params.sign_type = 'MD5';
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export class EasyPayProvider implements PaymentProvider {
|
|||||||
clientIp: request.clientIp || '127.0.0.1',
|
clientIp: request.clientIp || '127.0.0.1',
|
||||||
productName: request.subject,
|
productName: request.subject,
|
||||||
returnUrl: request.returnUrl,
|
returnUrl: request.returnUrl,
|
||||||
|
isMobile: request.isMobile,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user