# Payment

## Payment Flow

<figure><img src="/files/kaI5aXhqb3lC7pIm9p4T" alt=""><figcaption></figcaption></figure>

## LINE NEXT ➡️ PG

## 결제 생성 요청

> 결제 생성 요청 API입니다.

```json
{"openapi":"3.1.0","info":{"title":"Api-fiddle Bookstore Example","version":"1.0.0"},"tags":[{"name":"payment"}],"security":[{"X-Authorization-Hmac":[]}],"components":{"securitySchemes":{"X-Authorization-Hmac":{"in":"header","name":"X-Authorization-Hmac","type":"apiKey","description":"HMAC 생성 방식: BASE64( HMACSHA256(appSecret, {HTTP_METHOD}{URI}{X-API-Key}{X-Timestamp}{REQUEST_BODY}) )\n- 아래 서명값 대상을 문자열로 합쳐 PG사 측에 사전 발급된 appSecret으로 SHA256으로 서명값 생성\n서명값 대상\n- HTTP_METHOD: 요청시 지정한 대문자 HTTP Method (ex: GET, POST, PUT 등)\n- URI: 요청한 URI (ex: /api/v1/payment)\n- HEADER: 요청 header 중 아래 값 포함\n-     X-API-Key: PG사 측에 사전 발급된 api key (ex: X-API-Key: \"f3248c3e-881c-42bd-abe7-1232023fe896\") \n-     X-Timestamp: 요청시 밀리초단위 timestamp 값 (ex: X-Timestamp: 1773017787000) 단, 현재 시각과 5분 이상 차이가 나면 요청 거부\n- REQUESET_BODY: 요청시 request body"}}},"paths":{"/api/v1/payment":{"post":{"tags":["payment"],"summary":"결제 생성 요청","responses":{"200":{"content":{"application/json":{"schema":{"type":"object","title":"결제생성요청Ok","required":["startPageUrl","transactionId"],"properties":{"startPageUrl":{"type":"string","description":"PG 측에서 유저에게 리다이렉션할 URL"},"transactionId":{"type":"string","description":"생성한 거래 <uuid>"}}}}},"description":"The request was successful, and the server has returned the requested resource in the response body."}},"parameters":[{"in":"header","name":"X-AppId","style":"simple","schema":{"type":"string"},"explode":false,"required":true,"description":"PG사에 사전 발급된 appId","allowReserved":false},{"in":"header","name":"X-Timestamp","style":"simple","schema":{"type":"string"},"explode":false,"required":true,"description":"요청 시 밀리초단위 timestamp 값","allowReserved":false}],"description":"결제 생성 요청 API입니다.","operationId":"결제생성요청","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["requestId","orderId","storeId","items","returnUrl","callbackUrl","countryCode","orderCurrencyCode"],"properties":{"items":{"type":"array","items":{"type":"object","required":["name","price"],"properties":{"name":{"type":"string","description":"판매 상품의 식별 정보"},"price":{"type":"number","description":"판매 상품의 판매 가격 (USD: 1.xx 두자리수 허용)\nUSD 가격 정책\n- 최소: 0.01\n- 최대: 999,999"}}},"description":"결제 상품 정보"},"orderId":{"type":"string","description":"PG 측 거래에 대한 ID 정보"},"storeId":{"type":"string","description":"PG 측이 제공하는 가맹점 ID"},"requestId":{"type":"string","description":"PG 측 Transaction 요청에 대한 고유 식별자"},"returnUrl":{"type":"string","description":"결제 완료 후 복귀 페이지\nreturnUrl?transactionId=<Unifi Pay 측 생성 ID>"},"callbackUrl":{"type":"string","description":"결제 완료 후 Unifi Pay에서 결과 전송 시 PG 측 수신 받는 주소 "},"countryCode":{"type":"string","description":"3글자 국가코드 (ISO Alpha-3 Country Code)"},"orderCurrencyCode":{"type":"string","description":"화폐 코드 (ISO 4217)\n\"USD\"로 고정"}}}}},"required":true,"description":""}}}}}
```

## 결제 상태 확인

> 결제 상태 확인 API입니다.

```json
{"openapi":"3.1.0","info":{"title":"Api-fiddle Bookstore Example","version":"1.0.0"},"tags":[{"name":"payment"}],"security":[{"X-Authorization-Hmac":[]}],"components":{"securitySchemes":{"X-Authorization-Hmac":{"in":"header","name":"X-Authorization-Hmac","type":"apiKey","description":"HMAC 생성 방식: BASE64( HMACSHA256(appSecret, {HTTP_METHOD}{URI}{X-API-Key}{X-Timestamp}{REQUEST_BODY}) )\n- 아래 서명값 대상을 문자열로 합쳐 PG사 측에 사전 발급된 appSecret으로 SHA256으로 서명값 생성\n서명값 대상\n- HTTP_METHOD: 요청시 지정한 대문자 HTTP Method (ex: GET, POST, PUT 등)\n- URI: 요청한 URI (ex: /api/v1/payment)\n- HEADER: 요청 header 중 아래 값 포함\n-     X-API-Key: PG사 측에 사전 발급된 api key (ex: X-API-Key: \"f3248c3e-881c-42bd-abe7-1232023fe896\") \n-     X-Timestamp: 요청시 밀리초단위 timestamp 값 (ex: X-Timestamp: 1773017787000) 단, 현재 시각과 5분 이상 차이가 나면 요청 거부\n- REQUESET_BODY: 요청시 request body"}},"parameters":{"transactionId":{"in":"path","name":"transactionId","schema":{"type":"string"},"required":true}}},"paths":{"/api/v1/payment/{transactionId}":{"get":{"tags":["payment"],"summary":"결제 상태 확인","responses":{"200":{"content":{"application/json":{"schema":{"type":"object","title":"결제상태확인Ok","required":["transactionId","orderId","storeId","status","items","orderCurrencyCode","orderAmount","payAmount","discountAmount","payCurrencyCode"],"properties":{"items":{"type":"array","items":{"type":"object","required":["name","price"],"properties":{"name":{"type":"string","description":"판매 상품의 식별 정보"},"price":{"type":"number","description":"판매 상품의 판매 가격 (USD: 1.xx 두자리수 허용)\nUSD 가격 정책\n- 최소: 0.01\n- 최대: 999,999"}}}},"status":{"type":"string","description":"결제 상태값\n- CONFIRMED\n- FAILED"},"orderId":{"type":"string","description":"PG 측 거래에 대한 ID 정보"},"storeId":{"type":"string","description":"PG 측이 제공하는 가맹점 ID"},"payAmount":{"type":"number","description":"실제 결제된 수량"},"orderAmount":{"type":"string","description":"주문한 수량"},"transactionId":{"type":"string","description":"Unifi Pay에서 생성한 거래 번호"},"discountAmount":{"type":"number","description":"할인된 수량"},"payCurrencyCode":{"type":"string","description":"\"USD\"로 고정"},"orderCurrencyCode":{"type":"string","description":"화폐 코드 (ISO 4217)\n\"USD\"로 고정"}}}}},"description":"The request was successful, and the server has returned the requested resource in the response body."}},"parameters":[{"$ref":"#/components/parameters/transactionId"},{"in":"header","name":"X-AppId","style":"simple","schema":{"type":"string"},"explode":false,"required":true,"description":"PG사에 사전 발급된 appId","allowReserved":false},{"in":"header","name":"X-Timestamp","style":"simple","schema":{"type":"string"},"explode":false,"required":true,"description":"요청 시 밀리초단위 timestamp 값","allowReserved":false}],"description":"결제 상태 확인 API입니다.","operationId":"결제상태확인"}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.unifi.me/unifi-pay/payment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
