微信小程序支付功能打通
This commit is contained in:
@@ -49,7 +49,9 @@ export async function payOrder(orderId: string): Promise<'paid' | 'pending'> {
|
||||
});
|
||||
|
||||
if (result.mode === 'jsapi' && result.prepay) {
|
||||
await invokeWechatPay(result.prepay as WechatJsapiPrepayParams);
|
||||
await invokeWechatPay(result.prepay as WechatJsapiPrepayParams, {
|
||||
platform: isMiniWechatEnv() ? 'mini' : undefined,
|
||||
});
|
||||
const paid = await waitOrderPaid(orderId);
|
||||
return paid ? 'paid' : 'pending';
|
||||
}
|
||||
|
||||
@@ -100,6 +100,10 @@ export default function PayPage() {
|
||||
return;
|
||||
}
|
||||
const message = e instanceof Error ? e.message : '支付失败';
|
||||
if (message.includes('取消')) {
|
||||
setMsg('已取消支付');
|
||||
return;
|
||||
}
|
||||
setMsg(message);
|
||||
toast(message);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user