fix(review): harden payment, oauth, and migration paths
This commit is contained in:
@@ -391,6 +391,20 @@ function resetPayment() {
|
||||
removeRecoverySnapshot()
|
||||
}
|
||||
|
||||
async function redirectToPaymentResult(state: PaymentRecoverySnapshot): Promise<void> {
|
||||
const query: Record<string, string | undefined> = {}
|
||||
if (state.orderId > 0) {
|
||||
query.order_id = String(state.orderId)
|
||||
}
|
||||
if (state.resumeToken) {
|
||||
query.resume_token = state.resumeToken
|
||||
}
|
||||
await router.push({
|
||||
path: '/payment/result',
|
||||
query,
|
||||
})
|
||||
}
|
||||
|
||||
function onPaymentDone() {
|
||||
const wasSubscription = paymentState.value.orderType === 'subscription'
|
||||
resetPayment()
|
||||
@@ -684,8 +698,14 @@ async function createOrder(orderAmount: number, orderType: OrderType, planId?: n
|
||||
const errMsg = String(jsapiResult.err_msg || '').toLowerCase()
|
||||
if (errMsg.includes('cancel')) {
|
||||
appStore.showInfo(t('payment.qr.cancelled'))
|
||||
resetPayment()
|
||||
} else if (errMsg && !errMsg.includes('ok')) {
|
||||
applyScenarioError({ reason: 'WECHAT_JSAPI_FAILED', message: errMsg }, visibleMethod)
|
||||
resetPayment()
|
||||
} else {
|
||||
const resultState = { ...decision.paymentState }
|
||||
resetPayment()
|
||||
await redirectToPaymentResult(resultState)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user