-
Notifications
You must be signed in to change notification settings - Fork 139
Description
I had contacted support with this question, but I'll re-enter it here to capture it.
I am using custom integration with hosted fields and I would like to disable the submit button while waiting to get the payment nonce. My current approach is to:
- Add a submit listener on the form which always disables the submit UI button upon seeing a submit event.
- In braintree onError callback, I re-enable submit button in case of any validation errors.
- In onPaymentMethodReceived callback, I then send the payment nonce to my server.
This basically works ok and prevents duplicate submits if and only if the user clicks on the “submit” button.
Unfortunately, if the user uses the "return" key to submit the form, then the native submit event isn’t fired. This makes it so I cannot give my user any visual feedback that something is going on, increasing the likelihood that they may try to resubmit if it takes a long time.
Perhaps I’m missing something, but I’ve searched the web a bit and it seems that a lot of people want to do this flow, but it is more difficult than it seems it should be. It seems like adding some sort of “beforeSubmit” callback after everything is validated, but just before submitting to braintree server would make this flow a lot more intuitive.
Thanks.