Skip to content
Advertisement

How should I pass `cardNumberElement`, `cardExpiryElement` and `cardCvcElement` into `stripe.confirmCardPayment`’s `payment_method.card`?

In stripe docs, I can easily create a card like this

JavaScript

And I simpliy pass the cardElement to confirmCardPayment

JavaScript

However, for visual style css reason, I have to split cardElement in to three pieces like this:

JavaScript

Then I want to call stripe.confirmCardPayment, what should I do right now?

The doc only shows cardElement method, no splitted example.

Advertisement

Answer

You can pass the CardNumber Element in. As long as they were all created from the same instance of the Elements object, the confirmCardPayment function will pull the relevant information from all of the mounted Elements to get the expiry/CVC too and it will just work.

JavaScript

https://stripe.com/docs/js/setup_intents/confirm_card_setup#stripe_confirm_card_setup-with_element-payment_method-card

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement