etax 전자세금계산서 .sam.kr에 맞게 수정

This commit is contained in:
2025-12-16 15:24:44 +09:00
parent 16a54cef2d
commit 5e786c26a1
11 changed files with 465 additions and 371 deletions

View File

@@ -3,10 +3,12 @@ header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
// 바로빌 API 설정 로드
require_once(__DIR__ . '/barobill_config.php');
try {
require_once(__DIR__ . '/barobill_config.php');
// POST 데이터 읽기
$input = json_decode(file_get_contents('php://input'), true);
// POST 데이터 읽기
$input = json_decode(file_get_contents('php://input'), true);
if (!$input) {
http_response_code(400);
@@ -143,6 +145,7 @@ if ($useRealAPI) {
}
} else {
// 시뮬레이션 모드 (API 키가 없을 때)
// 시뮬레이션 모드 코드 (변경 없음)
$issueKey = "BARO-" . date('Y') . "-" . str_pad(rand(1, 9999), 4, '0', STR_PAD_LEFT);
$newInvoice = [
@@ -221,6 +224,24 @@ if ($useRealAPI) {
usleep(500000); // 0.5초 지연 시뮬레이션
}
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
?>
$jsonOutput = json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
if ($jsonOutput === false) {
throw new Exception("JSON Encoding Error: " . json_last_error_msg());
}
echo $jsonOutput;
} catch (Throwable $e) {
error_log("API Error: " . $e->getMessage() . "\n" . $e->getTraceAsString());
http_response_code(500);
echo json_encode([
"success" => false,
"error" => "Internal Server Error: " . $e->getMessage(),
"debug" => [
"file" => $e->getFile(),
"line" => $e->getLine()
]
], JSON_UNESCAPED_UNICODE);
}