개발자센터

4. 인증정보 조회 및 활용하기

인증정보를 획득하고 활용하는 방법을 안내합니다.

휴대폰 본인인증 완료이후 획득한 identity_verification_id를 이용하여 고객 인증정보를 조회할 수 있습니다.

인증 결과 조회 API 구현하기

아래 코드는 API KEY를 이용해 access_token을 먼저 발급하고, 이를 이용해 포트원의 본인인증 내역 단건조회 API를 호출하여 인증 정보를 조회하는 예시입니다.

server-side
app.use(bodyParser.json());
  ...
  // "/identity-verifications"에 대한 POST 요청을 처리하는 controller
  app.post("/identity-verifications", async (request, response) => {
    // request의 body에서 identityVerificationId와 identityVerificationTxId 추출
    const { identityVerificationId } = request.body;
    try {
      // 1. 포트원 API를 사용하기 위한 액세스 토큰 발급 받기
      const signinResponse = await axios({
        url: "https://api.portone.io/login/api-key",
        method: "post",
        headers: { "Content-Type": "application/json" },
        data: {
          apiKey: PORTONE_API_KEY, // 포트원 API Key
        },
      });
      const { access_token } = signinResponse.data;
 
      // 2. 포트원 본인인증 내역 단건조회 API 호출
      const verificationResponse = await axios({
        url: `https://api.portone.io/identity-verifications/${identityVerificationId}?storeId=${storeId}`,
        method: "get",
        // 1번에서 발급받은 액세스 토큰을 Bearer 형식에 맞게 넣어주세요.
        headers: { "Authorization": "Bearer " + access_token },
      });
      const identityVerification = verificationResponse.data;
      if (identityVerification.status !== "VERIFIED") {
        // 인증 실패
        ...
      }
      ...
    } catch(e) {
      console.error(e);
    }
  });

인증 정보 활용하기

조회한 인증 정보에서 다음의 고객 정보를 추출하는 서비스 코드 예제입니다. 아래 파라미터들은 모두 본인인증 단건 조회의 결과가 인증 완료 상태일 때 (status = "VERIFIED") 제공되는 verifiedCustomer 필드 내에 존재합니다.

  • ci: 연계 정보(Connecting Information). 사람마다 고유하고 서비스별로 달라지지 않기 때문에, 서비스 간 연계에 사용할 수 있음.
  • di: 중복 가입 확인 정보(Duplication Information). 해당 서비스 안에서만 사람마다 고유함. 이용자의 중복 가입을 확인하는 데 사용할 수 있음.
  • name: 이름
  • gender: 성별
  • birthDate: 생년월일 (YYYY-MM-DD)

위의 정보 외에 외국인(isForeigner) 여부는 API 방식 본인인증에 한하여 개인정보 제공동의 약관을 사이트에 게재한 후 cs@portone.io로 신청하여 취득할 수 있습니다. 해당 부분은 당사 계약 이후 다날PG사로 요청 후 승인이 완료되면 이용 가능한 점 참고해 주시기 바랍니다.

메일 요청 신청 양식

  • 상호명 :
  • 사업자번호 :
  • 본인인증용 다날 상점ID(CPID) :
  • 업종 :
  • 필요사유 :
  • 개인정보취급방침 url : 앱서비스로 URL형태로 전달이 어려우신 경우 ‘개인정보취급방침’ 경로를 캡쳐하여 전달주시기 바랍니다.

참고 - 포트원 이용 가맹점의 개인정보처리방침 적용 예시

  • (주)마플 : https://marpple.shop/kr/@/privacy
  • (주)브레이브모바일 / 숨고 : https://soomgo.com/terms/privacy
  • (주)마켓잇 : https://static.marketit.asia/static/privacy-terms.pdf
Node.js
  // "/identity-verifications"에 대한 POST 요청을 처리하는 controller
  app.post("/identity-verifications", async (request, response) => {
    // request의 body에서 identity_verification_id 추출
    const { identity_verification_id } = request.body;
    try {
      // 인증 토큰 발급 받기
      /* ...중략... */
      // identity_verification_id로 인증 정보 조회
      /* ...중략... */
      const { ci, di, name, gender, birthDate } = identityVerification.customer;
      ...
      // 연령 제한 로직 예시
      if (new Date(birthDate).getFullYear() <= 1999) {
        // 연령 만족
      } else {
        // 연령 미달
      }
      ...
      // 1인 1계정 허용 로직 예시
      // DB에서 di 조회 후 가입여부 검사
      const user = await Users.find({ di: di });
      if (!user) {
        // 신규 고객
      } else {
        // 이미 가입된 고객
      }
    } catch(e) {
      console.error(e);
    }
  });