fix: [esign] 알림톡 버튼 URL 도메인 치환 제거 (카카오 템플릿 검증 불일치 방지)

This commit is contained in:
김보곤
2026-02-26 08:37:15 +09:00
parent 370d001818
commit 76c60f6a92

View File

@@ -1061,30 +1061,20 @@ private function sendAlimtalk(
: " 안녕하세요, {$signer->name}님. \n 전자계약 서명 요청이 도착했습니다.\n\n ■ 계약명: {$contract->title}\n ■ 서명 기한: {$expires}\n\n 아래 버튼을 눌러 계약서를 확인하고 서명해 주세요.";
}
// 버튼 URL의 #{토큰} 변수를 실제 access_token으로 치환
// 버튼: 템플릿에서 가져온 URL의 #{토큰}만 치환 (도메인은 템플릿 등록값 유지 — 카카오 검증)
$buttons = ! empty($templateButtons) ? $templateButtons : [
['Name' => '계약서 확인하기', 'ButtonType' => 'WL',
'Url1' => $signUrl, 'Url2' => $signUrl],
];
$appUrl = rtrim(config('app.url'), '/');
foreach ($buttons as &$btn) {
foreach (['Url1', 'Url2'] as $urlKey) {
if (! empty($btn[$urlKey])) {
$url = urldecode($btn[$urlKey]);
// #{토큰} 변수를 실제 access_token으로 치환
$url = str_replace(
$btn[$urlKey] = str_replace(
['#{토큰}', '#{%ED%86%A0%ED%81%B0}'],
[$signer->access_token, $signer->access_token],
$url
urldecode($btn[$urlKey])
);
// 도메인을 현재 서버의 APP_URL로 치환 (개발/운영 환경 대응)
$url = preg_replace('#^https?://[^/]+#', $appUrl, $url);
$btn[$urlKey] = $url;
}
}
}