Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onAttachPaymentMethod = async (cardNumber) => {
this.setState({ ...this.state, loading: true })
if (this.state.confirmationMethod === 'manual') {
// Create a payment method
console.log('Calling stripe.createPaymentMethod()')
let paymentMethod
try {
paymentMethod = await stripe.createPaymentMethod(
demoPaymentMethodDetailsWithCard(cardNumber)
)
} catch (e) {
console.dir(e)
// One way a payment method can fail to be created is if the card number is invalid
this.setState({ ...this.state, loading: false, display: e })
return
}
console.log('Payment Method', paymentMethod)
console.log('Payment Intent', this.state.paymentIntent)
// Send the payment method to the server and ask it to confirm.
console.log('Calling /confirm_payment on backend example server')
let confirmResult = null