Shopify/active_merchant — pull request #525 by Soleone (2012-12-07 17:56:24+00:00)
Title: WorldPay: Fix currencies without fractions like JPY and HUF

### Problem

When trying to send fractional amounts like `49.41` to WorldPay for currencies without fractions they return the following error: `Fractional number of minor currency units`. We were sending the amount in a cents value e.g. `4941`.

### Solution

Always round down the amount and send e.g. `4900` instead. This is how currencies without fractions are currently displayed in Shopify, the digits after the decimal are just stripped off (floor).

### Background

The following was sent to WorldPay Technical Support:

> Here are two examples of how we are sending amounts to their servers in the XML:
>
> Failing for 49.41 HUF (this amount was calculated from a percentage based discount):
>
> ```4941```
>
> Working for $100.00:
>
> ```10000```
>
> 1. Should we remove the “exponent” attribute for currencies that do not use any decimals like HUF?
> 2. Or should we be rounding e.g. 49.41 Ft to 50 Ft before sending it to WorldPay?

Their reply was:

> > 1) Should we remove the “exponent” attribute for currencies that do not use any decimals like HUF?
>
> RESPONSE: Add "00" to the value, Eg. HUF 1234
>
> ```123400```
>
> > 2) Or should we be rounding e.g. 49.41 Ft to 50 Ft before sending it to WorldPay?
>
> RESPONSE: As mention, currencies are always in whole number. Depending on your business processing, rounding should be decided by you.

Please review @jduff, cc @ntalbott