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() {
console.log("error");
$('#submit-payment').removeClass('disabled');
}
});
$("form").submit(function (e) {
$('#submit-payment').addClass('disabled');
setTimeout(function() { $('#submit-payment').removeClass('disabled'); }, 2000);
return;
});
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:
P.S.S. Also I have found out that it callbacks this info:
/**/callback_jsond435f0d591e44176bf94ec137859dd3c({"error":{"message":"Credit card verification failed"},"fieldErrors":[{"field":"creditCard","fieldErrors":[{"field":"cvv","code":"81736","message":"CVV verification failed"}]}],"status":422})
I’m a developer at Braintree. Currently the Drop-in
onError
callback will not catch those type of server side validation errors.If you are still struggling I would recommend reaching out to our support team at [email protected]. They will be able to assist you with the more specifics of your integration.