mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-27 15:29:23 +00:00
Fix mobile payment launch detection
This commit is contained in:
1 parent
da1d26001f
commit
906802abe3
5 files changed
+163
-11
No files matched your search
@@ -46,6 +46,7 @@ export interface PaymentLaunchContext {
|
||||
visibleMethod: string
|
||||
orderType: OrderType
|
||||
isMobile: boolean
|
||||
isWechatBrowser?: boolean
|
||||
now?: number
|
||||
stripePopupUrl?: string
|
||||
stripeRouteUrl?: string
|
||||
@@ -159,7 +160,23 @@ export function decidePaymentLaunch(
|
||||
return { kind: 'wechat_jsapi', paymentState: baseState, recovery: baseState, jsapi: jsapiPayload }
|
||||
}
|
||||
|
||||
if (baseState.qrCode) {
|
||||
const normalizedPaymentMode = baseState.paymentMode.trim().toLowerCase()
|
||||
const prefersRedirect = normalizedPaymentMode === 'redirect'
|
||||
|| normalizedPaymentMode === 'popup'
|
||||
|| (context.isMobile && !!baseState.payUrl)
|
||||
const prefersQr = normalizedPaymentMode === 'qrcode'
|
||||
|| normalizedPaymentMode === 'native'
|
||||
|| (!prefersRedirect && !!baseState.qrCode)
|
||||
|
||||
if (visibleMethod === 'wxpay' && context.isWechatBrowser && baseState.payUrl && !baseState.qrCode) {
|
||||
return { kind: 'redirect_waiting', paymentState: baseState, recovery: baseState }
|
||||
}
|
||||
|
||||
if (prefersRedirect && baseState.payUrl) {
|
||||
return { kind: 'redirect_waiting', paymentState: baseState, recovery: baseState }
|
||||
}
|
||||
|
||||
if (prefersQr && baseState.qrCode) {
|
||||
return { kind: 'qr_waiting', paymentState: baseState, recovery: baseState }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user