etax 서버환경으로 수정

This commit is contained in:
2025-12-16 16:22:30 +09:00
parent 5e786c26a1
commit 1d79a2989b
11 changed files with 223 additions and 212 deletions

View File

@@ -143,7 +143,8 @@ try {
'error' => $result['error'],
'error_code' => $result['error_code'] ?? null
], JSON_UNESCAPED_UNICODE);
} catch (Throwable $e) {
}
} catch (Exception $e) {
echo json_encode([
'success' => false,
'error' => '서버 오류: ' . $e->getMessage()
@@ -183,4 +184,4 @@ function getBankName($code) {
];
return $banks[$code] ?? $code;
}
?>

View File

@@ -183,7 +183,7 @@ if (!empty($barobillCertKey) || $isTestMode) {
'stream_context' => $context,
'cache_wsdl' => WSDL_CACHE_NONE // WSDL 캐시 비활성화
]);
} catch (Throwable $e) {
} catch (Exception $e) {
$barobillInitError = $e->getMessage();
error_log('바로빌 계좌 SOAP 클라이언트 생성 실패: ' . $e->getMessage());
}
@@ -200,79 +200,18 @@ function callBarobillAccountSOAP($method, $params = []) {
global $barobillAccountSoapClient, $barobillCertKey, $barobillCorpNum, $isTestMode, $barobillInitError, $barobillAccountSoapUrl;
if (!$barobillAccountSoapClient) {
// SOAP 클라이언트가 없으면 시뮬레이션 모드로 동작
error_log("바로빌 SOAP 클라이언트 없음 - 시뮬레이션 모드 동작: $method");
$errorMsg = $isTestMode
? '바로빌 계좌 SOAP 클라이언트가 초기화되지 않았습니다. (' . ($barobillInitError ?: '알 수 없는 오류') . ')'
: '바로빌 계좌 SOAP 클라이언트가 초기화되지 않았습니다. CERTKEY를 확인하세요. (' . ($barobillInitError ?: '알 수 없는 오류') . ')';
$mockData = new stdClass();
if ($method === 'GetBankAccountEx') {
// 계좌 목록 모의 데이터
$account = new stdClass();
$account->BankAccountNum = '123-45-67890';
$account->BankCode = '003';
$account->BankName = '기업은행';
$account->AccountName = '모의계좌(시뮬레이션)';
$account->AccountType = '1';
$account->Currency = 'KRW';
$account->IssueDate = date('Ymd');
$account->Balance = 15000000;
$account->UseState = 1;
$mockData->BankAccountEx = [$account]; // 배열 형태
// 일부 API 버전 호환성
$mockData->BankAccount = [$account];
return [
'success' => true,
'data' => $mockData,
'debug' => ['mode' => 'simulation']
];
}
elseif ($method === 'GetPeriodBankAccountTransLog') {
// 거래 내역 모의 데이터
$logs = [];
for ($i = 0; $i < 5; $i++) {
$log = new stdClass();
$log->TransDT = date('YmdHis', strtotime("-$i hours")); // 최근 시간
$log->TransDate = date('Ymd', strtotime("-$i hours"));
$log->TransTime = date('His', strtotime("-$i hours"));
$log->BankAccountNum = $params['BankAccountNum'] ?? '123-45-67890';
$log->BankName = '기업은행';
$log->Deposit = ($i % 2 == 0) ? 100000 * ($i + 1) : 0;
$log->Withdraw = ($i % 2 != 0) ? 50000 * ($i + 1) : 0;
$log->Balance = 15000000 + ($i * 10000);
$log->TransRemark1 = "시뮬레이션 거래 " . ($i + 1);
$log->Cast = "테스터";
$log->Identity = (string)$i;
$log->TransType = "IT"; // 인터넷
$log->TransOffice = "영업점";
$logs[] = $log;
}
$list = new stdClass();
$list->BankAccountTransLog = $logs;
$mockData->CurrentPage = 1;
$mockData->MaxPageNum = 1;
$mockData->CountPerPage = 10;
$mockData->MaxIndex = 5;
$mockData->BankAccountLogList = $list;
return [
'success' => true,
'data' => $mockData,
'debug' => ['mode' => 'simulation']
];
}
// 그 외 메서드는 에러 반환하되 시뮬레이션 알림
return [
'success' => false,
'error' => '시뮬레이션 모드 지원하지 않는 메서드입니다: ' . $method,
'error' => $errorMsg,
'error_detail' => [
'cert_key_file' => $_SERVER['DOCUMENT_ROOT'] . '/apikey/barobill_cert_key.txt',
'soap_url' => $barobillAccountSoapUrl,
'init_error' => $barobillInitError,
'mode' => 'simulation_fallback'
'test_mode' => $isTestMode
]
];
}
@@ -405,11 +344,17 @@ function callBarobillAccountSOAP($method, $params = []) {
]
];
} catch (Throwable $e) {
} catch (SoapFault $e) {
return [
'success' => false,
'error' => 'SOAP 오류: ' . $e->getMessage(),
'error_code' => $e->getCode()
];
} catch (Exception $e) {
return [
'success' => false,
'error' => 'API 호출 오류: ' . $e->getMessage()
];
}
}
?>

View File

@@ -483,9 +483,10 @@ try {
echo json_encode($response, JSON_UNESCAPED_UNICODE);
}
} catch (Throwable $e) {
} catch (Exception $e) {
echo json_encode([
'success' => false,
'error' => '서버 오류: ' . $e->getMessage()
], JSON_UNESCAPED_UNICODE);
}
?>