# 인증서 관리

## 1. GetTaxCertURL - 인증서 등록 팝업 URL

| HTTP Method | 테스트(Sandbox)                                | 운영(Production)                         |
| ----------- | ------------------------------------------- | -------------------------------------- |
| GET         | <https://popbill-test.linkhub.co.kr/Member> | <https://popbill.linkhub.co.kr/Member> |

![인증서 등록 팝업 URL 미리보기](https://developers.popbill.com/images/reference/taxinvoice/getTaxCertURL.png)

**공동인증서를 등록하는 팝업 URL을 반환합니다.**

- 권장 사이즈 : width = 1,000px / height = 630px
- 반환되는 URL은 30초 동안만 사용이 가능합니다.
- 반환되는 URL에서만 유효한 세션을 포함하고 있습니다.

### Request

**요청 헤더**

- Authorization `required: Y` `description: 인증 토큰`
  - [\[참고\] 인증 및 헤더 설정](https://developers.popbill.com/api-reference/taxinvoice/getting-started/authorization)
- Accept-Language `required: N` `description: 응답 언어 설정`
  - `ko-KR`: 기본값
  - `en-US`
- Accept-Encoding `required: N` `description: 응답 압축 방식`
  - `gzip`
- X-PB-UserID `required: N` `description: 팝빌회원 아이디`

**Query 파라미터**

- TG `type: string` `length: -` `required: Y` `description: 고정값 : CERT`

**요청 예시**

```bash
curl --request GET \
  --url 'https://{domain}/Member?TG=CERT' \
  --header 'Authorization: Bearer {token}'
```

### Response

**응답 본문**

- url `type: string` `length: -` `description: 인증서 등록 팝업 URL`

**응답 예시**

```json
{
    "url": "https://test.popbill.com/App/API?T=FFXMY6SEHFVDD27TUYBESQ7...XYK2NPF5NLWKD2==="
}
```

## 2. RegistTaxCert - 인증서 등록

| HTTP Method | 테스트(Sandbox)                                                | 운영(Production)                                         |
| ----------- | ----------------------------------------------------------- | ------------------------------------------------------ |
| POST        | <https://popbill-test.linkhub.co.kr/Taxinvoice/Certificate> | <https://popbill.linkhub.co.kr/Taxinvoice/Certificate> |

- 전자세금계산서 발행에 필요한 공동인증서를 팝빌 인증서버에 등록합니다.
- 공동인증서는 팝빌에서 발급하는 ‘표준 인증서’, 은행에서 발급하는 ‘전자세금용 인증서’ 또는 ‘기업범용 인증서’만 등록 가능합니다.

> 공동인증서 정보는 통신 구간의 보안을 위해 필드 레벨 암호화(FLE)되어 처리됩니다.\
> ※ 통신구간 암호화 키 발급은 파트너 센터(1600-8536)로 문의하여 주시기 바랍니다.\
> 공동인증서 비밀번호의 안전한 관리를 위해 DB 저장시 컬럼 암호화 하여 저장합니다.

### Request

**요청 헤더**

- Authorization `required: Y` `description: 인증 토큰`
  - [\[참고\] 인증 및 헤더 설정](https://developers.popbill.com/api-reference/taxinvoice/getting-started/authorization)
- Content-Type `required: Y` `description: 요청 본문 형식`
  - `application/json`
- Accept-Language `required: N` `description: 응답 언어 설정`
  - `ko-KR`: 기본값
  - `en-US`
- Accept-Encoding `required: N` `description: 응답 압축 방식`
  - `gzip`
- X-PB-UserID `required: N` `description: 팝빌회원 아이디`

**요청 본문**

- certPublicKey `type: string` `length: -` `required: Y` `description: 공동인증서 공개키`
  - 공동인증서 정보 암호화된 값
- certPrivateKey `type: string` `length: -` `required: Y` `description: 공동인증서 개인키`
  - 공동인증서 정보 암호화된 값
- certCipher `type: string` `length: -` `required: Y` `description: 공동인증서 비밀번호`

**요청 예시**

```bash
curl --request POST \
  --url 'https://{domain}/Taxinvoice/Certificate' \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
    "certPublicKey": "암호화된 공동인증서 공개키",
    "certPrivateKey": "암호화된 공동인증서 개인키",
    "certCipher": "암호화된 공동인증서 비밀번호"
  }'
```

### Response

**응답 본문**

- code `type: number` `length: -` `description: API 처리에 대한 응답코드`
  - `1`: 성공
- message `type: string` `length: -` `description: API 처리에 대한 응답메시지`

**응답 예시**

```json
{
    "code": 1,
    "message": "등록 완료"
}
```

## 3. RegistTaxCertPFX - PFX 인증서 등록

| HTTP Method | 테스트(Sandbox)                                                   | 운영(Production)                                            |
| ----------- | -------------------------------------------------------------- | --------------------------------------------------------- |
| POST        | <https://popbill-test.linkhub.co.kr/Taxinvoice/CertificatePFX> | <https://popbill.linkhub.co.kr/Taxinvoice/CertificatePFX> |

- 전자세금계산서 발행에 필요한 공동인증서를 팝빌 인증서버에 등록합니다.
- 공동인증서는 팝빌에서 발급하는 ‘표준 인증서’, 은행에서 발급하는 ‘전자세금용 인증서’ 또는 ‘기업범용 인증서’만 등록 가능합니다.

> 공동인증서 정보는 통신 구간의 보안을 위해 필드 레벨 암호화(FLE)되어 처리됩니다.\
> ※ 통신구간 암호화 키 발급은 파트너 센터(1600-8536)로 문의하여 주시기 바랍니다.\
> 공동인증서 비밀번호의 안전한 관리를 위해 DB 저장시 컬럼 암호화 하여 저장합니다.

### Request

**요청 헤더**

- Authorization `required: Y` `description: 인증 토큰`
  - [\[참고\] 인증 및 헤더 설정](https://developers.popbill.com/api-reference/taxinvoice/getting-started/authorization)
- Content-Type `required: Y` `description: 요청 본문 형식`
  - `application/json`
- Accept-Language `required: N` `description: 응답 언어 설정`
  - `ko-KR`: 기본값
  - `en-US`
- Accept-Encoding `required: N` `description: 응답 압축 방식`
  - `gzip`
- X-PB-UserID `required: N` `description: 팝빌회원 아이디`

**요청 본문**

- pfx `type: string` `length: -` `required: Y` `description: 공동인증서 PFX 파일`
  - 공동인증서 정보 암호화된 값
- password `type: string` `length: -` `required: Y` `description: 공동인증서 PFX 파일 비밀번호`
  - 공동인증서 정보 암호화된 값

**요청 예시**

```bash
curl --request POST \
  --url 'https://{domain}/Taxinvoice/CertificatePFX' \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
    "pfx": "암호화된 공동인증서 PFX 파일",
    "password": "암호화된 공동인증서 PFX 파일 비밀번호"
  }'
```

### Response

**응답 본문**

- code `type: number` `length: -` `description: API 처리에 대한 응답코드`
  - `1`: 성공
- message `type: string` `length: -` `description: API 처리에 대한 응답메시지`

**응답 예시**

```json
{
    "code": 1,
    "message": "등록 완료"
}
```

## 4. GetCertificateExpireDate - 인증서 만료일 확인

| HTTP Method | 테스트(Sandbox)                                    | 운영(Production)                             |
| ----------- | ----------------------------------------------- | ------------------------------------------ |
| GET         | <https://popbill-test.linkhub.co.kr/Taxinvoice> | <https://popbill.linkhub.co.kr/Taxinvoice> |

- 팝빌 인증서버에 등록된 공동인증서의 만료일을 확인합니다.

### Request

**요청 헤더**

- Authorization `required: Y` `description: 인증 토큰`
  - [\[참고\] 인증 및 헤더 설정](https://developers.popbill.com/api-reference/taxinvoice/getting-started/authorization)
- Accept-Language `required: N` `description: 응답 언어 설정`
  - `ko-KR`: 기본값
  - `en-US`
- Accept-Encoding `required: N` `description: 응답 압축 방식`
  - `gzip`
- X-PB-UserID `required: N` `description: 팝빌회원 아이디`

**Query 파라미터**

- cfg `type: string` `length: -` `required: Y` `description: 고정값 : CERT`

**요청 예시**

```bash
curl --request GET \
  --url 'https://{domain}/Taxinvoice?cfg=CERT' \
  --header 'Authorization: Bearer {token}'
```

### Response

**응답 본문**

- certificateExpiration `type: string` `length: 14` `description: 공동인증서 만료일자`
  - 형식 : yyyyMMddHHmmss

**응답 예시**

```json
{
    "certificateExpiration": "20260706145209"
}
```

## 5. CheckCertValidation - 인증서 유효성 확인

| HTTP Method | 테스트(Sandbox)                                              | 운영(Production)                                       |
| ----------- | --------------------------------------------------------- | ---------------------------------------------------- |
| GET         | <https://popbill-test.linkhub.co.kr/Taxinvoice/CertCheck> | <https://popbill.linkhub.co.kr/Taxinvoice/CertCheck> |

- 팝빌 인증서버에 등록된 공동인증서의 유효성을 확인합니다.

### Request

**요청 헤더**

- Authorization `required: Y` `description: 인증 토큰`
  - [\[참고\] 인증 및 헤더 설정](https://developers.popbill.com/api-reference/taxinvoice/getting-started/authorization)
- Accept-Language `required: N` `description: 응답 언어 설정`
  - `ko-KR`: 기본값
  - `en-US`
- Accept-Encoding `required: N` `description: 응답 압축 방식`
  - `gzip`
- X-PB-UserID `required: N` `description: 팝빌회원 아이디`

**요청 예시**

```bash
curl --request GET \
  --url 'https://{domain}/Taxinvoice/CertCheck' \
  --header 'Authorization: Bearer {token}'
```

### Response

**응답 본문**

- code `type: number` `length: -` `description: API 처리에 대한 응답코드`
  - `1`: 성공
- message `type: string` `length: -` `description: API 처리에 대한 응답메시지`

**응답 예시**

```json
{
    "code": 1,
    "message": "유효성 확인"
}
```

## 6. GetTaxCertInfo - 인증서 정보 확인

| HTTP Method | 테스트(Sandbox)                                                | 운영(Production)                                         |
| ----------- | ----------------------------------------------------------- | ------------------------------------------------------ |
| GET         | <https://popbill-test.linkhub.co.kr/Taxinvoice/Certificate> | <https://popbill.linkhub.co.kr/Taxinvoice/Certificate> |

- 팝빌 인증서버에 등록된 공동인증서의 정보를 확인합니다.

### Request

**요청 헤더**

- Authorization `required: Y` `description: 인증 토큰`
  - [\[참고\] 인증 및 헤더 설정](https://developers.popbill.com/api-reference/taxinvoice/getting-started/authorization)
- Accept-Language `required: N` `description: 응답 언어 설정`
  - `ko-KR`: 기본값
  - `en-US`
- Accept-Encoding `required: N` `description: 응답 압축 방식`
  - `gzip`
- X-PB-UserID `required: N` `description: 팝빌회원 아이디`

**요청 예시**

```bash
curl --request GET \
  --url 'https://{domain}/Taxinvoice/Certificate' \
  --header 'Authorization: Bearer {token}'
```

### Response

**응답 본문**

- regDT `type: string` `length: 14` `description: 등록일시`
  - 형식 : yyyyMMddHHmmss
  - 인증서를 팝빌 인증서버에 등록한 시간
- expireDT `type: string` `length: 14` `description: 만료일시`
  - 형식 : yyyyMMddHHmmss
  - 팝빌 인증서버에 등록된 인증서의 만료일시
- issuerDN `type: string` `length: 200` `description: 발급자 DN`
- subjectDN `type: string` `length: 200` `description: 인증서 DN`
- issuerName `type: string` `length: 12` `description: 인증서 종류`
  - `전자세금용 공동인증서`
  - `팝빌 특목용 공동인증서`
  - `기타`
- OID `type: string` `length: 30` `description: OID`
- regContactName `type: string` `length: 100` `description: 등록 담당자 성명`
  - 팝빌 인증서버에 인증서를 등록한 담당자 성명
- regContactID `type: string` `length: 50` `description: 등록 담당자 아이디`
  - 팝빌 인증서버에 인증서를 등록한 담당자 팝빌회원 아이디

**응답 예시**

```json
{
    "issuerDN": "CN=TradeSignCA4, OU=AccreditedCA, O=TradeSign, C=KR",
    "subjectDN": "CN=테스트(KTNET), OU=KTNET, OU=LicensedCA, O=TradeSign, C=KR",
    "oid": "1.2.410.200012.1.1.3",
    "regDT": "20250711112305",
    "regContactID": "등록 담당자 아이디",
    "expireDT": "20260706145209",
    "issuerName": "기타 [1.2.410.200012.1.1.3]",
    "regContactName": "등록 담당자 성명"
}
```
