From 504f59dc998d18b8a44b12bbc6564cd79908ac13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Tue, 24 Feb 2026 18:41:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[esign]=20=EC=95=8C=EB=A6=BC=ED=86=A1=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20URL=EC=9D=84=20=EB=93=B1=EB=A1=9D=EB=90=9C?= =?UTF-8?q?=20=ED=85=9C=ED=94=8C=EB=A6=BF=20URL=20=EA=B7=B8=EB=8C=80?= =?UTF-8?q?=EB=A1=9C=20=EC=82=AC=EC=9A=A9=20(=EB=8F=99=EC=A0=81=20URL=20?= =?UTF-8?q?=ED=85=9C=ED=94=8C=EB=A6=BF=20=EB=B6=88=EC=9D=BC=EC=B9=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ESign/EsignApiController.php | 60 +++++++++++++------ 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/ESign/EsignApiController.php b/app/Http/Controllers/ESign/EsignApiController.php index 5cb4b6cf..a3478bff 100644 --- a/app/Http/Controllers/ESign/EsignApiController.php +++ b/app/Http/Controllers/ESign/EsignApiController.php @@ -1035,8 +1035,10 @@ private function sendAlimtalk( $templateName = $isReminder ? '전자계약_리마인드' : '전자계약_서명요청'; - // 등록된 템플릿 본문을 가져와서 변수 치환 (정확한 포맷 유지) - $templateContent = $this->getTemplateContent($barobill, $member->biz_no, $channelId, $templateName); + // 등록된 템플릿 본문 + 버튼 정보 조회 (정확한 포맷 유지) + $tplData = $this->getTemplateData($barobill, $member->biz_no, $channelId, $templateName); + $templateContent = $tplData['content']; + $templateButtons = $tplData['buttons']; if ($templateContent) { $message = str_replace( @@ -1054,18 +1056,21 @@ private function sendAlimtalk( : " 안녕하세요, {$signer->name}님. \n 전자계약 서명 요청이 도착했습니다.\n\n ■ 계약명: {$contract->title}\n ■ 서명 기한: {$expires}\n\n 아래 버튼을 눌러 계약서를 확인하고 서명해 주세요."; } + // 등록된 버튼 URL을 그대로 사용 (동적 URL 사용 시 템플릿 불일치 오류) + $buttons = ! empty($templateButtons) ? $templateButtons : [ + ['Name' => '계약서 확인하기', 'ButtonType' => 'WL', + 'Url1' => 'https://mng.codebridge-x.com', 'Url2' => 'https://mng.codebridge-x.com'], + ]; + $receiverNum = preg_replace('/[^0-9]/', '', $signer->phone); \Log::info('E-Sign 알림톡 발송 시도', [ 'contract_id' => $contract->id, 'signer_id' => $signer->id, - 'sender_id' => $member->barobill_id, - 'yellow_id' => $channelId, 'template_name' => $templateName, 'template_from_api' => (bool) $templateContent, + 'buttons_from_api' => ! empty($templateButtons), 'receiver_num' => $receiverNum, - 'message_length' => mb_strlen($message), - 'sign_url' => $signUrl, ]); $result = $barobill->sendATKakaotalkEx( @@ -1077,14 +1082,7 @@ private function sendAlimtalk( receiverNum: $receiverNum, title: '', message: $message, - buttons: [ - [ - 'Name' => '계약서 확인하기', - 'ButtonType' => 'WL', - 'Url1' => $signUrl, - 'Url2' => $signUrl, - ], - ], + buttons: $buttons, ); // 발송 접수 후 결과 확인 (SendKey 반환 시) @@ -1178,14 +1176,18 @@ private function getKakaotalkChannelId(BarobillService $barobill, string $bizNo) } /** - * 바로빌 등록 템플릿의 본문 내용 조회 + * 바로빌 등록 템플릿의 본문 내용 및 버튼 정보 조회 + * + * @return array{content: string|null, buttons: array} */ - private function getTemplateContent(BarobillService $barobill, string $bizNo, string $channelId, string $templateName): ?string + private function getTemplateData(BarobillService $barobill, string $bizNo, string $channelId, string $templateName): array { + $empty = ['content' => null, 'buttons' => []]; + $result = $barobill->getKakaotalkTemplates($bizNo, $channelId); if (! ($result['success'] ?? false) || empty($result['data'])) { - return null; + return $empty; } $data = $result['data']; @@ -1199,11 +1201,31 @@ private function getTemplateContent(BarobillService $barobill, string $bizNo, st foreach ($items as $tpl) { if (($tpl->TemplateName ?? '') === $templateName) { - return $tpl->TemplateContent ?? null; + $buttons = []; + $btnData = $tpl->Buttons ?? null; + if ($btnData) { + $btnList = $btnData->KakaotalkButton ?? null; + if ($btnList) { + $btnList = is_array($btnList) ? $btnList : [$btnList]; + foreach ($btnList as $btn) { + $buttons[] = [ + 'Name' => $btn->Name ?? '', + 'ButtonType' => $btn->ButtonType ?? 'WL', + 'Url1' => $btn->Url1 ?? '', + 'Url2' => $btn->Url2 ?? '', + ]; + } + } + } + + return [ + 'content' => $tpl->TemplateContent ?? null, + 'buttons' => $buttons, + ]; } } - return null; + return $empty; } /**