민간인증서를 기반으로 간편인증과 전자서명을 통합으로 제공하는 서비스입니다.
제공된 샘플은 API 구동을 위한 최소한의 샘플링이오니 참고부탁드립니다.
※ 좌측 하단 [샘플 다운로드] 내 패키징 파일을 통해 "즉시 연동" 할 수 있습니다.
<?php
$mid ='**********'; // 부여받은 MID(상점ID) 입력(영업담당자 문의)$apiKey ='********************************'; // 부여받은 MID 에 대한 apiKey
$mTxId ='test_20210625';
$reqSvcCd ='01';
// 등록가맹점 확인
$plainText1 = hash("sha256",(string)$mid.(string)$mTxId.(string)$apiKey);
$authHash = $plainText1;
$userName = '홍길동'; // 사용자 이름
$userPhone = '01011112222'; // 사용자 전화번호
$userBirth ='19830000'; // 사용자 생년월일
$flgFixedUser = 'N'; // 특정사용자 고정시 : Y 세팅및 아래 해시 데이터 생성if($flgFixedUser=="Y")
{
$plainText2 = hash("sha256",(string)$userName.(string)$mid.(string)$userPhone.(string)$mTxId.(string)$userBirth.(string)$reqSvcCd);
$userHash = $plainText2;
}
?>
<html>
<head>
<title>통합본인인증 요청</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script language="javascript">
function callSa()
{
let window = popupCenter();
if(window != undefined && window != null)
{
document.saForm.setAttribute("target", "sa_popup");
document.saForm.setAttribute("post", "post");
document.saForm.setAttribute("action", "https://sa.inicis.com/auth");
document.saForm.submit();
}
}
function popupCenter() {
let _width = 400;
let _height = 620;
var xPos = (document.body.offsetWidth/2) - (_width/2); // 가운데 정렬
xPos += window.screenLeft; // 듀얼 모니터일 때
return window.open("", "sa_popup", "width="+_width+", height="+_height+", left="+xPos+", menubar=yes, status=yes, titlebar=yes, resizable=yes");
}
</script>
</head>
<body>
<form name="saForm">
<input type="text" name="mid" value="<?php echo $mid ?>">
<input type="text" name="reqSvcCd" value="<?php echo $reqSvcCd ?>">
<input type="text" name="mTxId" value="<?php echo $mTxId ?>"><input type="text" name="authHash" value="<?php echo $authHash ?>">
<input type="text" name="flgFixedUser" value="<?php echo $flgFixedUser ?>">
<input type="text" name="userName" value="<?php echo $userName ?>">
<input type="text" name="userPhone" value="<?php echo $userPhone ?>">
<input type="text" name="userBirth" value="<?php echo $userBirth ?>">
<input type="text" name="userHash" value="<?php echo $userHash ?>">
<input type="text" name="directAgency" value="">
<input type="text" name="successUrl" value="https://merchantdomain/success.php">
<input type="text" name="failUrl" value="https://merchantdomain/success.php">
<!-- successUrl / failUrl 은 분리 하여 이용가능!--></form>
<button onclick="callSa()">확인</button>
</body>
</html>
<%@page import="javax.xml.bind.DatatypeConverter"%>
<%@page import="java.security.MessageDigest"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="java.util.Calendar"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String mid = "**********"; // 부여받은 MID(상점ID) 입력(영업담당자 문의)String apiKey = "********************************"; // 부여받은 MID 에 대한 apiKey
String reqSvcCd = "01";
String mTxId = "mTxId_" + Calendar.getInstance().getTimeInMillis();
// 등록가맹점 확인
String plainText1 = mid + mTxId + apiKey;
MessageDigest authmd = MessageDigest.getInstance("SHA-256");
authmd.update(plainText1.getBytes("UTF-8"));
authHash = DatatypeConverter.printHexBinary(authmd.digest()).toLowerCase();
String userName = "홍길동"; // 사용자 이름
String userPhone = "01011112222"; // 사용자 핸드폰
String userBirth = "19800101"; // 사용자 생년월일
String userHash = "";
String flgFixedUser = "N"; // 특정사용자 고정시 Y
if("Y".equals(flgFixedUser))
{
String plainText2 = userName + mid + userPhone + mTxId + userBirth + reqSvcCd;
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(plainText2.getBytes("UTF-8"));
userHash = DatatypeConverter.printHexBinary(md.digest()).toLowerCase();
}
%>
<html>
<head>
<title>통합본인인증 요청</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script language="javascript">
function callSa()
{
let window = popupCenter();
if(window != undefined && window != null)
{
document.saForm.setAttribute("target", "sa_popup");
document.saForm.setAttribute("post", "post");
document.saForm.setAttribute("action", "https://sa.inicis.com/auth");
document.saForm.submit();
}
}
function popupCenter() {
let _width = 400;
let _height = 620;
var xPos = (document.body.offsetWidth/2) - (_width/2); // 가운데 정렬
xPos += window.screenLeft; // 듀얼 모니터일 때
return window.open("", "sa_popup", "width="+_width+", height="+_height+", left="+xPos+", menubar=yes, status=yes, titlebar=yes, resizable=yes");
}
</script>
</head>
<body><form name="saForm">
<input type="text" name="mid" value="<%=mid %>">
<input type="text" name="reqSvcCd" value="<%=reqSvcCd %>">
<input type="text" name="mTxId" value="<%=mTxId %>"><input type="text" name="authHash" value="<%=authHash %>">
<input type="text" name="flgFixedUser" value="<%=flgFixedUser %>">
<input type="text" name="userName" value="<%=userName %>">
<input type="text" name="userPhone" value="<%=userPhone %>">
<input type="text" name="userBirth" value="<%==userBirth %>">
<input type="text" name="userHash" value="<%=userHash %>">
<input type="text" name="directAgency" value="">
<input type="text" name="successUrl" value="https://merchantdomain/success.jsp">
<input type="text" name="failUrl" value="https://merchantdomain/success.jsp">
<!-- successUrl/failUrl 은 분리하여도 됩니다. !-->
</form>
<button onclick="callSa()">확인</button>
</body>
</html>
파라미터 | 설명 | SIZE(Byte) | 필수(O/X) | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mid | 이니시스 가맹점 ID | 10 | O | ||||||||||||||
reqSvcCd | 요청구분코드 ["01":간편인증, "02":전자서명] * reqSvcCd: 02 (전자서명) 일 경우, identifier 파라미터 추가 세팅필요 | 2 | O | ||||||||||||||
identifier | 전자서명 값 (전자서명일 때만 필수) * 서명할 내용을 세팅 | - | X | ||||||||||||||
mTxId | 가맹점 트랜잭션 ID (요청시마다 유일값) | 20 | O | ||||||||||||||
successUrl | 인증성공 결과 전달용 가맹점 URL | 128 | O | ||||||||||||||
failUrl | 인증실패 결과 전달용 가맹점 URL | 128 | O | ||||||||||||||
authHash | 등록된 가맹점 요청 확인을 위한 HASH
HASH
×
authHash 개요
알고리즘 : SHA256 (생성된 해시값은 소문자(LowerCase) 사용)
PHP 예시)
$plainText = hash("sha256",(string)$mid.(string)$mTxId.(string)$apikey);
$authHash = $plainText;
JSP 예시)
String plainText = mid + mTxId + apikey ;
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(plainText.getBytes("UTF-8"));
authHash = DatatypeConverter.printHexBinary(md.digest()).toLowerCase();
|
N/A | O | ||||||||||||||
directAgency | 특정 제휴사 인증요청 페이지 노출옵션
Info
×
제휴사코드
|
N/A | X | ||||||||||||||
flgFixedUser | 특정 사용자에게 인증요청여부 ["Y":사용, "N":미사용 ] | 1 | O | ||||||||||||||
userName | 사용자 이름 * flgFixedUser: Y 일 경우 필수 | 25 | X | ||||||||||||||
userPhone | 사용자 전화번호 * flgFixedUser: Y 일 경우 필수 | 11 | X | ||||||||||||||
userBirth | 사용자 생년월일 [YYYYMMDD] * flgFixedUser: Y 일 경우 필수 | 8 | X | ||||||||||||||
userHash | 사용자 위변조방지를 위한 HASH
HASH
×
userHash 개요
알고리즘 : SHA256 (생성된 해시값은 소문자(LowerCase) 사용)
PHP 예시)
$plainText = hash("sha256",(string)$userName.(string)$mid.(string)$userPhone.(string)$mTxId.(string)$userBirth.(string)$reqSvcCd);
$userHash = $plainText;
JSP 예시)
String plainText = userName + mid + userPhone + mTxId + userBirth + reqSvcCd;
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(plainText.getBytes("UTF-8"));
userHash = DatatypeConverter.printHexBinary(md.digest()).toLowerCase();
|
N/A | X |
<?php
extract($_POST);
echo '<인증결과내역>'."<br/><br/>";
echo 'resultCode : '.$_REQUEST["resultCode"]."<br/>";
echo 'resultMsg : '.$_REQUEST["resultMsg"]."<br/>";
echo 'authRequestUrl : '.$_REQUEST["authRequestUrl"]."<br/>";
echo 'txId : '.$_REQUEST["txId"]."<br/>";
<%@page import="org.json.simple.parser.JSONParser"%>
<%@page import="org.json.simple.JSONObject"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="java.nio.charset.StandardCharsets"%>
<%@page import="java.nio.charset.Charset"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page import="java.net.URL"%>
<%@page import="java.net.HttpURLConnection"%>
<%@page import="java.util.Enumeration"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
String resultCode = request.getParameter("resultCode");
String resultMsg = request.getParameter("resultMsg");
* 정상처리 (resultCode:0000) 일 경우는 응답필드가 전부 전송됩니다. * 처리결과에 따라 resultCode, resultMsg 이외의 값은 전송되지 않을 수 있습니다.
파라미터 | 설명 | SIZE(Byte) | 필수(O/X) |
---|---|---|---|
resultCode | 결과코드 ["0000": 정상, 이외 실패] | 4 | O |
resultMsg | 결과메시지 (UTF-8 urlEncoding) | 500 | |
authRequestUrl | 결과조회 요청 URL | 10 | |
txId | 통합인증 트랜잭션 ID * 고유값 | 40 |
// STEP2 에 이어 인증결과가 성공일(resultCode=0000) 경우 STEP2 에서 받은 인증결과로 아래 승인요청 진행
$mid = '**********'; // 부여받은 MID(상점ID) 입력(영업담당자 문의)
if ($_REQUEST["resultCode"] === "0000") {
$data = array(
'mid' => $mid,
'txId' => $txId
);
$post_data = json_encode($data);
// curl 통신 시작
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_REQUEST["authRequestUrl"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
// -------------------- 결과 수신 -------------------------------------------
echo '<결과내역>'."<br/><br/>";
echo $response;
}else { // resultCode===0000 아닐경우 아래 인증 실패를 출력함
echo 'resultCode : '.$_REQUEST["resultCode"]."<br/>";
echo 'resultMsg : '.$_REQUEST["resultMsg"]."<br/>";
}
?>
// STEP2 에 이어 인증결과가 성공일(resultCode=0000) 경우 STEP2 에서 받은 인증결과로 아래 승인요청 진행
JSONObject resJson = null;
if("0000".equals(resultCode)){
String authRequestUrl = request.getParameter("authRequestUrl");
String txId = request.getParameter("txId");
JSONParser parser = new JSONParser();
URL url = new URL(authRequestUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if (conn != null) {
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
conn.setRequestMethod("POST");
conn.setDefaultUseCaches(false);
conn.setConnectTimeout(3000);
conn.setReadTimeout(3000);
conn.setDoOutput(true);
JSONObject reqJson = new JSONObject();
reqJson.put("mid", "**********"); // 부여받은 MID(상점ID) 입력(영업담당자 문의)reqJson.put("txId", txId);
if (conn.getDoOutput()) {
conn.getOutputStream().write(reqJson.toString().getBytes());
conn.getOutputStream().flush();
conn.getOutputStream().close();
}
conn.connect();
if (conn.getResponseCode() == HttpServletResponse.SC_OK) {
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
resJson = (JSONObject) parser.parse(br);
br.close();
}
}
for(Object key : resJson.keySet()){
out.print("<p>"+key + " : " + resJson.get(key)+"</p>");
}
// -------------------- 결과 수신 -------------------------------------------//
}else{
out.print("<p>"+resultCode+"</p>");
out.print("<p>"+resultMsg+"</p>");
}
%>
파라미터 | 설명 | SIZE(Byte) | 필수(O/X) |
---|---|---|---|
mid | 상점아이디 | 10 | O |
txId | 통합인증 트랜잭션 ID * 통합인증결과로 수신받은 값 | 40 | O |
모든 인증 프로세스 종료 후 최종적으로 전달되는 결과조회응답 파라미터에 대하여 안내합니다.
* 정상처리 (resultCode:0000) 일 경우는 응답필드가 전부 전송됩니다. * 처리결과에 따라 resultCode, resultMsg 이외의 값은 전송되지 않을 수 있습니다.
파라미터 | 설명 | SIZE(Byte) | 필수(O/X) | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
resultCode | 결과코드 ["0000": 정상, 이외 실패] | 4 | O | ||||||||||||||
resultMsg | 결과메시지 (UTF-8 urlEncoding) | 500 | O | ||||||||||||||
txId | 통합인증 트랜젝션 ID | 40 | X | ||||||||||||||
mTxId | 가맹점 트랜잭션 ID | 20 | X | ||||||||||||||
svcCd | 요청구분코드 ["01":간편인증, "02":전자서명] | 2 | X | ||||||||||||||
providerDevCd | 제휴사코드
Info
×
제휴사코드
|
10 | X | ||||||||||||||
userName | 사용자 이름 | 50 | X | ||||||||||||||
userPhone | 사용자 전화번호 | 11 | X | ||||||||||||||
userBirthday | 사용자 생년월일 | 8 | X | ||||||||||||||
userCi | 사용자 CI 데이터* 카카오톡 인증서 경우 CI 미제공 | 88 | X | ||||||||||||||
signedData | 서명데이터* 페이코 : 간편인증의 경우 미제공 | N/A | X |