diff --git a/app/Payments/StripeAlipay.php b/app/Payments/StripeAlipay.php index 43669136..cfa2c17a 100644 --- a/app/Payments/StripeAlipay.php +++ b/app/Payments/StripeAlipay.php @@ -110,8 +110,10 @@ class StripeAlipay { private function exchange($from, $to) { - $result = file_get_contents('https://api.exchangerate.host/latest?symbols=' . $to . '&base=' . $from); + $from = strtolower($from); + $to = strtolower($to); + $result = file_get_contents("https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/" . $from . "/" . $to . ".json"); $result = json_decode($result, true); - return $result['rates'][$to]; + return $result[$to]; } } diff --git a/app/Payments/StripeCheckout.php b/app/Payments/StripeCheckout.php index 673f0ccd..bb5e3b7f 100644 --- a/app/Payments/StripeCheckout.php +++ b/app/Payments/StripeCheckout.php @@ -132,8 +132,10 @@ class StripeCheckout { private function exchange($from, $to) { - $result = file_get_contents('https://api.exchangerate.host/latest?symbols=' . $to . '&base=' . $from); + $from = strtolower($from); + $to = strtolower($to); + $result = file_get_contents("https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/" . $from . "/" . $to . ".json"); $result = json_decode($result, true); - return $result['rates'][$to]; + return $result[$to]; } } diff --git a/app/Payments/StripeCredit.php b/app/Payments/StripeCredit.php index a066e835..a358d726 100644 --- a/app/Payments/StripeCredit.php +++ b/app/Payments/StripeCredit.php @@ -117,8 +117,10 @@ class StripeCredit { private function exchange($from, $to) { - $result = file_get_contents('https://api.exchangerate.host/latest?symbols=' . $to . '&base=' . $from); + $from = strtolower($from); + $to = strtolower($to); + $result = file_get_contents("https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/" . $from . "/" . $to . ".json"); $result = json_decode($result, true); - return $result['rates'][$to]; + return $result[$to]; } } diff --git a/app/Payments/StripeWepay.php b/app/Payments/StripeWepay.php index 8b0fc1b0..4be2c4e8 100644 --- a/app/Payments/StripeWepay.php +++ b/app/Payments/StripeWepay.php @@ -110,8 +110,10 @@ class StripeWepay { private function exchange($from, $to) { - $result = file_get_contents('https://api.exchangerate.host/latest?symbols=' . $to . '&base=' . $from); + $from = strtolower($from); + $to = strtolower($to); + $result = file_get_contents("https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/" . $from . "/" . $to . ".json"); $result = json_decode($result, true); - return $result['rates'][$to]; + return $result[$to]; } }