Kaynağa Gözat

refactor(lakala):重构配置类以支持V3接口

- 修改 Config 类继承关系,移除 Configuration 继承- 新增 getV3Config 方法返回 V3 版本配置对象
- 调整 TransactionService 构造函数使用 V3 配置
- 移除旧版配置方法如 getAppId、getSerialNo 等
- 更新证书路径和调试模式配置逻辑
runphp 4 ay önce
ebeveyn
işleme
795c4517c3
2 değiştirilmiş dosya ile 17 ekleme ve 28 silme
  1. 16 27
      src/Config.php
  2. 1 1
      src/Service/TransactionService.php

+ 16 - 27
src/Config.php

@@ -12,7 +12,7 @@ use SixShop\System\Trait\ConfigTrait;
  * @property string $notify_url 商户通知地址
  * @property string $complete_notify_url 收货确认通知地址
  */
-class Config extends Configuration
+class Config
 {
     use ConfigTrait;
 
@@ -31,33 +31,22 @@ class Config extends Configuration
         ];
     }
 
-    #[\Override] public function getAppId()
+    /**
+     * 获取V3配置
+     * @return Configuration
+     */
+    public function getV3Config():Configuration
     {
-        return $this->getConfig('appid');
-    }
-
-    #[\Override] public function getSerialNo()
-    {
-        return $this->getConfig('serial_no');
-    }
-
-    #[\Override] public function getSm4Key()
-    {
-        return null;
-    }
+        return new Configuration([
+            'app_id' => $this->getConfig('appid'),
+            'serial_no' => $this->getConfig('serial_no'),
+            'sm4_key' => null,
+            'merchant_private_key_path' => public_path().$this->getConfig('sign_cert')[0],
+            'lkl_certificate_path' => public_path().$this->getConfig('verify_cert')[0],
+            'app_debug' => $this->getConfig('environment') === 'test',
+            'host_test' => $this->getConfig('gateway')['test'],
+            'host_pro' => $this->getConfig('gateway')['product'],
+        ]);
 
-    #[\Override] public function getMerchantPrivateKeyPath()
-    {
-        return public_path().$this->getConfig('sign_cert')[0];
-    }
-
-    #[\Override] public function getLklCertificatePath()
-    {
-        return public_path().$this->getConfig('verify_cert')[0];
-    }
-
-    #[\Override] public function getHost()
-    {
-        return $this->getConfig('gateway')[$this->getConfig('environment')];
     }
 }

+ 1 - 1
src/Service/TransactionService.php

@@ -19,7 +19,7 @@ class TransactionService
     private TransPreorderApi $transPreorderApi;
     public function __construct(private Config $config)
     {
-        $this->transPreorderApi = new TransPreorderApi($config);
+        $this->transPreorderApi = new TransPreorderApi($config->getV3Config());
     }
 
     /**