소스 검색

fix(payment): 修复支付环境配置获取逻辑

- 移除默认环境值 'release'
- 优化环境配置检查逻辑,避免空值错误
- 调整数组键名拼接格式,确保配置读取正确性
runphp 4 달 전
부모
커밋
1e91d765bc
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      src/Controller/PaymentController.php

+ 4 - 3
src/Controller/PaymentController.php

@@ -1,5 +1,6 @@
 <?php
 declare(strict_types=1);
+
 namespace SixShop\Payment\Controller;
 
 use SixShop\Core\Helper;
@@ -14,11 +15,11 @@ class PaymentController
 {
     public function index(PaymentManager $paymentManager, Config $config, Request $request): Response
     {
-        $env = $request->header('env', 'release');
-        $payments = array_column($paymentManager->getAllPayment(), null,'id');
+        $env = $request->header('env');
+        $payments = array_column($paymentManager->getAllPayment(), null, 'id');
         $result = [];
         foreach ($payments as $id => $payment) {
-            if (in_array($env, $config->getConfig('supported_env_'.$id))) {
+            if ($env == null || in_array($env, $config->getConfig('supported_env_' . $id, []))) {
                 $result[] = $payment;
             }
         }