Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Add HUF as non-decimal currency (#974)
Browse files Browse the repository at this point in the history
- Fixes #973.
  • Loading branch information
jaypatel512 authored Nov 6, 2017
1 parent 0303e2c commit 26dadbf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/PayPal/Converter/FormatConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public static function formatToNumber($value, $decimals = 2)
public static function formatToPrice($value, $currency = null)
{
$decimals = 2;
$currencyDecimals = array('JPY' => 0, 'TWD' => 0);
$currencyDecimals = array('JPY' => 0, 'TWD' => 0, 'HUF' => 0);
if ($currency && array_key_exists($currency, $currencyDecimals)) {
if (strpos($value, ".") !== false && (floor($value) != $value)) {
//throw exception if it has decimal values for JPY and TWD which does not ends with .00
//throw exception if it has decimal values for JPY, TWD and HUF which does not ends with .00
throw new \InvalidArgumentException("value cannot have decimals for $currency currency");
}
$decimals = $currencyDecimals[$currency];
Expand Down
3 changes: 2 additions & 1 deletion tests/PayPal/Test/Common/FormatConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public static function CurrencyListWithNoDecimalsProvider()
{
return array(
array('JPY'),
array('TWD')
array('TWD'),
array('HUF')
);
}

Expand Down

0 comments on commit 26dadbf

Please sign in to comment.