cancel
Showing results for 
Search instead for 
Did you mean: 

Braintree CE 2.1.0 doesn't accept payments in KRW - error msg 'Amount is an invalid format.'

0 Kudos

Braintree CE 2.1.0 doesn't accept payments in KRW - error msg 'Amount is an invalid format.'

Feature request from flecxie, posted on GitHub Aug 03, 2016

I can't process KRW payments with Braintree on CE 2.1.0, getting the following error message in debug.log: Amount is an invalid format.

Steps to reproduce

  1. Create Braintree Sandbox account + additional Korean Wong Merchant Account ID
  2. Apply patch from https://github.com/magento/magento2/issues/5910 to get alternative Merchant Account ID's working
  3. Configure Magento CE 2.1.0 store for alternative merchant ID, enable Braintree debugging & place test order for a large amount (I tried with ₩826,961.35 which is equivalent to ~700 USD)

Expected result

  1. Success

Actual result

  1. Fails with error below in debug.log:
  'response' => 
  array (
    'success' => false,
    '' . "\0" . '*' . "\0" . '_attributes' =>
    array ( 
      'errors' =>
      Braintree\Error\ErrorCollection::__set_state(array(
         '_errors' =>
        Braintree\Error\ValidationErrorCollection::__set_state(array(
           '_errors' => 
          array (
          ),
           '_nested' => 
          array (
            'transaction' =>
            Braintree\Error\ValidationErrorCollection::__set_state(array(
               '_errors' => 
              array (
                0 => 
                Braintree\Error\Validation::__set_state(array(
                   '_attribute' => 'amount',
                   '_code' => '81503',
                   '_message' => 'Amount is an invalid format.',
                )), 
              ),
8 Comments
apiuser
New Member
Status changed to: Investigating
 
apiuser
New Member

Comment from joni-jones, posted on GitHub Aug 03, 2016

Hi, @flecxie. Please, attach request log.

apiuser
New Member

Comment from flecxie, posted on GitHub Aug 04, 2016

Request array below:

[2016-08-03 10:02:57] main.DEBUG: array (
  'request' =>
  array (
    'customer' =>
    array (
      'firstName' => 'XXXXXXXXXXXXX',
      'lastName' => 'XXXXXXXXXXXXX',
      'company' => NULL,
      'phone' => '132465',
      'email' => 'XXXXXXXXXXXXX@XXXXXXXXXXXXX.com',
    ),
    'amount' => '826961.35',
    'paymentMethodNonce' => 'XXXXXXXXXXXXX',
    'orderId' => '7000000901',
    'merchantAccountId' => 'XXXXXXXXXXXXX',
    'channel' => 'Magento2_Cart_Community_BT',
    'billing' =>
    array (
      'firstName' => 'XXXXXXXXXXXXX',
      'lastName' => 'XXXXXXXXXXXXX',
      'company' => NULL,
      'streetAddress' => 'XXXXXXXXXXXXX',
      'extendedAddress' => '',
      'locality' => 'Seoul',
      'region' => NULL,
      'postalCode' => '123-465',
      'countryCodeAlpha2' => 'KR',
    ),
    'shipping' =>
    array (
      'firstName' => 'XXXXXXXXXXXXX',
      'lastName' => 'XXXXXXXXXXXXX',
      'company' => NULL,
      'streetAddress' => 'XXXXXXXXXXXXX',
      'extendedAddress' => '',
      'locality' => 'Seoul',
      'region' => NULL,
      'postalCode' => '123-465',
      'countryCodeAlpha2' => 'KR',
    ),
    'options' =>
    array (
      'storeInVaultOnSuccess' => true,
      'three_d_secure' =>
      array (
        'required' => true,
      ),
    ),
  ),
  'client' => 'Magento\\Braintree\\Gateway\\Http\\Client\\TransactionSale',
  'response' =>
  array (
    'success' => false,
    '' . "\0" . '*' . "\0" . '_attributes' =>
    array (
      'errors' =>
      Braintree\Error\ErrorCollection::__set_state(array(
         '_errors' =>
        Braintree\Error\ValidationErrorCollection::__set_state(array(
           '_errors' =>
          array (
          ),
           '_nested' =>
          array (
            'transaction' =>
            Braintree\Error\ValidationErrorCollection::__set_state(array(
               '_errors' =>
              array (
                0 =>
                Braintree\Error\Validation::__set_state(array(
                   '_attribute' => 'amount',
                   '_code' => '81503',
                   '_message' => 'Amount is an invalid format.',
                )),
              ),
...
apiuser
New Member

Comment from joni-jones, posted on GitHub Aug 04, 2016

If you open a list of currencies supported by Braintree, you will see that KRW is zero-decimal currency, but in your request amount is a fractional part.

apiuser
New Member

Comment from flecxie, posted on GitHub Aug 04, 2016

Thanks for that info @joni-jones! Is there a way to tell Magento that this is a zero-decimal currency / avoid that it uses decimals?

apiuser
New Member

Comment from joni-jones, posted on GitHub Aug 05, 2016

Magento doesn't process any currency details because each payment processor can contain own specific for different currencies. We need to decide what we should do in that case, we can't just change authorization amount for Braintree related to some currency because order amounts won't be match.

I've created internal ticket MAGETWO-56451 to investigate this issue.

apiuser
New Member

Comment from flecxie, posted on GitHub Aug 12, 2016

@joni-jones: Can you think of a workaround for now? Is it possible to change the decimal precision of a currency store-wide?

apiuser
New Member

Comment from asemenenko, posted on GitHub Aug 17, 2016

@flecxie @joni-jones This is a framework level feature. Magento needs to support a non-decimal currencies outside a payments area, this includes Catalog module, Sales module, reporting etc. Payment gateway is a consumer of the output provided by the sales module/checkout/quote. We can not just multiple calculated numbers by 100 in particular payment module, we do also need to be consistent about displaying it across the system. Ticket is converted to a user story. As a temporary solution you can write a custom format function.