Просмотр исходного кода

clearpay当国家是GB和货币是GBP才显示

llp 4 дней назад
Родитель
Сommit
c5d024db4b
1 измененных файлов с 7 добавлено и 9 удалено
  1. 7 9
      packages/Longyi/Pay/Afterpay/src/Payment/Clearpay.php

+ 7 - 9
packages/Longyi/Pay/Afterpay/src/Payment/Clearpay.php

@@ -133,15 +133,13 @@ class Clearpay extends Afterpay
             return false;
         }
         $info = $this->getOrder() ?: Cart::getCart();
-        if ($info && $billingCountry = $info->billing_address->country ?? false) {
-//            $allowedCountries = $this->getConfigData('allowed_countries');
-//            if (empty($allowedCountries)) {
-//                return true;
-//            }
-//            $allowedCountries = explode(',', $allowedCountries);
-//            return in_array($billingCountry, $allowedCountries);
-            $allowedCountries = ['GB'];//英国
-            return in_array($billingCountry, $allowedCountries);
+        if ($info) {
+            $billingCountry = $info->billing_address->country ?? false;
+            $currency = $info->order_currency_code ?? $info->cart_currency_code ?? false;
+            // 仅当国家为 GB 且货币为 GBP 时才显示 Clearpay
+            if ($billingCountry === 'GB' && $currency === 'GBP') {
+                return true;
+            }
         }
         return false;
     }