get('env', 'prod') !== 'test'); } $root = self::getSdkRoot(); require_once $root . '/init.php'; $config->validateKeys(); \BsPaySdk\core\BsPay::init([ 'sys_id' => $config->get('sys_id'), 'product_id' => $config->get('product_id'), 'rsa_merch_private_key' => $config->getPrivateKey(), 'rsa_huifu_public_key' => $config->getPublicKey(), 'skill_source' => $config->get('skill_source', 'hfps/1.3.5'), ], true); self::$loaded = true; return $root; } public static function getSdkRoot() { $paths = [ ROOT_PATH . 'vendor/huifurepo/dg-php-sdk/BsPaySdk', ADDON_PATH . 'shopro_huifu/library/sdk/BsPaySdk', ADDON_PATH . 'shopro_huifu/library/sdk/extracted/huifurepo-bspay-php-sdk-45b895b/BsPaySdk', ]; foreach ($paths as $path) { if (is_file($path . '/init.php')) { return rtrim($path, '/\\'); } } throw new \RuntimeException('未找到汇付 dg-php-sdk,请安装 huifurepo/dg-php-sdk ^2.0.30'); } public static function requireRequest($relativePath) { $root = self::boot(); $file = $root . '/request/' . ltrim(str_replace('\\', '/', $relativePath), '/'); if (!is_file($file)) { $file = dirname($root) . '/request/' . ltrim(str_replace('\\', '/', $relativePath), '/'); } if (!is_file($file)) { throw new \RuntimeException('SDK request 文件不存在: ' . $relativePath); } require_once $file; } }