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

Add HUF as non-decimal currency #974

Merged
merged 1 commit into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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