繁体   English   中英

在 react.js 中下订单时,条纹出现错误

[英]While placing order in react.js with stripe getting error

 const payload = await stripe.confirmCardPayment(clientSecret, {
        payment_method: {
            card: elements.getElement(CardElement)
        }
    }).then(({paymentIntent}) => {
        // paymentIntent = payment confirmation

        db
        .collection('users')
        .doc(user?.uid)
        .collection('orders')
        .doc(paymentIntent.id)
        .set({
            basket: basket,
            amount: paymentIntent.amount,
            created: paymentIntent.created
        })

        setSucceeded(true)
        setError(null)
        setProcessing(false)

        dispatch({
            type: 'EMPTY_BASKET'
        })

        history.replace('/orders')
    })
}

下面是错误 iam getting Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id') at payment.js:58:1 at async handleSubmit (payment.js:51:1)

你能打印出你的paymentIntent变量来看看你是否真的成功地找回了 PaymentIntent 吗? 当您尝试从中获取id时,这可能会导致paymentIntent变量undefined

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM