fix: 支付宝 H5 下单失败时 fallback 到 PC 页面支付
与微信支付保持一致的 fallback 策略。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,27 +22,36 @@ export class AlipayProvider implements PaymentProvider {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async createPayment(request: CreatePaymentRequest): Promise<CreatePaymentResponse> {
|
async createPayment(request: CreatePaymentRequest): Promise<CreatePaymentResponse> {
|
||||||
const method = request.isMobile ? 'alipay.trade.wap.pay' : 'alipay.trade.page.pay';
|
const buildPayUrl = (mobile: boolean) => {
|
||||||
const productCode = request.isMobile ? 'QUICK_WAP_WAY' : 'FAST_INSTANT_TRADE_PAY';
|
const method = mobile ? 'alipay.trade.wap.pay' : 'alipay.trade.page.pay';
|
||||||
|
const productCode = mobile ? 'QUICK_WAP_WAY' : 'FAST_INSTANT_TRADE_PAY';
|
||||||
const url = pageExecute(
|
return pageExecute(
|
||||||
{
|
{
|
||||||
out_trade_no: request.orderId,
|
out_trade_no: request.orderId,
|
||||||
product_code: productCode,
|
product_code: productCode,
|
||||||
total_amount: request.amount.toFixed(2),
|
total_amount: request.amount.toFixed(2),
|
||||||
subject: request.subject,
|
subject: request.subject,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
notifyUrl: request.notifyUrl,
|
notifyUrl: request.notifyUrl,
|
||||||
returnUrl: request.returnUrl,
|
returnUrl: request.returnUrl,
|
||||||
method,
|
method,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
|
||||||
tradeNo: request.orderId,
|
|
||||||
payUrl: url,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let url: string;
|
||||||
|
if (request.isMobile) {
|
||||||
|
try {
|
||||||
|
url = buildPayUrl(true);
|
||||||
|
} catch {
|
||||||
|
url = buildPayUrl(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
url = buildPayUrl(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { tradeNo: request.orderId, payUrl: url };
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryOrder(tradeNo: string): Promise<QueryOrderResponse> {
|
async queryOrder(tradeNo: string): Promise<QueryOrderResponse> {
|
||||||
|
|||||||
Reference in New Issue
Block a user