54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers\Danal;
|
|
|
|
final class DanalConfig
|
|
{
|
|
public function card(string $kind): array
|
|
{
|
|
$cfg = config("danal.card.$kind");
|
|
if (!$cfg || !$cfg['cpid'] || !$cfg['key'] || !$cfg['iv'] || !$cfg['url']) {
|
|
throw new \RuntimeException("Danal card config missing: {$kind}");
|
|
}
|
|
return $cfg;
|
|
}
|
|
|
|
public function vact(): array
|
|
{
|
|
$cfg = config('danal.vact');
|
|
if (!$cfg || !$cfg['cpid'] || !$cfg['key'] || !$cfg['iv'] || !$cfg['url']) {
|
|
throw new \RuntimeException('Danal vact config missing');
|
|
}
|
|
return $cfg;
|
|
}
|
|
|
|
public function phone(string $mode): array
|
|
{
|
|
$base = config('danal.phone');
|
|
if (!$base || empty($base['bin_path']) || empty($base['item_code'])) {
|
|
throw new \RuntimeException('Danal phone base config missing (BIN_PATH/ITEMCODE)');
|
|
}
|
|
|
|
$m = $base[$mode] ?? null;
|
|
if (!$m || empty($m['cpid']) || empty($m['pwd'])) {
|
|
throw new \RuntimeException("Danal phone config missing: {$mode}");
|
|
}
|
|
|
|
return [
|
|
'bin_path' => $base['bin_path'],
|
|
'item_code' => $base['item_code'],
|
|
'start_url_web' => $base['start_url_web'],
|
|
'start_url_mobile' => $base['start_url_mobile'],
|
|
'cpid' => $m['cpid'],
|
|
'pwd' => $m['pwd'],
|
|
'iv' => $m['iv'] ?? '',
|
|
'mode' => $mode,
|
|
];
|
|
}
|
|
|
|
public function http(): array
|
|
{
|
|
return config('danal.http');
|
|
}
|
|
}
|