From 995b16d7e3b4f97beb3a5ceb02200d0dc9357473 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 21 Dec 2021 20:27:51 +1100 Subject: [PATCH] Stripe Zero Decimal CUrrencies --- app/PaymentDrivers/Stripe/Utilities.php | 4 +-- tests/Unit/ZeroDecimalTest.php | 41 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/ZeroDecimalTest.php diff --git a/app/PaymentDrivers/Stripe/Utilities.php b/app/PaymentDrivers/Stripe/Utilities.php index 586871d08a93..dd04e64aec21 100644 --- a/app/PaymentDrivers/Stripe/Utilities.php +++ b/app/PaymentDrivers/Stripe/Utilities.php @@ -18,7 +18,7 @@ trait Utilities public function convertFromStripeAmount($amount, $precision, $currency) { - if($currency->code == "JPY") + if(in_array($amount, ["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"])) return $amount; return $amount / pow(10, $precision); @@ -28,7 +28,7 @@ trait Utilities public function convertToStripeAmount($amount, $precision, $currency) { - if($currency->code == "JPY") + if(in_array($amount, ["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"])) return $amount; return round(($amount * pow(10, $precision)),0); diff --git a/tests/Unit/ZeroDecimalTest.php b/tests/Unit/ZeroDecimalTest.php new file mode 100644 index 000000000000..ca0ed4534010 --- /dev/null +++ b/tests/Unit/ZeroDecimalTest.php @@ -0,0 +1,41 @@ +assertTrue(in_array("KRW", $this->currencies)); + + } + +} +