Reputation: 230
i use stripe as payment. here in my code its generate clientSecret and request comes in my stripe account but it's incompltete and shown The customer has not entered their payment method. and when i click on pay now button error is come that
Unhandled Rejection (TypeError): Cannot read property 'uid' of undefined
and in console...
POST https://api.stripe.com/v1/payment_intents/pi_1HWKxuFi3enyg1Glqirj0Wto/confirm 400
undefine //that means paymentIntent is not definr
Uncaught (in promise) TypeError: Cannot read property 'uid' of undefined
at async handleSubmit
here is my code..
useEffect(() => {
const getClientSecret = async () => {
const response = await axios({
method: 'post',
url: `/payments/create?total=${getBasketTotal(basket) * 100}`
})
console.log('response is >>>>>>>>>>>', response)
setClientSecret(response.data.clientSecret)
}
getClientSecret()
}, [basket])
console.log('the secrate is >>>>>>>>', clientSecret)
const handleSubmit = async (event) => {
event.preventDefault()
setProcessing(true)
const payload = await stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: elements.getElement(CardElement)
}
}).then(({ paymentIntent }) => {
console.log(paymentIntent)
db
.collection('users')
.doc(user?.uid)
.collection('orders')
.doc(paymentIntent.uid)
.set({
basket: basket,
amount: paymentIntent.amount,
created: paymentIntent.created
})
//payment
setSucceeded(true)
setError(null)
setProcessing(false)
dispatch({
type: 'EMTY_BASKET'
})
history.replace('/orders')
})
}
whyt is error? and why i am getting it??
Upvotes: 0
Views: 181
Reputation: 230
my answer is solved...
Just make sure you are putting the same currency.
For example: if you have mentioned India as your country then put "inr" else "usd"
Upvotes: 1