#Colby S
1 messages · Page 1 of 1 (latest)
What do you mean by using card elements? You need to get the last 4 on the frontend?
yes
using the card element with react to collect payment, but want to show last 4 on FE
Where do you want to surface last 4? The card element shows the full card number. At what point in the flow do you need to display it?
Ok. So you're using this? https://stripe.com/docs/js/payment_intents/confirm_card_payment
Sorry misspoke, is setup. this is what I have been following https://stripe.com/docs/js/setup_intents/confirm_card_setup
Got it no worries. So you can't grab the last 4 from the card element on the frontend. You'll need to grab it via the api. So on confirmation, you'll get result.setupIntent in the return object (see the bottom part of the section you just linked). From the setupintent, you will have a payment method object on it: https://stripe.com/docs/api/setup_intents/object#setup_intent_object-payment_method. You'll need to make a call to your server where you can retrieve that payment method: https://stripe.com/docs/api/payment_methods/retrieve. Then, your server can return the last 4 on that payment method back to your client: https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-last4
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
oh I see where I might be going wrong, i am using create instead of retrieve. and in postman I was able to see last 4