Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// The initial confirm did not require_action - a new payment method is required instead.
response = confirmResult
}
this.setState({ ...this.state, loading: false, display: response })
}
} else if (this.state.confirmationMethod === 'automatic') {
// Here we're in automatic confirmation mode.
// In this mode, we can confirm the payment from the client side and
// fulfill the order on the client side by listening to webhooks.
// For cards, we also get immediate confirmation of the outcome of the payment.
let display = null
try {
console.log('Confirming')
const confirmPaymentResult = await stripe.confirmPaymentIntent({
clientSecret: this.state.paymentIntent.secret,
paymentMethod: demoPaymentMethodDetailsWithCard(cardNumber),
})
display = confirmPaymentResult
} catch (e) {
// One way we can arrive here is if the payment intent had previously succeeded.
console.dir(e)
display = {
message: e.message,
code: e.code,
}
}
this.setState({ ...this.state, loading: false, display })
}
}