fix:applyMemberServerMode에서 is_active 조건 제거

- 기존: environment + is_active=true 조건으로 config 조회
  → 운영 모드 config의 is_active가 false라 certKey 적용 안됨
- 수정: environment만으로 조회하여 테넌트별 서버 모드 지원
- 운영/테스트 모드 전환 시 올바른 CERTKEY 적용됨
- 4개 컨트롤러 모두 동일 패턴 적용 및 로깅 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-03 09:06:02 +09:00
parent 0b2b0b20aa
commit f5ec680118
4 changed files with 79 additions and 80 deletions

View File

@@ -131,32 +131,31 @@ public function index(Request $request): View|Response
private function applyMemberServerMode(BarobillMember $member): void
{
$memberTestMode = $member->isTestMode();
$targetEnv = $memberTestMode ? 'test' : 'production';
// 현재 모드와 다르면 재설정
if ($this->isTestMode !== $memberTestMode) {
// 해당 환경의 BarobillConfig 조회 (is_active 무관하게 환경에 맞는 설정 사용)
$config = BarobillConfig::where('environment', $targetEnv)->first();
if ($config) {
$this->isTestMode = $memberTestMode;
// 해당 모드의 BarobillConfig 조회
$config = BarobillConfig::where('environment', $memberTestMode ? 'test' : 'production')
->where('is_active', true)
->first();
if ($config) {
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$baseUrl = $memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com';
$this->soapUrl = $baseUrl . '/BANKACCOUNT.asmx?WSDL';
} else {
// 설정이 없으면 기본 URL 사용
$this->soapUrl = $memberTestMode
? 'https://testws.baroservice.com/BANKACCOUNT.asmx?WSDL'
: 'https://ws.baroservice.com/BANKACCOUNT.asmx?WSDL';
}
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$baseUrl = $config->base_url ?: ($memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com');
$this->soapUrl = $baseUrl . '/BANKACCOUNT.asmx?WSDL';
// SOAP 클라이언트 재초기화
$this->initSoapClient();
Log::info('[Eaccount] 서버 모드 적용', [
'targetEnv' => $targetEnv,
'certKey' => substr($this->certKey ?? '', 0, 10) . '...',
'corpNum' => $this->corpNum,
'soapUrl' => $this->soapUrl,
]);
} else {
Log::warning('[Eaccount] BarobillConfig 없음', ['targetEnv' => $targetEnv]);
}
}

View File

@@ -131,32 +131,31 @@ public function index(Request $request): View|Response
private function applyMemberServerMode(BarobillMember $member): void
{
$memberTestMode = $member->isTestMode();
$targetEnv = $memberTestMode ? 'test' : 'production';
// 현재 모드와 다르면 재설정
if ($this->isTestMode !== $memberTestMode) {
// 해당 환경의 BarobillConfig 조회 (is_active 무관하게 환경에 맞는 설정 사용)
$config = BarobillConfig::where('environment', $targetEnv)->first();
if ($config) {
$this->isTestMode = $memberTestMode;
// 해당 모드의 BarobillConfig 조회
$config = BarobillConfig::where('environment', $memberTestMode ? 'test' : 'production')
->where('is_active', true)
->first();
if ($config) {
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$baseUrl = $memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com';
$this->soapUrl = $baseUrl . '/CARD.asmx?WSDL';
} else {
// 설정이 없으면 기본 URL 사용
$this->soapUrl = $memberTestMode
? 'https://testws.baroservice.com/CARD.asmx?WSDL'
: 'https://ws.baroservice.com/CARD.asmx?WSDL';
}
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$baseUrl = $config->base_url ?: ($memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com');
$this->soapUrl = $baseUrl . '/CARD.asmx?WSDL';
// SOAP 클라이언트 재초기화
$this->initSoapClient();
Log::info('[Ecard] 서버 모드 적용', [
'targetEnv' => $targetEnv,
'certKey' => substr($this->certKey ?? '', 0, 10) . '...',
'corpNum' => $this->corpNum,
'soapUrl' => $this->soapUrl,
]);
} else {
Log::warning('[Ecard] BarobillConfig 없음', ['targetEnv' => $targetEnv]);
}
}

View File

@@ -123,29 +123,31 @@ public function index(Request $request): View|Response
private function applyMemberServerMode(BarobillMember $member): void
{
$memberTestMode = $member->isTestMode();
$targetEnv = $memberTestMode ? 'test' : 'production';
// 현재 모드와 다르면 재설정
if ($this->isTestMode !== $memberTestMode) {
// 해당 환경의 BarobillConfig 조회 (is_active 무관하게 환경에 맞는 설정 사용)
$config = BarobillConfig::where('environment', $targetEnv)->first();
if ($config) {
$this->isTestMode = $memberTestMode;
// 해당 모드의 BarobillConfig 조회
$config = BarobillConfig::where('environment', $memberTestMode ? 'test' : 'production')
->where('is_active', true)
->first();
if ($config) {
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$this->soapUrl = $config->base_url . '/TI.asmx?WSDL';
} else {
// 설정이 없으면 기본 URL 사용
$this->soapUrl = $memberTestMode
? 'https://testws.baroservice.com/TI.asmx?WSDL'
: 'https://ws.baroservice.com/TI.asmx?WSDL';
}
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$baseUrl = $config->base_url ?: ($memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com');
$this->soapUrl = $baseUrl . '/TI.asmx?WSDL';
// SOAP 클라이언트 재초기화
$this->initSoapClient();
Log::info('[Etax] 서버 모드 적용', [
'targetEnv' => $targetEnv,
'certKey' => substr($this->certKey ?? '', 0, 10) . '...',
'corpNum' => $this->corpNum,
'soapUrl' => $this->soapUrl,
]);
} else {
Log::warning('[Etax] BarobillConfig 없음', ['targetEnv' => $targetEnv]);
}
}

View File

@@ -132,31 +132,30 @@ public function index(Request $request): View|Response
private function applyMemberServerMode(BarobillMember $member): void
{
$memberTestMode = $member->isTestMode();
$targetEnv = $memberTestMode ? 'test' : 'production';
// 현재 모드와 다르면 재설정
if ($this->isTestMode !== $memberTestMode) {
// 해당 환경의 BarobillConfig 조회 (is_active 무관하게 환경에 맞는 설정 사용)
$config = BarobillConfig::where('environment', $targetEnv)->first();
if ($config) {
$this->isTestMode = $memberTestMode;
// 해당 모드의 BarobillConfig 조회
$config = BarobillConfig::where('environment', $memberTestMode ? 'test' : 'production')
->where('is_active', true)
->first();
if ($config) {
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$this->baseUrl = $memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com';
} else {
// 설정이 없으면 기본 URL 사용
$this->baseUrl = $memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com';
}
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$this->baseUrl = $config->base_url ?: ($memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com');
// SOAP 클라이언트 재초기화
$this->initSoapClient();
Log::info('[Hometax] 서버 모드 적용', [
'targetEnv' => $targetEnv,
'certKey' => substr($this->certKey ?? '', 0, 10) . '...',
'corpNum' => $this->corpNum,
'baseUrl' => $this->baseUrl,
]);
} else {
Log::warning('[Hometax] BarobillConfig 없음', ['targetEnv' => $targetEnv]);
}
}