From 4250032318a12fddf20321f566102cc8b0aa61c5 Mon Sep 17 00:00:00 2001 From: Vincent Young Date: Thu, 26 Oct 2023 01:02:45 -0400 Subject: [PATCH] fix: Stripe payment not working --- app/Payments/StripeAlipay.php | 6 ++++-- app/Payments/StripeCheckout.php | 6 ++++-- app/Payments/StripeCredit.php | 6 ++++-- app/Payments/StripeWepay.php | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) 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]; } }