I am having a problem getting 3DSecure to work on my site. I get the following error. The JSON request I am getting back a 422 error from api.braintree.com

      "message":"Amount can be any number of digits optionally followed by a decimal point `.` and up to two decimal places following the decimal point. Commas `,` are not allowed."

This is the request data

      "billingLine1":"xxxxx Road",
      "shippingLine1":"xxx Road",

The problem is that Magento is passing amount":12.0499 which has 4 decimal places. The Braintree API is expecting only 2. My system is displaying the correct number of decimal places as 2 on the frontend. I am not sure how to force Magento to send only 2 decimal places?

Thank you for your help.




Wondering whether you ever solved this. I was experiencing the same issue but only when using percentage-based promo codes. We are running Magento 2.4.0 and for braintree:

"name": "braintree/braintree_php", "version": "4.5.0", "name": "paypal/module-braintree", "version": "4.1.0",

Having spoken with Gene who build the Braintree module for M2 they have now supplied a patch for the fix. I am sure they will be rolling this into their next release.


Yes, it is a bit of a hack job, but it is the only way I could figure out how to fix it.

Edit \vendor\magento\module-quote\Model\Quote\Address\Total.php

Change line 59 & 79 to

$amount = is_float($amount) ? round($amount, 2) : $amount;

This will force the precision of the amount calculated to be 2 instead of 4 which will allow 3DS to work correctly.

To note every time you upgrade Magento you need to apply this patch until something official gets released.

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.