123
This commit is contained in:
parent
bbb191651e
commit
1ed311c5f9
@ -39,18 +39,40 @@ async function handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
setLoading(true)
|
||||
|
||||
const { error } = await stripe.confirmPayment({
|
||||
// 保存当前时间戳,用于检测是否需要手动跳转
|
||||
const paymentStartTime = Date.now()
|
||||
|
||||
// 检测是否为Android设备
|
||||
const isAndroid = /android/i.test(navigator.userAgent)
|
||||
|
||||
const { error, paymentIntent } = await stripe.confirmPayment({
|
||||
elements: elements.value,
|
||||
confirmParams: {
|
||||
return_url: `${baseURL}/payment/result?orderNo=${payUid.value}`,
|
||||
},
|
||||
redirect: 'if_required',
|
||||
})
|
||||
|
||||
if (error) {
|
||||
if (error.type === "card_error" || error.type === "validation_error") {
|
||||
showMessage(error.message)
|
||||
} else {
|
||||
showMessage("An unexpected error occurred.")
|
||||
}
|
||||
} else if (paymentIntent && paymentIntent.status === 'succeeded') {
|
||||
// 支付成功但没有自动跳转,手动跳转到结果页面
|
||||
window.location.href = `${baseURL}/payment/result?orderNo=${payUid.value}`
|
||||
return
|
||||
} else if (isAndroid) {
|
||||
// 针对Android设备,添加额外检查
|
||||
// 如果3秒后仍在当前页面,可能是没有自动跳转,尝试手动跳转
|
||||
setTimeout(() => {
|
||||
// 检查是否仍在支付页面
|
||||
if (document.getElementById('payment-form')) {
|
||||
window.location.href = `${baseURL}/payment/result?orderNo=${payUid.value}`
|
||||
}
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
setLoading(false)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user