fix: restore wechat payment oauth and jsapi flow
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import type { CreateOrderRequest, CreateOrderResult, MethodLimit, OrderType } from '@/types/payment'
|
||||
import type {
|
||||
CreateOrderRequest,
|
||||
CreateOrderResult,
|
||||
MethodLimit,
|
||||
OrderType,
|
||||
WechatJSAPIPayload,
|
||||
WechatOAuthInfo,
|
||||
} from '@/types/payment'
|
||||
|
||||
export const PAYMENT_RECOVERY_STORAGE_KEY = 'payment.recovery.current'
|
||||
|
||||
@@ -16,6 +23,8 @@ export type PaymentLaunchKind =
|
||||
| 'redirect_waiting'
|
||||
| 'stripe_popup'
|
||||
| 'stripe_route'
|
||||
| 'wechat_oauth'
|
||||
| 'wechat_jsapi'
|
||||
| 'unhandled'
|
||||
|
||||
export interface PaymentRecoverySnapshot {
|
||||
@@ -47,6 +56,8 @@ export interface PaymentLaunchDecision {
|
||||
paymentState: PaymentRecoverySnapshot
|
||||
recovery: PaymentRecoverySnapshot
|
||||
stripeMethod?: StripeVisibleMethod
|
||||
oauth?: WechatOAuthInfo
|
||||
jsapi?: WechatJSAPIPayload
|
||||
}
|
||||
|
||||
export interface BuildCreateOrderPayloadInput {
|
||||
@@ -139,6 +150,15 @@ export function decidePaymentLaunch(
|
||||
return { kind, paymentState, recovery: paymentState, stripeMethod }
|
||||
}
|
||||
|
||||
if (result.result_type === 'oauth_required' && result.oauth?.authorize_url) {
|
||||
return { kind: 'wechat_oauth', paymentState: baseState, recovery: baseState, oauth: result.oauth }
|
||||
}
|
||||
|
||||
const jsapiPayload = result.jsapi ?? result.jsapi_payload
|
||||
if (result.result_type === 'jsapi_ready' && jsapiPayload) {
|
||||
return { kind: 'wechat_jsapi', paymentState: baseState, recovery: baseState, jsapi: jsapiPayload }
|
||||
}
|
||||
|
||||
if (baseState.qrCode) {
|
||||
return { kind: 'qr_waiting', paymentState: baseState, recovery: baseState }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user