#aseychell - elements
1 messages ยท Page 1 of 1 (latest)
hello, what do you mean by validating the expiry in this case? Do you want to check the expiry to ensure it is later than the reservation date?
yes exactly
One the payment method is created (ie, after the setup intent is successful) you can inspect the exp_year and exp_month on the payment method object: https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-exp_month
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
can this be done on the client side before completing the setup intent?
Are you using the card element or the payment element?
we're using the card element through ngx-stripe. In the docs, i found this reference but not sure how it can be done
Using the card element you can create the payment method client side first to inspect:
https://stripe.com/docs/js/payment_methods/create_payment_method
You could do this, eg, when the change event fires and indicates the elements are complete:
https://stripe.com/docs/js/element/events/on_change?type=cardElement#element_on_change-handler-complete
Thanks for your suggestion. I just tried the on change listener but the expiry date is not available, only the postal code.
No, it's not in the change event. You listen for the change event, and when complete=true you would use createPaymentMethod to get a payment method object you can inspect.