# 5. 결제정보 검증하기

{% hint style="warning" %}
**Deprecated**

이 문서는 더 이상 관리되지 않습니다.

[PortOne 개발자센터](https://developers.portone.io/)를 이용해주세요.
{% endhint %}

> **결제금액의 위변조 검증 이유**
>
> 결제 요청은 클라이언트 환경에서 이루어지기 때문에 별도의 검증을 하지 않으면 **클라이언트가 스크립트를 조작해 금액을 위 변조하여 결제를 요청**할 수 있습니다. 따라서 결제하고자 하는 상품의 금액과 실제로 결제된 금액을 반드시 검증해야 합니다.
>
> 예를 들어 420,000원짜리 상품을 결제할 때에는 `amount: 420000`으로 결제요청을 하게 되는데, 공격자가 스크립트를 조작하여 해당 속성을 실제 금액보다 낮은 값(예 `amount: 420`)으로 변조할 수 있습니다.
>
> 클라이언트에서의 스크립트 조작은 원천적으로 막을 수 없는 기술적 특징이 있기 때문에 **결제 전후로 서버에서 결제금액의 위변조 여부를 반드시 검증**해야 합니다.

운영중인 서버에서 클라이언트로 부터 전달 받은 결제 결과 데이터를 바탕으로 <mark style="color:red;">**결제금액 위변조 여부**</mark>를 검증하고 필요시 데이터베이스에 저장합니다. 결제 정보를 검증하는 과정은 크게 아래와 같은 단계로 진행합니다.

1. [백엔드 - 사전 검증](/docs/auth/guide/5/pre.md)
   * [**결제금액 사전등록 API**](/docs/api/api-1/api-5.md) 요청
2. [프론트엔드 - 결제 요청](/docs/auth/guide/3..md)
   * SDK `IMP.request_pay` 호출
3. [백엔드 - 사후 검증](/docs/auth/guide/5/post.md)
   1. 포트원 결제고유번호(**imp\_uid**), 가맹점 주문번호(**merchant\_uid**)를 프론트엔드로부터 수신
   2. 결제 상세내역 조회를 위해 포트원 [**결제 단건 조회 API** ](https://api.iamport.kr/#!/payments/getPaymentByImpUid)요청
   3. 응답받은 내용을 바탕으로 실 결제 금액과 결제요청금액(가맹점 자체 데이터베이스)을 비교


---

# 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://portone.gitbook.io/docs/auth/guide/5.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.
