Reputation: 179
I have
const stripeResponse = await stripe.confirmCardSetup(client_secret, {
payment_method: {
card: elements.getElement('cardNumber'),
billing_details: {
address: {
city: selectedAddress.town,
country: selectedAddress.country.iso3166Code,
line1: selectedAddress.line1,
line2: selectedAddress.line2,
postal_code: selectedAddress.postalCode,
state: selectedAddress.region,
},
email: '[email protected]',
name,
phone: selectedAddress.phone,
},
},
});
With this I confirm card setup and I am using react-stripe-js inside react component:
import { CardNumberElement } from '@stripe/react-stripe-js';
//some component code below
...
<CardNumberElement options={options} />
...
It is not possible to get card number from CardNumberElement
component.
How can I get card number with stripe?
the closest thing I could find was as below, but I need client js preferably react version of it
Upvotes: 0
Views: 4148
Reputation: 472
onFormComplete={cardDetails => { console.log('card details', cardDetails); setCard(cardDetails); }}
here you will get like this in console.
card details {"brand": "Visa", "complete": true, "country": "IN", "expiryMonth": 12, "expiryYear": 2039, "last4": "4242", "postalCode": ""
If you want to get all card details then
dangerouslyGetFullCardDetails={true}
Upvotes: -1
Reputation: 3341
You cannot get the card number from Stripe. That is a big part of why you need to use Stripe's libraries, so that card details don't touch your integration.
Full raw card number is never exposed in API responses from Stripe: https://stripe.com/docs/security/guide
Upvotes: 3