#Pain-PaymentElement
1 messages · Page 1 of 1 (latest)
Hi there, you can listen to PaymentElement change event and examine the complete flag (https://stripe.com/docs/js/element/events/on_change?type=paymentElement#element_on_change-handler-complete) . This flag tells you whether the required fields in PaymentElement have been filled.
Is there no function I can call to, to just validate it?
You don't need to call a function to validate, StripeElement validates the input automatically.
Alright, I've just disabled the button until the complete parameter is returned. I was looking for a function but this works too.
Is there a way to get the last4 before submitting?
(like from the elements maybe?)
You can, but you need to use cardElement instead of paymentElement.
With cardElement, you can call stripe.createPaymentMethod() to get a PaymentMethod object, from there you can access the last4 property of a card PaymentElement 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.
I see, thanks for the info.