Closed hoordev closed 3 years ago
Hi @hoordev thanks for using the Braintree Android SDK. The error you are seeing is expected behavior of the SDK when an invalid amount is included in the ThreeDSecureRequest
. The amount must be expressed in numbers with an optional decimal (using .
) and precision up to the hundredths place. For example, if you're processing a transaction for 1.234,56
€ then amount
should be 1234.56
.
I know that, but I don't understand what is the correct solution for this, because sometimes I got error and can't reproduced. If has a double value, then the currency is independent. Please write the valid solution for this. You specifically what method do you recommend? This requires one line of code I think.
There are several different ways, but this can depend on the locale of the user. Closing this, because it does not appear to be an issue with the SDK. If you need additional help troubleshooting your specific integration, please contact support.
General information
Braintree dependencies:
Issue description
My application uses Braintree payments for about 6 months. It cannot be reproduced on your own devices, but we see it in the firebase logs. This problem exists in 3 months. When the application put the amount value into the sdk, the device got an error. This problem not reproduce always. We tried some solutions for this and tried to change sdk version, but rarely get the same error.
Last code that managed by application
ThreeDSecureRequest().apply { ..... amount(amount) ..... }
The priceSum type is double. A few tries from us:
priceSum.toString().replace(" ", "").replace(",", ".")
DecimalFormat("0.00").format(priceSum)
DecimalFormat("0.00", DecimalFormatSymbols.getInstance().apply { decimalSeparator = '.'} )
Crash log
Non-fatal Exception: com.braintreepayments.api.exceptions.ErrorWithResponse: 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. at com.braintreepayments.api.internal.BraintreeHttpClient.parseResponse(BraintreeHttpClient.java:144) at com.braintreepayments.api.internal.HttpClient.post(HttpClient.java:219) at com.braintreepayments.api.internal.BraintreeHttpClient.post(BraintreeHttpClient.java:121) at com.braintreepayments.api.internal.HttpClient$2.run(HttpClient.java:186) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)
Any suggestion?