From 26dadbf879971d1b3e547a9b0ee47ecb09e27bf6 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 6 Nov 2017 11:49:36 -0600 Subject: [PATCH] Add HUF as non-decimal currency (#974) - Fixes #973. --- lib/PayPal/Converter/FormatConverter.php | 4 ++-- tests/PayPal/Test/Common/FormatConverterTest.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/PayPal/Converter/FormatConverter.php b/lib/PayPal/Converter/FormatConverter.php index a237766..82c1be5 100644 --- a/lib/PayPal/Converter/FormatConverter.php +++ b/lib/PayPal/Converter/FormatConverter.php @@ -46,10 +46,10 @@ class FormatConverter 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]; diff --git a/tests/PayPal/Test/Common/FormatConverterTest.php b/tests/PayPal/Test/Common/FormatConverterTest.php index c6201af..b3c5f83 100644 --- a/tests/PayPal/Test/Common/FormatConverterTest.php +++ b/tests/PayPal/Test/Common/FormatConverterTest.php @@ -38,7 +38,8 @@ class FormatConverterTest extends \PHPUnit_Framework_TestCase { return array( array('JPY'), - array('TWD') + array('TWD'), + array('HUF') ); }