# SDK 본인인증

원문: https://developers.bootpay.ai/api/identity/sdk

> SDK로 본인인증 창을 띄우고 receipt_id로 결과를 서버에서 조회하는 방법

프론트엔드에서 `requestAuthentication()`으로 PG 인증창(통신사 선택·OTP 입력)을 띄워 `receipt_id`를 받고, 서버에서 그 `receipt_id`로 결과를 조회해 이름·CI/DI 같은 값을 확정합니다. 프론트엔드 결과만으로 실명·성인 여부를 확정하면 안 됩니다.

---

## 1. 인증창 호출 (프론트엔드)

::: code-group sync=platform

```javascript [JavaScript]
import { Bootpay } from '@bootpay/client-js'

async function requestAuthentication() {
    try {
        const response = await Bootpay.requestAuthentication({
            client_key: '[ Client Key ]',
            pg: '다날',
            order_name: '본인인증',                        // 인증창에 표시될 이름
            authentication_id: 'auth_' + Date.now(),       // 가맹점이 부여하는 고유 본인인증 ID
            user: {
                username: '홍길동',     // 선입력 시 사용자가 다시 입력하지 않아도 됨 (선택)
                phone: '01012345678'
            }
        })

        // 인증 완료 → receipt_id를 서버로 보내 결과를 확정
        if (response.event === 'done') {
            await confirmIdentity(response.data.receipt_id)
        }
    } catch (e) {
        console.log(e.message)   // 사용자가 인증창을 닫거나 인증에 실패한 경우
    }
}

async function confirmIdentity(receiptId) {
    await fetch('/api/identity/confirm', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ receipt_id: receiptId })
    })
}
```

:::

::: tip 앱(iOS·Android·Flutter·React Native)에서
앱 SDK도 동일한 payload(`pg`, `order_name`, `authentication_id`, `user`)로 본인인증을 요청합니다. 네이티브 SDK의 초기화·`client_key` 설정 방법은 [결제창 통합 가이드](https://developers.bootpay.ai/api/pg/window/integration)의 플랫폼별 설정과 같습니다. 인증 완료 콜백에서 받은 `receipt_id`를 서버로 전달하면 이후 처리는 동일합니다.
:::

### 요청 파라미터

::: parameters

| 파라미터 | 타입 | 필수 | 설명 |
| --- | --- | --- | --- |
| `client_key` | String | Y | Client Key. [관리자 > 개발자 설정 > API 연동키](https://admin.bootpay.co.kr/setting/developer)에서 확인 |
| `pg` | String | Y | 본인인증 PG사. 다날 또는 KCP 의 PG 코드를 넣습니다 (예: `다날`, `kcp`). 값은 [PG 코드](https://developers.bootpay.ai/api/reference/enum)에 있습니다 |
| `order_name` | String | Y | 인증창에 표시할 이름 |
| `authentication_id` | String | Y | 가맹점이 부여하는 본인인증 고유 ID (중복 요청 추적용) |
| `method` | String | N | 인증 수단. 생략하면 `본인인증`으로 처리됩니다 |
| `user.username` | String | N | 이름 선입력값 |
| `user.phone` | String | N | 휴대폰번호 선입력값 |
| `metadata` | Object | N | 가맹점 커스텀 데이터. 결과 조회 응답에 그대로 되돌아옵니다 |
| `extra` | Object | N | 추가 옵션. `extra.carrier`로 다날 인증창의 통신사를 고정할 수 있습니다 |

:::

### 인증 완료 이벤트 데이터

`done` 이벤트로 받는 데이터는 **결과 조회를 위한 최소 정보**입니다. 실명·CI/DI 같은 값은 들어있지 않으므로 서버 조회가 필요합니다.

```json
{
  "event": "done",
  "data": {
    "receipt_id": "624ce9d31fc19202e4746f3b",
    "authentication_id": "1649207763202",
    "gateway_url": "https://gw.bootpay.co.kr",
    "metadata": {},
    "pg": "다날",
    "method": "인증",
    "method_symbol": "auth",
    "method_origin": "인증",
    "method_origin_symbol": "auth",
    "authenticated_at": "2026-04-06T10:16:20+09:00",
    "requested_at": "2026-04-06T10:16:03+09:00",
    "status_locale": "본인인증완료",
    "status": 12
  }
}
```

---

## 2. 결과 조회 (서버)

프론트엔드에서 받은 `receipt_id`로 서버에서 인증 결과를 조회합니다. 이 응답의 `authenticate_data`가 **신뢰할 수 있는 최종 결과**입니다.

::: endpoint
method: GET
url: https://api.bootpay.co.kr/v2/certificate/{receipt_id}
auth: Basic Auth
:::

::: parameters

| 파라미터 | 위치 | 필수 | 설명 |
| --- | --- | --- | --- |
| `receipt_id` | Path | Y | 프론트엔드 `done` 이벤트에서 받은 본인인증 영수증 ID |

:::

::: warning 조회 시한
본인인증 결과는 인증 완료 후 30분이 지나면 조회할 수 없습니다(`AUTH_EXPIRED`). 프론트엔드에서 `receipt_id`를 받으면 곧바로 서버로 보내 조회·저장합니다.
:::

서버 SDK 7개 언어 조회 · 검증 코드와 응답 필드 전체는 [인증 정보 조회·검증](https://developers.bootpay.ai/api/identity/verify#조회검증-코드)에 있습니다. 응답의 `status` 가 `12`(본인인증완료)일 때만 완료로 처리하고, 필요한 값만 저장합니다.

::: danger CI/DI 취급
`unique`(CI)와 `di`(DI)는 개인을 식별하는 민감정보입니다. 평문으로 로그에 남기거나 프론트엔드로 내려보내지 말고, 저장 시 반드시 암호화합니다.
:::

## 에러 코드

결과 조회에서 나는 에러(`AUTH_NOT_FOUND` · `AUTH_NOT_CONFIRMED` · `AUTH_EXPIRED` · `RC_NOT_AUTH` 등)와 응답 본문 형식은 [인증 정보 조회·검증 › 에러 코드](https://developers.bootpay.ai/api/identity/verify#에러-코드)에 있습니다. 인증·권한 관련 공통 에러는 [에러 코드표](https://developers.bootpay.ai/api/reference/codes#인증-관련-에러)를 참고합니다.

## 함께 보기

- [인증창 없이 연동](https://developers.bootpay.ai/api/identity/no-window) — 인증 화면을 직접 구성하거나 OTP를 단계별로 제어하려면(REST API 본인인증)
- [데이터 모델 설계](https://developers.bootpay.ai/api/reference/data-model) — 결과값(CI/DI) 저장 설계
