Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get stripe card number, cvc and expiry date from the react stripe PaymentElement

I have a question for you. How can I access the card details, like the last number of cards, expiry date, and CVC from the PaymentElement? I am using the @stripe/react-stripe-js package here. Here are the checkout form code:

 <form ref={connectRef} id="payment-form" onSubmit={handleSubmit}>
  <PaymentElement
    id="payment-element"
    options={{
      layout: 'accordion',
    }}   
  />  
</form>

Can we get the card details from here?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Payment method information collected using PaymentElement gets tokenized by Stripe for security and safety reasons.

When the information gets tokenized, it creates a PaymentMethod object. You can retrieve the PaymentMethod object using the API and look at the card parameter to get last 4 and expiry.

I don’t believe Stripe API returns cvc as that could have security implications.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading