> For the complete documentation index, see [llms.txt](https://minimanimo.gitbook.io/lumiere-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://minimanimo.gitbook.io/lumiere-api/undefined-3.md).

# 주문

## 장바구니 상품 재고 확인

<mark style="color:blue;">`GET`</mark> `/api/products/cart-items`

one or Array

#### Query Parameters

| Name                                        | Type     | Description |
| ------------------------------------------- | -------- | ----------- |
| productId<mark style="color:red;">\*</mark> | ObjectId | Product's   |

{% tabs %}
{% tab title="200: OK " %}

```javascript
[
    {
        "info": {
            "size": "163x131cm",
            "canvas": 100
        },
        "_id": "61a4debe4f5f6aa036bfec5f",
        "artist": {
            "_id": "61a4debe4f5f6aa036bfec5d",
            "name": "로키산맥"
        },
        "title": "파멸",
        "image": "/images/owner/1.jpg",
        "price": 469000,
        "inStock": true
    },
    {
        "info": {
            "size": "146x112cm",
            "canvas": 80
        },
        "_id": "61a58ed5eebb463c14eca0f9",
        "artist": {
            "_id": "61a4c82a2c1eaad2e0d0084c",
            "name": "안영희"
        },
        "title": "날갯짓",
        "image": "/images/bye/2.jpg",
        "price": 310000,
        "inStock": true
    },
    ...
]
```

{% endtab %}
{% endtabs %}

## 결제 예정 총 금액 확인

<mark style="color:blue;">`GET`</mark> `/api/products/total-price`

one or Array

#### Query Parameters

| Name                                        | Type     | Description |
| ------------------------------------------- | -------- | ----------- |
| productId<mark style="color:red;">\*</mark> | ObjectId | Product's   |

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "_id": "결제 예정 총 금액",
    "totalPrice": 898000
}
```

{% endtab %}
{% endtabs %}

## 결제 전 주문 생성

<mark style="color:green;">`POST`</mark> `/api/orders`

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| authorization<mark style="color:red;">\*</mark> | String | Bearer Token     |
| Content-type<mark style="color:red;">\*</mark>  | String | application/json |

#### Request Body

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| orderItems<mark style="color:red;">\*</mark>    | Array  | product, image, title, artist, size, price     |
| result<mark style="color:red;">\*</mark>        | Object | id                                             |
| deliveryInfo<mark style="color:red;">\*</mark>  | Object | address, detailedAddress, receiver, contactNum |
| ordererInfo<mark style="color:red;">\*</mark>   | Object | name, phoneNum, email, refundTerms             |
| shippingPrice<mark style="color:red;">\*</mark> | Number |                                                |
| totalPrice<mark style="color:red;">\*</mark>    | Number |                                                |
| deliveryDetails                                 | Object | receiveAt, requestedTerms                      |

{% tabs %}
{% tab title="201: Created " %}

```javascript
{
    "message": "주문서 생성 성공",
    "orderId": "61a7adc903b7708e5dbba693"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "message": "주문할 상품 목록이 없습니다"
}
```

{% endtab %}
{% endtabs %}

## 아임포트 결제 후 해당 주문서에 imp\_uid 추가

<mark style="color:purple;">`PATCH`</mark> `/api/orders/pay`

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| imp\_uid<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "message": "결제 성공"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "message": "금액 불일치, 위조된 결제 시도"
}
```

{% endtab %}
{% endtabs %}

## 해당 주문 취소 | 반품 신청

<mark style="color:red;">`DELETE`</mark> `/api/orders/:id`

#### Path Parameters

| Name                                 | Type     | Description |
| ------------------------------------ | -------- | ----------- |
| id<mark style="color:red;">\*</mark> | ObjectId | Order's     |

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| authorization<mark style="color:red;">\*</mark> | String | Bearer Token     |
| Content-type                                    | String | application/json |

#### Request Body

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| status | Number |             |

{% tabs %}
{% tab title="200: OK 취소 요청" %}

```javascript
{
    "message": "해당 주문의 결제 취소가 완료되었습니다"
}
```

{% endtab %}

{% tab title="200: OK 반품 요청" %}

```javascript
{
    "message": "해당 주문의 반품 요청이 완료되었습니다"
}
```

{% endtab %}

{% tab title="404: Not Found " %}

```javascript
{
    "message": "해당 주문내역이 존재하지 않습니다"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "message": "진행 단계를 알 수 없습니다"
}
```

{% endtab %}

{% tab title="200: OK 임시 주문서 취소" %}

```javascript
{
    "message": "결제 오류로 임시 주문서를 삭제했습니다"
}
```

{% endtab %}
{% endtabs %}

## 해당 주문 상세 확인

<mark style="color:blue;">`GET`</mark> `/api/orders/:id`

#### Path Parameters

| Name                                 | Type     | Description |
| ------------------------------------ | -------- | ----------- |
| id<mark style="color:red;">\*</mark> | ObjectId | Order's     |

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "result": {
        "id": "20211130111111",
        "paidAt": "2021-12-01T17:15:53.146Z",
        "status": 0,
        "updatedAt": "2021-12-01T17:15:53.146Z"
    },
    "deliveryInfo": {
        "address": "[12990] 경기 하남시 감북로 18 (감일동)",
        "detailedAddress": "강남으로 가자 8282",
        "receiver": "김로또",
        "contactNum": "010-7777-7777"
    },
    "deliveryDetails": {
        "receiveAt": "문 앞",
        "requestedTerms": "도착 시 꼭 문자주세요!!"
    },
    "ordererInfo": {
        "name": "남대문",
        "phoneNum": "010-4444-4444",
        "email": "a@test.com",
        "refundTerms": "품절 시 결제수단으로 환불"
    },
    "_id": "61a7adc903b7708e5dbba693",
    "user": "61a4e52b4f5f6aa036bfec61",
    "orderItems": [
        {
            "image": "/images/bye/1.jpg",
            "title": "잠식",
            "artist": "안영희",
            "size": "73x61cm(20호)",
            "price": 99000,
            "product": "61a4c895f59ea1b7a727a658"
        },
        {
            "image": "/images/owner/1.jpg",
            "title": "파멸",
            "artist": "로키산맥",
            "size": "163x131cm(100호)",
            "price": 469000,
            "product": "61a4debe4f5f6aa036bfec5f"
        }
    ],
    "shippingPrice": 10000,
    "totalPrice": 578000
}
```

{% endtab %}

{% tab title="404: Not Found " %}

```javascript
{
    "message": "해당 주문 내역이 없습니다"
}
```

{% endtab %}
{% endtabs %}

## 유저의 최근 주문 정보

<mark style="color:blue;">`GET`</mark> `/api/orders/latest`

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "deliveryInfo": {
        "address": "[18030] 서울특별시 서초구 서초대로 396 ",
        "detailedAddress": "강남빌딩 20층 (스파크플러스 강남2호점)",
        "receiver": "김로또",
        "contactNum": "010-7777-7777"
    },
    "deliveryDetails": {
        "receiveAt": "문 앞에 놓아주세요",
        "requestedTerms": "도착 시 문자주세요"
    },
    "ordererInfo": {
        "name": "남대문",
        "phoneNum": "010-4444-4444",
        "email": "a@test.com",
        "refundTerms": "품절 시 결제수단으로 환불"
    },
    "_id": "61b344023c5af7a153d19a71"
}
```

{% endtab %}

{% tab title="404: Not Found " %}

```javascript
{
    "message": "최근 주문 내역이 없습니다"
}
```

{% endtab %}
{% endtabs %}
