Braintree on validation error

I’m using Drop-in UI which is configured in Braintree control panel to automatically verificate if the payment method is legit.

So in my application I disable form submit button when it is clicked, and if user payment method is not legit, it says that there is error and doesn’t submits form. My question is how to catch this error so I can enable submit button back.

onError event is thrown only if there are not present all fields in input fields. So what about verification error, how do I catch it?

Right now my javascript looks like this:

braintree.setup("#{@braintree_token}", 'dropin', {
  container: 'dropin',
    onReady: function () {
    onError: function() {
$("form").submit(function (e) {
  setTimeout(function() { $('#submit-payment').removeClass('disabled'); }, 2000);

My solution is not ideal right now as it just disables button for 2 seconds. So please suggest me something.

P.S. To be clear I want to catch with Javascript this kind of error:
enter image description here

Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.