fix(payment): restore public resume and result flows
This commit is contained in:
@@ -276,7 +276,7 @@ import PaymentStatusPanel from '@/components/payment/PaymentStatusPanel.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import type { PaymentMethodOption } from '@/components/payment/PaymentMethodSelector.vue'
|
||||
import { buildPaymentErrorToastMessage, describePaymentScenarioError } from './paymentUx'
|
||||
import { parseWechatResumeRoute, stripWechatResumeQuery } from './paymentWechatResume'
|
||||
import { hasWechatResumeQuery, parseWechatResumeRoute, stripWechatResumeQuery } from './paymentWechatResume'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
@@ -329,6 +329,7 @@ function emptyPaymentState(): PaymentRecoverySnapshot {
|
||||
expiresAt: '',
|
||||
paymentType: '',
|
||||
payUrl: '',
|
||||
outTradeNo: '',
|
||||
clientSecret: '',
|
||||
payAmount: 0,
|
||||
orderType: '',
|
||||
@@ -396,6 +397,9 @@ async function redirectToPaymentResult(state: PaymentRecoverySnapshot): Promise<
|
||||
if (state.orderId > 0) {
|
||||
query.order_id = String(state.orderId)
|
||||
}
|
||||
if (state.outTradeNo) {
|
||||
query.out_trade_no = state.outTradeNo
|
||||
}
|
||||
if (state.resumeToken) {
|
||||
query.resume_token = state.resumeToken
|
||||
}
|
||||
@@ -809,9 +813,14 @@ onMounted(async () => {
|
||||
selectedMethod.value = sorted[0]
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
if (hasWechatResumeQuery(route.query)) {
|
||||
removeRecoverySnapshot()
|
||||
}
|
||||
const routeResumeToken = typeof route.query.resume_token === 'string'
|
||||
? route.query.resume_token
|
||||
: undefined
|
||||
: typeof route.query.wechat_resume_token === 'string'
|
||||
? route.query.wechat_resume_token
|
||||
: undefined
|
||||
const restored = readPaymentRecoverySnapshot(
|
||||
window.localStorage.getItem(PAYMENT_RECOVERY_STORAGE_KEY),
|
||||
{ resumeToken: routeResumeToken },
|
||||
|
||||
Reference in New Issue
Block a user