braintree / braintree_java

Braintree Java library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
158 stars 98 forks source link

invalid transaction amount format issue #24

Closed rifnijeleel closed 9 years ago

rifnijeleel commented 9 years ago

Service gateway returns me a TRANSACTION_AMOUNT_FORMAT_IS_INVALID if I pass a float decimal number.

TransactionRequest request = new TransactionRequest() .amount(new BigDecimal(0.10f));

this returns TRANSACTION_AMOUNT_FORMAT_IS_INVALID where as

TransactionRequest request = new TransactionRequest() .amount(new BigDecimal("0.10"));

returns a Approved, SUBMITTED_FOR_SETTLEMENT value.

this is how request parameter looks if you pass a float number transaction[amount]=0.100000001490116119384765625

dewyze commented 9 years ago

@rifnijeleel Per the oracle java docs a float is not a valid parameter for constructing a big decimal.

You can use a variety of other options, but we recommend using a string to create the BigDecimal.

Let us know if this does not address your issue.

dewyze commented 9 years ago

Closing. @rifnijeleel feel free to reopen if you have further questions.