0

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

{
   "error":{
      "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."
   },
   "threeDSecureInfo":{
      "liabilityShifted":false,
      "liabilityShiftPossible":false
   }
}

This is the request data

{
   "_meta":{
      "integration":"custom",
      "integrationType":"custom",
      "merchantAppId":"xxxx.com",
      "platform":"web",
      "sdkVersion":"3.48.0",
      "sessionId":"3df9a6aa-46d1-494b-bff3-7a850a6ff13d",
      "source":"client"
   },
   "additionalInfo":{
      "billingCity":"xxxx",
      "billingCountryCode":"xx",
      "billingGivenName":"xxx",
      "billingLine1":"xxxxx Road",
      "billingPhoneNumber":"xxx-xxx-xxxx",
      "billingPostalCode":"xxxx",
      "billingState":"xx",
      "billingSurname":"xxxx",
      "shippingCity":"xxxx",
      "shippingCountryCode":"xx",
      "shippingGivenName":"xxxx",
      "shippingLine1":"xxx Road",
      "shippingPhone":"xxx-xxx",
      "shippingPostalCode":"xxxx",
      "shippingState":"xxx",
      "shippingSurname":"xxxx"
   },
   "**amount":12.0499**,
   "authorizationFingerprint":"eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6IjIwMTgwNDI2MTYtcHJvZHVjdGlvbiIsImlzcyI6Imh0dHBzOi8vYXBpLmJyYWludHJlZWdhdGV3YXkuY29tIn0.eyJleHAiOjE1OTYyMTA2NDQsImp0aSI6IjcxNTQxYzA0LTZkNDItNDlhZi1iODc2LTBmZjA1ZWEwNDRhMSIsInN1YiI6ImJqcXY3cGpqbXJrajc4cHIiLCJpc3MiOiJodHRwczovL2FwaS5icmFpbnRyZWVnYXRld2F5LmNvbSIsIm1lcmNoYW50Ijp7InB1YmxpY19pZCI6ImJqcXY3cGpqbXJrajc4cHIiLCJ2ZXJpZnlfY2FyZF9ieV9kZWZhdWx0IjpmYWxzZX0sInJpZ2h0cyI6WyJtYW5hZ2VfdmF1bHQiXSwic2NvcGUiOlsiQnJhaW50cmVlOlZhdWx0Il0sIm9wdGlvbnMiOnsibWVyY2hhbnRfYWNjb3VudF9pZCI6ImxlZHJvcGVsaWdodHNDQUQifX0.naHfA02qt5clJXYGGg7xxTfKKdaJOMFR0NZCfDbTxUR_f6vk1skBe8BH0afOYpwXsEf4Iz8YGDy1an7vLN33sg",
   "braintreeLibraryVersion":"braintree/web/3.48.0",
   "clientMetadata":{
      "cardinalDeviceDataCollectionTimeElapsed":3,
      "requestedThreeDSecureVersion":"2",
      "sdkVersion":"web/3.48.0"
   },
   "dfReferenceId":"0_3767710b-425b-4ba7-83a1-6d72a4619ff4"
}

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.

Request

Reponse

0

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.

0

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.