# 인증 정보 조회·검증

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

> 서버에서 receipt_id로 본인인증 정보를 조회하고 검증·저장하는 방법

백엔드에서 `receipt_id`로 본인인증 정보를 조회해 완료 여부를 검증하고 필요한 값만 저장합니다. 클라이언트의 `done` 이벤트가 아니라 서버가 조회한 `status` 값으로 완료를 판단합니다.

## API 정보

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

인증 헤더는 [서버 인증](https://developers.bootpay.ai/api/common/authentication)과 같은 Basic Auth(`client_key:secret_key`) 방식이고, 서버 SDK에 키를 설정하면 자동으로 처리됩니다.

## 조회·검증 코드

::: code-group sync=backend

```javascript [Node.js]
import { Bootpay } from '@bootpay/backend-js'

Bootpay.setConfiguration({
    client_key: '[ Client Key ]',
    secret_key: '[ Secret Key ]'
})

app.post('/auth/certificate', async (req, res) => {
    const { receipt_id } = req.body

    const certificate = await Bootpay.certificate(receipt_id)

    // status 12(본인인증완료)일 때만 인증 완료로 처리한다.
    if (certificate.status !== 12) {
        return res.status(400).json({ message: '본인인증이 완료되지 않았습니다.' })
    }

    // 조회 응답값만 저장한다. 클라이언트가 보낸 값은 신뢰하지 않는다.
    // unique = CI(기관 공통), di = DI(가맹점별)
    const data = certificate.authenticate_data
    await saveVerifiedUser({
        name: data.name,
        birth: data.birth,
        ci: data.unique,
        di: data.di
    })
    return res.json({ verified: true })
})
```

```python [Python]
from bootpay_backend import BootpayBackend

bootpay = BootpayBackend(
    client_key='[ Client Key ]',
    secret_key='[ Secret Key ]',
)

@app.route('/auth/certificate', methods=['POST'])
def auth_certificate():
    receipt_id = request.get_json().get('receipt_id')

    certificate = bootpay.certificate(receipt_id)

    # status 12(본인인증완료)일 때만 인증 완료로 처리한다.
    if certificate.get('status') != 12:
        return jsonify(message='본인인증이 완료되지 않았습니다.'), 400

    # 조회 응답값만 저장한다. 클라이언트가 보낸 값은 신뢰하지 않는다.
    # unique = CI(기관 공통), di = DI(가맹점별)
    data = certificate.get('authenticate_data')
    save_verified_user(
        name=data.get('name'),
        birth=data.get('birth'),
        ci=data.get('unique'),
        di=data.get('di')
    )
    return jsonify(verified=True)
```

```php [PHP]
$receipt_id = json_decode(file_get_contents('php://input'), true)['receipt_id'];

BootpayApi::setClientKeyConfiguration('[ Client Key ]', '[ Secret Key ]');
$certificate = BootpayApi::certificate($receipt_id);

// status 12(본인인증완료)일 때만 인증 완료로 처리한다.
if ($certificate->status !== 12) {
    http_response_code(400);
    echo json_encode(['message' => '본인인증이 완료되지 않았습니다.']);
    exit;
}

// 조회 응답값만 저장한다. 클라이언트가 보낸 값은 신뢰하지 않는다.
// unique = CI(기관 공통), di = DI(가맹점별)
$data = $certificate->authenticate_data;
saveVerifiedUser($data->name, $data->birth, $data->unique, $data->di);
echo json_encode(['verified' => true]);
```

```java [Java]
@PostMapping("/auth/certificate")
public ResponseEntity<?> authCertificate(@RequestBody Map<String, String> body) throws Exception {
    String receiptId = body.get("receipt_id");

    Bootpay bootpay = Bootpay.withClientKey("[ Client Key ]", "[ Secret Key ]");
    HashMap<String, Object> certificate = bootpay.certificate(receiptId);

    // status 12(본인인증완료)일 때만 인증 완료로 처리한다.
    int status = ((Number) certificate.get("status")).intValue();
    if (status != 12) {
        return ResponseEntity.badRequest().body(Map.of("message", "본인인증이 완료되지 않았습니다."));
    }

    // 조회 응답값만 저장한다. 클라이언트가 보낸 값은 신뢰하지 않는다.
    // unique = CI(기관 공통), di = DI(가맹점별)
    @SuppressWarnings("unchecked")
    Map<String, Object> data = (Map<String, Object>) certificate.get("authenticate_data");
    saveVerifiedUser(data.get("name"), data.get("birth"), data.get("unique"), data.get("di"));
    return ResponseEntity.ok(Map.of("verified", true));
}
```

```ruby [Ruby]
post '/auth/certificate' do
  receipt_id = JSON.parse(request.body.read)['receipt_id']

  bootpay = Bootpay::RestClient.new(client_key: '[ Client Key ]', secret_key: '[ Secret Key ]')
  certificate = bootpay.certificate(receipt_id).data

  # status 12(본인인증완료)일 때만 인증 완료로 처리한다. 응답 키는 심볼이다.
  if certificate[:status] != 12
    halt 400, { message: '본인인증이 완료되지 않았습니다.' }.to_json
  end

  # 조회 응답값만 저장한다. 클라이언트가 보낸 값은 신뢰하지 않는다.
  # unique = CI(기관 공통), di = DI(가맹점별)
  data = certificate[:authenticate_data]
  save_verified_user(name: data[:name], birth: data[:birth], ci: data[:unique], di: data[:di])
  { verified: true }.to_json
end
```

```go [Go]
func authCertificate(w http.ResponseWriter, r *http.Request) {
	var body map[string]string
	json.NewDecoder(r.Body).Decode(&body)
	receiptId := body["receipt_id"]

	api := bootpay.NewAPIWithClientKey("[ Client Key ]", "[ Secret Key ]", nil, "")
	certificate, err := api.Certificate(receiptId)
	if err != nil {
		http.Error(w, "인증 정보를 조회하지 못했습니다.", http.StatusBadRequest)
		return
	}

	// status 12(본인인증완료)일 때만 인증 완료로 처리한다.
	// 조회 실패 응답(error_code)에는 status 가 없으므로 comma-ok 로 읽는다.
	status, _ := certificate["status"].(float64)
	if int(status) != 12 {
		http.Error(w, "본인인증이 완료되지 않았습니다.", http.StatusBadRequest)
		return
	}

	// 조회 응답값만 저장한다. 클라이언트가 보낸 값은 신뢰하지 않는다.
	// unique = CI(기관 공통), di = DI(가맹점별)
	data := certificate["authenticate_data"].(map[string]interface{})
	saveVerifiedUser(data["name"], data["birth"], data["unique"], data["di"])
	json.NewEncoder(w).Encode(map[string]bool{"verified": true})
}
```

```csharp [.NET]
[HttpPost("/auth/certificate")]
public async Task<IActionResult> AuthCertificate([FromBody] Dictionary<string, string> body)
{
    var receiptId = body["receipt_id"];

    var bootpay = BootpayApi.WithClientKey("[ Client Key ]", "[ Secret Key ]");
    var response = await bootpay.Certificate(receiptId);
    var certificate = JsonConvert.DeserializeObject<Dictionary<string, object>>(
        await response.Content.ReadAsStringAsync()
    );

    // status 12(본인인증완료)일 때만 인증 완료로 처리한다.
    if (Convert.ToInt32(certificate["status"]) != 12)
    {
        return BadRequest(new { Message = "본인인증이 완료되지 않았습니다." });
    }

    // 조회 응답값만 저장한다. 클라이언트가 보낸 값은 신뢰하지 않는다.
    // unique = CI(기관 공통), di = DI(가맹점별)
    var data = (JObject)certificate["authenticate_data"];
    SaveVerifiedUser(data["name"], data["birth"], data["unique"], data["di"]);
    return Ok(new { Verified = true });
}
```

:::

## 응답

```json
{
  "receipt_id": "6244f60c1fc19202e42e8c4e",
  "authentication_id": "auth_1718000000000",
  "gateway_url": "https://gw.bootpay.co.kr",
  "metadata": {},
  "pg": "다날",
  "method": "인증",
  "method_symbol": "auth",
  "method_origin": "인증",
  "method_origin_symbol": "auth",
  "status": 12,
  "status_locale": "본인인증완료",
  "requested_at": "2026-06-11T09:30:01+09:00",
  "authenticated_at": "2026-06-11T09:30:29+09:00",
  "authenticate_data": {
    "name": "홍길동",
    "phone": "01012345678",
    "birth": "19900101",
    "gender": 1,
    "foreigner": "0",
    "carrier": "SKT",
    "unique": "[ CI 값 ]",
    "di": "[ DI 값 ]",
    "tid": "danal_tid_..."
  }
}
```

::: response-fields

| 필드 | 타입 | 필수 | 설명 |
|------|------|------|------|
| receipt_id | String | Y | 부트페이 인증 거래 ID |
| authentication_id | String | Y | 요청 시 보낸 가맹점 고유 인증번호 |
| gateway_url | String | Y | 인증을 처리한 게이트웨이 URL |
| metadata | Object | N | 요청 시 보낸 커스텀 데이터. 없으면 `{}` |
| pg | String | Y | 인증을 처리한 PG |
| method | String | Y | 인증 수단. 본인인증 건은 `인증` |
| method_symbol | String | N | 인증 수단 코드. 본인인증 건은 `auth` |
| method_origin | String | N | PG가 내려준 원본 수단명. 본인인증 건은 `인증` |
| method_origin_symbol | String | N | 원본 수단 코드. 본인인증 건은 `auth` |
| status | Integer | Y | 인증 상태. `12`(본인인증완료)일 때만 완료로 처리합니다 |
| status_locale | String | N | 상태의 한글 표기. 한글 라벨이 없는 상태(`50`·`51`·`-50`·`-12`)에서는 키 자체가 빠집니다 |
| requested_at | Datetime | Y | 인증 요청 시각 |
| authenticated_at | Datetime | N | 인증 완료 시각. 미완료 건은 비어 있습니다 |
| cancelled_at | Datetime | N | 취소 시각. 값이 없으면 키가 빠집니다 |
| authenticate_data | Object | Y | 인증된 사용자 정보 |
| ∟ name | String | N | 이름 |
| ∟ phone | String | N | 휴대폰 번호 |
| ∟ birth | String | N | 생년월일. PG 원본 형식 그대로 전달됩니다 (예: 다날 `19900101`) |
| ∟ gender | Integer | N | 성별 (`1`: 남자, `0`: 여자) |
| ∟ foreigner | - | N | 내·외국인 구분값. PG마다 타입이 다릅니다 (다날은 원본 문자열 `"0"`/`"1"`, KCP는 Integer `0`/`1`) |
| ∟ carrier | String | N | 통신사 (예: `SKT`). 다날은 `phone` · `foreigner` · `carrier` 를 추가 제공을 신청해야 줍니다 |
| ∟ unique | String | N | **CI**(연계정보). 기관 공통 식별값이라 어느 가맹점에서 인증해도 같은 값입니다 |
| ∟ di | String | N | **DI**(중복가입 확인정보). 가맹점별 식별값이라 중복 가입 방지에 사용합니다 |
| ∟ tid | String | Y | PG 거래 ID |

:::

### status 값

| status | 의미 | 설명 |
| ---: | --- | --- |
| `50` | 본인인증준비 | 인증 요청이 막 생성된 내부 초기 상태 |
| `51` | 본인인증승인전 | SMS/PASS 발송 완료, OTP 검증(승인) 대기 상태 |
| `12` | 본인인증완료 | 인증이 완료되어 `authenticate_data`를 받을 수 있는 상태 |
| `-50` | 본인인증실패 | 인증 요청·발송 단계에서 실패한 상태 |
| `-12` | 본인인증승인오류 | OTP 승인 단계에서 실패한 상태 |

본인인증 흐름에서는 `12` 외의 값을 모두 미완료로 처리합니다. 상태 사이의 흐름은 가이드 [본인인증 › 인증 상태](https://developers.bootpay.ai/docs/identity#인증-상태)에 있습니다.

::: info 상태값을 다룰 때 알아둘 점
- `50`은 요청 처리 중에만 잠깐 머무는 내부 초기 상태라, 요청 API 응답에서는 발송까지 끝난 `51`로 관측됩니다.
- 한글 상태 라벨은 `12`(본인인증완료)에만 정의돼 있습니다. `50`·`51`·`-50`·`-12` 상태에서는 `status_locale` 키 자체가 응답에서 빠집니다. 응답에 `status_locale`이 있다고 가정하고 파싱하면 안 됩니다.
:::

::: warning foreigner는 PG마다 타입이 다릅니다
`foreigner`는 PG가 내려주는 내·외국인 구분값입니다. 다날은 PG 원본 문자열(`"0"` / `"1"`)이 그대로 전달되고, KCP는 Integer(`0` / `1`)로 변환됩니다. 서버 분기 조건으로 쓴다면 타입까지 함께 비교하거나 문자열로 정규화한 뒤 판단합니다.
:::

## 인증 정보 저장 설계

### 30분 안에 저장해야 합니다

조회 API는 **승인 완료 시각(`authenticated_at`)부터 30분이 지나면 `AUTH_EXPIRED`로 차단**됩니다. 그래서 "나중에 필요하면 `receipt_id`로 다시 조회한다"는 설계는 동작하지 않습니다. 인증 직후 조회해서 필요한 값만 내 DB에 저장합니다.

:::canvas-flow
{
  "nodes": [
    { "id": "done", "label": "인증 완료", "col": 0, "row": 0, "type": "success" },
    { "id": "get", "label": "즉시 조회\nGET /certificate", "col": 1, "row": 0, "type": "process" },
    { "id": "save", "label": "필요한 값만\n내 DB에 저장", "col": 2, "row": 0, "type": "process" },
    { "id": "gone", "label": "30분 후\n조회 API 차단\nAUTH_EXPIRED", "col": 3, "row": 0, "type": "warning" }
  ],
  "edges": [
    { "from": "done", "to": "get" },
    { "from": "get", "to": "save" },
    { "from": "save", "to": "gone" }
  ],
  "direction": "LR",
  "cols": 4,
  "rows": 1
}
:::

30분이 지난 뒤 조회하면 `AUTH_EXPIRED` 에러가 반환되고, 사용자는 처음부터 다시 인증해야 합니다.

### 중복 가입은 DI로 판단합니다

`authenticate_data`의 `unique`는 CI(기관 공통), `di`는 DI(가맹점별)입니다. 둘이 어떻게 다른지는 가이드 [본인인증 › CI와 DI](https://developers.bootpay.ai/docs/identity#ci와-di)에 있습니다. 회원 테이블에 DI를 저장해 두고, 신규 가입 시 같은 DI가 이미 있으면 중복 가입으로 처리합니다. CI·DI 모두 개인 식별정보라 평문 노출을 피하고 암호화 저장하며, 조회용으로만 쓰도록 접근을 제한합니다.

```javascript
// 중복 가입 방지 예시
const certificate = await Bootpay.certificate(receipt_id)
if (certificate.status !== 12) throw new Error('본인인증 미완료')

const { unique: ci, di, name, birth } = certificate.authenticate_data
const existing = await User.findByDi(di)   // 중복 가입 판단은 DI로

if (existing) {
    // 이미 가입된 사람 — 아이디 찾기·계정 통합 안내로 유도한다.
    return { duplicated: true, maskedEmail: mask(existing.email) }
}

await User.create({ ci, di, name, birth })
```

### 저장은 최소한으로

::: danger 개인정보 최소 수집
`authenticate_data`에는 이름·생년월일·휴대폰 번호 같은 개인정보가 들어 있습니다. 서비스에 실제로 필요한 값만 저장하고, 나머지는 저장하면 안 됩니다. 클라이언트가 보낸 이름·전화번호가 아니라 조회 응답값을 저장합니다.

- 성인 인증만 필요하다면 → 생년월일 대신 성인 여부(boolean) 만 저장할 수 있습니다.
- 중복 가입 방지만 필요하다면 → `di`(DI)만 저장하면 충분합니다.
- 저장한 항목은 개인정보 처리방침의 수집 항목·보관 기간과 일치시킵니다.
:::

## 에러 코드

::: error-codes

| 코드 | 상황 | 처리 |
|------|------|------|
| `AUTH_NOT_FOUND` (2407) | 인증 정보를 찾지 못했습니다 | `receipt_id`가 올바른지 확인합니다 |
| `AUTH_NOT_CONFIRMED` (2408) | 아직 승인(`status: 12`)되지 않은 건입니다 | 사용자 인증 완료 후 다시 조회합니다 |
| `AUTH_EXPIRED` (2409) | 승인 완료 후 30분이 지나 조회할 수 없습니다 | 인증을 처음부터 다시 요청합니다 |
| `RC_NOT_AUTH` (2064) | 본인인증 건이 아닙니다 (결제·정기결제 영수증) | 본인인증으로 발급된 `receipt_id`인지 확인합니다 |
| `API_ONLY_SELLER` (600) | 판매점 계정만 호출할 수 있습니다 | 연동키가 판매점 프로젝트의 것인지 확인합니다 |
| `APP_KEY_CHAIN_SESSION_INVALID` (1225) | 연동키 세션이 해당 인증 건과 맞지 않습니다 | 인증을 요청할 때 쓴 것과 같은 프로젝트 연동키로 조회합니다 |

:::

::: warning 결제 receipt_id를 넣으면 2408이 먼저 나옵니다
조회 API는 `status: 12` 여부(`AUTH_NOT_CONFIRMED`)를 `RC_NOT_AUTH`보다 먼저 검사합니다. 그래서 결제 건의 `receipt_id`를 잘못 넣으면 "본인인증 건이 아니다"(2064)가 아니라 `AUTH_NOT_CONFIRMED`(2408) 가 반환됩니다. 2408을 받았다고 무조건 "인증이 아직 안 끝났다"고 해석하지 말고, 보낸 `receipt_id`의 출처도 함께 확인합니다.
:::

::: info 에러 응답 본문
에러 응답에는 `error_code`·`message`·`pg_error_code`와 함께 `payload`가 들어옵니다. `error_code`는 숫자가 아니라 상수명 문자열(예: `"AUTH_NOT_CONFIRMED"`)로 내려오므로, 분기 조건도 문자열로 비교합니다. 위 표의 괄호 안 숫자는 내부 코드값이라 응답 본문에는 나타나지 않습니다.
:::

전체 목록은 [에러 코드표](https://developers.bootpay.ai/api/reference/codes#본인인증-관련-에러)에서 확인합니다.

## 함께 보기

- [인증창 연동](https://developers.bootpay.ai/api/identity/sdk) — 인증창을 띄우는 코드를 보려면
- [인증창 없이 연동](https://developers.bootpay.ai/api/identity/no-window) — 인증 화면을 직접 만들려면
- [결제 조회](https://developers.bootpay.ai/api/pg/server/verify) — 서버 조회·검증의 공통 패턴을 보려면
