#mirajacc-payment-element-react
1 messages · Page 1 of 1 (latest)
By empty field do you mean when customer push the submit button, there is some fields left unfilled?
Yes. I have a few API calls added before confirmPayment() so I need to check if the user has completed the form to make those API calls.
Maybe this change event would help? https://stripe.com/docs/js/element/events/on_change?type=paymentElement
I had a look at it before. Tried, but couldn't make it work in the React application, so reached out here.
I am not super familiar but why is it not working in a Reaction application?
Because the implementation is different in react application compared to regular JS app. https://stripe.com/docs/stripe-js/react
ah I see, because you don't have access to paymentElement
Correct. And I'm trying to see if I can use useElements(). Compared console logs for both success and error cases, no distinct field to check if any field is empty.
stepping in on behalf of orakaro. Can you give an example of a field which you're validating that it's not empty?
Thanks Alex. The fields are credit card number, expiry and cvc.
the payment element is already performing those validations though, why do you want to validate it too?
I have a few APIs that I need to call before the payment is made. These should be called after the pay button is clicked and before the confirmPayment() is called. This is where I need the check and handle API calls accordingly.
This is basically for inventory lock and order placement. We don't want the payment to be made before the inventory check or order placement.
If you want to perform inventory lock and order placement, then I think for your use case, perhaps a better way to go about it is to use Authorize and Capture instead - https://stripe.com/docs/payments/place-a-hold-on-a-payment-method
or alternatively save the card and then charge it later after performing inventory lock and order placement : https://stripe.com/docs/payments/save-and-reuse