I am trying to follow the example shown in the following link https://stripe.com/docs/payments/accept-a-payment.
I have the following code in the client side
var cardNumber = elements.create('cardNumber', {
placeholder:'',
style: style
});
var cardexpiry = elements.create('cardExpiry',{
placeholder:'',
style:style
});
var cardCVV = elements.create('cardCvc',{
placeholder:'',
style:style
});
// Add an instance of the card Element into the `card-element` <div>.
cardNumber.mount('#card-element');
cardexpiry.mount("#card-expiry")
cardCVV.mount("#card-cvv")
instead of this
var card = elements.create("card", { style: style });
card.mount("#card-element");
Because the I wanted to some UI manipulation. According to the code posted in the link I should do the following
var submitButton = document.getElementById('submit');
submitButton.addEventListener('click', function(ev) {
stripe.confirmCardPayment(clientSecret, {
payment_method: {card: card}
}).then(function(result) {
if (result.error) {
// Show error to your customer (e.g., insufficient funds)
console.log(result.error.message);
} else {
// The payment has been processed!
if (result.paymentIntent.status === 'succeeded') {
// Show a success message to your customer
// There's a risk of the customer closing the window before callback
// execution. Set up a webhook or plugin to listen for the
// payment_intent.succeeded event that handles any business critical
// post-payment actions.
}
}
});
});
However in the example above in the payment_method the card object is passed, which is not the case in my code. How can I pass my card number and exp/date as well CVC separately in the stripe.confirmCardPayment(clientSecret, { payment_method: {card: card}