mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Merge pull request #202 from woocommerce/PCP-176-currency-japananese-yen-jpy-is-n
Do not send decimals when currency does not support them
This commit is contained in:
commit
5a84bd1430
3 changed files with 21 additions and 2 deletions
|
@ -28,6 +28,13 @@ class Amount {
|
||||||
*/
|
*/
|
||||||
private $breakdown;
|
private $breakdown;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currencies that does not support decimals.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $currencies_without_decimals = array( 'HUF', 'JPY', 'TWD' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount constructor.
|
* Amount constructor.
|
||||||
*
|
*
|
||||||
|
@ -74,7 +81,9 @@ class Amount {
|
||||||
public function to_array(): array {
|
public function to_array(): array {
|
||||||
$amount = array(
|
$amount = array(
|
||||||
'currency_code' => $this->currency_code(),
|
'currency_code' => $this->currency_code(),
|
||||||
'value' => number_format( $this->value(), 2, '.', '' ),
|
'value' => in_array( $this->currency_code(), $this->currencies_without_decimals, true )
|
||||||
|
? round( $this->value(), 0 )
|
||||||
|
: number_format( $this->value(), 2, '.', '' ),
|
||||||
);
|
);
|
||||||
if ( $this->breakdown() && count( $this->breakdown()->to_array() ) ) {
|
if ( $this->breakdown() && count( $this->breakdown()->to_array() ) ) {
|
||||||
$amount['breakdown'] = $this->breakdown()->to_array();
|
$amount['breakdown'] = $this->breakdown()->to_array();
|
||||||
|
|
|
@ -28,6 +28,13 @@ class Money {
|
||||||
*/
|
*/
|
||||||
private $value;
|
private $value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currencies that does not support decimals.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $currencies_without_decimals = array( 'HUF', 'JPY', 'TWD' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Money constructor.
|
* Money constructor.
|
||||||
*
|
*
|
||||||
|
@ -65,7 +72,9 @@ class Money {
|
||||||
public function to_array(): array {
|
public function to_array(): array {
|
||||||
return array(
|
return array(
|
||||||
'currency_code' => $this->currency_code(),
|
'currency_code' => $this->currency_code(),
|
||||||
'value' => number_format( $this->value(), 2, '.', '' ),
|
'value' => in_array( $this->currency_code(), $this->currencies_without_decimals, true )
|
||||||
|
? round( $this->value(), 0 )
|
||||||
|
: number_format( $this->value(), 2, '.', '' ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,3 +551,4 @@ class SettingsRenderer {
|
||||||
|| $this->is_paypal_checkout_screen() && $this->settings_status->pay_later_messaging_is_enabled();
|
|| $this->is_paypal_checkout_screen() && $this->settings_status->pay_later_messaging_is_enabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue