# 취소 처리하기

취소는 **주문 배송이 시작하기 전에 주문을 무효화하는 것**입니다. 구매자, 판매자 둘 다 취소를 요청할 수 있어요.

1. [구매자의 취소 요청 처리하기](#undefined)
2. [직접 주문 취소하기](#undefined-7)

## 구매자의 취소 요청

<figure><img src="/files/6bxXXAUSfxORMYs6Ok08" alt=""><figcaption></figcaption></figure>

구매자는 주문 상품이 '결제완료', '상품준비중', '발송지연' 상태일 때 토스앱에서 취소를 요청할 수 있어요.

'결제완료' 상태에서 구매자가 취소를 요청하면 주문 상태는 즉시 '결제취소'로 변경되고 구매자는 주문금액을 환불받습니다. 판매자는 별도로 **API를 호출하지 않아도 돼요. 이 경우는 클레임으로 잡히지 않습니다.**

'발송지연' 또는 '상품준비중' 상태에서 구매자가 취소를 요청하면 토스쇼핑 API로 **승인 또는 거절을** 할 수 있어요. 승인하면 환불과 함께 결제 취소 상태가 되고, 거절하면 주문이 바로 배송중 상태로 바뀌어요.

### 구매자의 취소 요청 승인 및 거절하기

'발송지연' 또는 '상품준비중' 상태에서 구매자가 요청한 취소를 승인 및 거절하는 방법을 알아볼게요.

{% stepper %}
{% step %}

### 취소 요청 확인하기

[클레임 목록 조회 API](/dev/api-2/claim.md#get-api-v3-shopping-fep-claims)로 취소 요청을 확인해주세요.  `type` 쿼리 파라미터를 `CANCEL`로 설정해주세요. `status` 쿼리 파라미터는 항상 `REQUESTED`로 설정해주세요. '요청' 상태인 취소 클레임을 불러옵니다.

**GET** `/api/v3/shopping-fep/claims?type={claimType}&status={claimStatus}'`

```bash
  curl --request GET \
  --url 'https://shopping-fep.toss.im/api/v3/shopping-fep/claims?type=CANCEL&status=REQUESTED' \
  --header 'Authorization: Bearer {ACCESS_TOKEN}' \
  --header 'Content-Type: application/json'
```

{% endstep %}

{% step %}

### 클레임 ID로 취소 요청 승인/거절하기

응답의 `success` 필드 안에 `items.id`는 해당 클레임 요청의 유니크한 ID 값입니다. [취소 요청 승인](/dev/api-2/claim.md#post-api-v3-shopping-fep-claims-claimid-cancel-approval)과 [취소 요청 거절](/dev/api-2/claim.md#post-api-v3-shopping-fep-claims-claimid-cancel-rejection) API의 쿼리 파라미터로 사용해주세요.

* 취소 요청을 **승인**하려면 클레임 ID Path 파라미터만 채워서 API를 호출해주세요.\
  **POST** `/api/v3/shopping-fep/claims/{claimId}/cancel/approval`
* 취소 요청을 **거절**하려면 클레임 ID Path 파라미터와 택배사 및 송장번호 요청 파라미터를 추가해서 API를 호출해주세요.\
  **POST** `/api/v3/shopping-fep/claims/{claimId}/cancel/rejection`

{% tabs %}
{% tab title="취소 승인 예시" %}

```bash
  curl --request POST \
  --url 'https://shopping-fep.toss.im/api/v3/shopping-fep/claims/145523/cancel/approval
  --header 'Authorization: Bearer {ACCESS_TOKEN}' \
  --header 'Content-Type: application/json'
```

{% endtab %}

{% tab title="취소 거절 예시" %}

```bash
  curl --request POST \
  --url 'https://shopping-fep.toss.im/api-internal/v1/orders/claims/145523/cancel/rejection
  --header 'Authorization: Bearer {ACCESS_TOKEN}' \
  --header 'Content-Type: application/json'
  --data '{"deliveryCompany":"CJ대한통운", "shippingTrackingNumber":"1022-5765-4265"}
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### 결제 취소 완료하기

요청이 성공적이면 HTTP 200과 아래 응답이 돌아옵니다.

```json
{
  "resultType":"SUCCESS",
  "success": {}
}
```

**취소를 승인했을 때**

* 클레임 상태가 `APPROVED`로 변경됩니다.
* 구매자에게 자동으로 주문금액이 환불됩니다.
* 주문상품 상태가 `결제취소`로 변경됩니다.

**취소를 거절했을 때**

* 클레임 상태가 `REJECTED`로 변경됩니다.
* 주문상품 상태가 `배송중`으로 변경됩니다.
* 배송정보(배송회사, 송장번호)가 등록됩니다.
  {% endstep %}
  {% endstepper %}

## 직접 주문 취소하기

판매자가 직접 주문을 취소할 수도 있어요. 판매자는 결제완료, 상품준비중, 발송지연, 배송중, 배송완료 상태의 주문을 취소할 수 있습니다.

* 판매자가 요청한 취소의  주문 상태는 즉시 '결제취소'로 바뀌어요
* 클레임 진행 중인 주문도 취소가 가능하며, 취소 후 마찬가지로 '결제취소' 상태로 바뀝니다.
* 이 경우 클레임으로 잡히지 않습니다.

{% stepper %}
{% step %}

### 주문내역 조회하기

[주문 내역 조회 API](/dev/api-2/order.md#get-api-v3-shopping-fep-orders-v2)로 취소하고 싶은 주문의 ID(`orderProductId`)를 확인해주세요.

**GET** `/api/v3/shopping-fep/orders/v2?startDate={yyyy-MM-dd}&endDate={yyyy-MM-dd}'`&#x20;

```bash
  curl --request GET \
  --url 'https://shopping-fep.toss.im/api/v3/shopping-fep/orders/v2?startDate={yyyy-MM-dd}&endDate={yyyy-MM-dd}' \
  --header 'Authorization: Bearer {ACCESS_TOKEN}' \
  --header 'Content-Type: application/json'
```

{% endstep %}

{% step %}

### 주문 ID로 취소하기

응답의 `success` 필드 안에 `results.orderProductId`를 [판매자 주문 취소 API](/dev/api-2/claim.md#post-api-v3-shopping-fep-order-products-orderproductid-seller-cancel)의 Path 파라미터로 사용해주세요. 요청 파라미터에는 배송비 부담하는 책임자와 취소 사유를 입력해주세요.

**POST** `/api/v3/shopping-fep/order-products/{orderProductId}/seller-cancel`

```bash
  curl --request POST \
  --url 'https://shopping-fep.toss.im/api/v3/shopping-fep/order-products/{orderProductId}/seller-cancel' \
  --header 'Authorization: Bearer {ACCESS_TOKEN}' \
  --header 'Content-Type: application/json'
  --body {"deliveryPenaltyCharger":"USER", "reason":"주문 취소 사유"}
```

{% endstep %}

{% step %}

### 취소 완료하기

요청이 성공적이면 HTTP 200과 아래 응답이 돌아옵니다.

```json
{
  "resultType":"SUCCESS",
  "success": {}
}
```

* 주문금액이 구매자에게 자동으로 환불됩니다.
* 주문상품 상태가 '결제취소'로 변경됩니다.
  {% endstep %}
  {% endstepper %}

> ### API 연동 중 문의사항이나 개선 제안이 있으신가요?

{% hint style="info" %}
토스쇼핑 API 연동에 대한 질문이나, 건의사항이 있다면 [연동/개발 문의](https://discord.gg/xPz6H9NZ3P)에 남겨주세요. 다른 유저의 문의를 참고하거나, 토스쇼핑 담당자와 질의를 주고 받을 수 있어요.
{% endhint %}


---

# 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://shopping-docs.toss.im/dev/api-1/claim/cancel.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.
