🔐 포트원 V2 본인인증 연동 예제
📌 사용 방법:
1. 포트원 콘솔에서 본인인증 채널 을 먼저 추가하세요 (채널 속성: "본인인증")
2. 아래 Store ID와 본인인증 채널의 Channel Key 를 입력하세요
3. PG사를 선택하세요 (다날, KG이니시스, KCP)
4. 🔑 로그인 후 테스트하세요 (Authorization 토큰 필요)
5. "본인인증 시작" 버튼을 클릭하세요
6. 본인인증 완료 후 백엔드로 자동 전송되고, 사용자 정보가 업데이트됩니다
🔑 Authorization Token:
• 이 페이지는 index.html에서 설정한 공통 Access Token 을 사용합니다.
• 토큰이 없으면 메인 페이지에서 먼저 로그인해주세요.
Store ID
Channel Key
PG사 선택
선택하세요
다날 (DANAL)
KG이니시스 통합인증 (INICIS_UNIFIED)
KCP (KCP)
본인인증 시작
⚠️ 주의사항:
• 반드시 본인인증용 채널을 별도로 추가 해야 합니다 (채널 속성: "본인인증")
• 결제용 채널의 Channel Key를 사용하면 "ALL_CHANNELS_NOT_SATISFIED" 오류 발생
• Store ID와 Channel Key는 포트원 관리자 콘솔에서 확인하세요
• 테스트 환경에서는 실제 휴대폰 인증이 이루어지지 않을 수 있습니다
• 모바일 환경에서는 redirect 방식으로 동작합니다
📖 코드 예시
1. JavaScript (브라우저)
// 포트원 SDK 로드
<script src="https://cdn.portone.io/v2/browser-sdk.js"></script>
// 본인인증 요청
async function startIdentityVerification() {
const identityVerificationId = `identity-verification-${crypto.randomUUID()}`;
const response = await PortOne.requestIdentityVerification({
storeId: "store-xxx",
identityVerificationId: identityVerificationId,
channelKey: "channel-key-xxx",
// redirectUrl: "https://example.com/verification-complete" // 모바일용 (선택)
});
// 오류 처리
if (response.code !== undefined) {
alert(response.message);
return;
}
// 백엔드로 identityVerificationId 전송
const result = await fetch("/api/v1/identity-verification/verify", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
identity_verification_id: identityVerificationId
})
});
const data = await result.json();
console.log("본인인증 결과:", data);
}
2. React 예시
import { useEffect } from 'react';
function IdentityVerification() {
const handleVerify = async () => {
const identityVerificationId = `identity-verification-${crypto.randomUUID()}`;
try {
const response = await window.PortOne.requestIdentityVerification({
storeId: process.env.REACT_APP_PORTONE_STORE_ID,
identityVerificationId,
channelKey: process.env.REACT_APP_PORTONE_CHANNEL_KEY,
});
if (response.code) {
throw new Error(response.message);
}
// 백엔드 API 호출
const result = await fetch('/api/v1/identity-verification/verify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ identity_verification_id: identityVerificationId })
});
const data = await result.json();
console.log('인증 성공:', data);
} catch (error) {
console.error('본인인증 실패:', error);
}
};
return (
본인인증
);
}
3. Flutter/React Native (모바일)
// 웹뷰를 사용하여 본인인증 진행
// redirectUrl을 설정하여 인증 완료 후 앱으로 복귀
const response = await PortOne.requestIdentityVerification({
storeId: "store-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
identityVerificationId: identityVerificationId,
channelKey: "channel-key-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
redirectUrl: "myapp://verification-complete" // 딥링크 설정
});