# 주문 상세

원문: https://commerce.bootpay.ai/api/orders/detail

> 주문번호(order_number)로 주문 하나를 조회합니다. 결제 결과 · 주문 상품 · 발주와 운송장 · 구독 계약이 함께 오고, order_id 로는 찾을 수 없습니다.

**주문번호(`order_number`)**로 단일 주문의 상세 정보를 조회합니다.

## API 엔드포인트

::: endpoint
method: GET
url: https://api.bootapi.com/v1/orders/:order_number
auth: [Basic Auth](https://commerce.bootpay.ai/api/server/authentication)
:::

::: warning order_id 가 아니라 order_number 입니다
URL 경로에는 [주문 목록](https://commerce.bootpay.ai/api/orders/list) 응답의 `order_number`(예: `25071182085082524116`)를 넣습니다. `order_id`(예: `68707c59b0eacea5cd974efd`)를 넣으면 `ORDER_NOT_FOUND`가 돌아옵니다.
:::

::: info 구매자 조회
`Bootpay-User-JWT` 또는 secretKey 인증의 `user_id`를 보내면 그 회원의 주문만 조회하고 `charge_key`는 응답에서 제외됩니다. 회원을 지정하지 않으면 가맹점 서버가 프로젝트 주문을 조회합니다. 필드·오류 전체는 [주문 API 원문](https://commerce.bootpay.ai/api/reference/v1/orders)을 확인합니다.
:::

## 요청 파라미터

::: parameters

| 파라미터 | 타입 | 필수 | 설명 |
|---------|------|------|------|
| order_number | String | Y | 주문번호 (URL 경로) |
| user_id | String | N | 구매자 조회에 사용할 회원 ID 또는 가맹점 회원 ID (쿼리) |

:::

## 코드 예제

::: code-group

```bash [cURL]
curl -X GET "https://api.bootapi.com/v1/orders/25071182085082524116" \
  -H "Authorization: Basic {base64(client_key:secret_key)}"
```

```javascript [Node.js]
import { BootpayCommerce } from '@bootpay/backend-js'

const commerce = new BootpayCommerce({
    client_key: 'your-commerce-client-key',
    secret_key: 'your-commerce-secret-key',
    mode: 'production'
})

const response = await commerce.order.detail('25071182085082524116')
console.log(response)
```

```python [Python]
from bootpay_backend import BootpayCommerce

commerce = BootpayCommerce(
    client_key='your-commerce-client-key',
    secret_key='your-commerce-secret-key',
    mode='production'
)

response = commerce.order.detail('25071182085082524116')
print(response)
```

```php [PHP]
use Bootpay\ServerPhp\BootpayCommerceApi;

$commerce = new BootpayCommerceApi("your-commerce-client-key", "your-commerce-secret-key");
$response = $commerce->order->detail('25071182085082524116');
print_r($response);
```

```java [Java]
import kr.co.bootpay.store.BootpayStore;
import kr.co.bootpay.store.model.request.TokenPayload;
import kr.co.bootpay.store.model.response.BootpayStoreResponse;

TokenPayload tp = new TokenPayload("your-commerce-client-key", "your-commerce-secret-key");
BootpayStore commerce = new BootpayStore(tp).withToken();

BootpayStoreResponse response = commerce.order.detail("25071182085082524116");
System.out.println(response);
```

```ruby [Ruby]
require 'bootpay'

commerce = BootpayStore::RestClient.new(client_key: 'your-commerce-client-key', secret_key: 'your-commerce-secret-key')
response = commerce.order_detail(
  order_number: '25071182085082524116'
)
puts response.data
```

```go [Go]
import "github.com/bootpay/backend-go/v2"

commerce := bootpay.NewCommerceAPI("your-commerce-client-key", "your-commerce-secret-key", nil, "production")
response, err := commerce.Order.Detail("25071182085082524116")
fmt.Println(response, err)
```

```csharp [.NET]
using Bootpay.Commerce;

var commerce = new BootpayCommerceApi("your-commerce-client-key", "your-commerce-secret-key");
var response = await commerce.OrderDetail("25071182085082524116");
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

:::

## 응답

#### 성공 응답

```json
{
  "order_name": "Professional 플랜",
  "order_number": "25071182085082524116",
  "request_id": "your-order-draft-id",
  "price": 29900,
  "tax_free_price": 0,
  "status": "payment_completed",
  "receipt_status": "receipt_success",
  "receipt_id": "68707c598bbe23d076af189c",
  "purchased_at": "2025-07-11T10:30:00Z",
  "user": {
    "user_id": "67e4b4425ec892162491d0ec",
    "name": "홍길동",
    "email": "user@example.com",
    "phone": "01012345678"
  },
  "result_data": {
    "receipt_id": "receipt_abc123",
    "method_name": "카드결제",
    "card_name": "삼성카드",
    "card_no": "9430-****-****-1234"
  },
  "products": [
    {
      "product_id": "67c95e64d01640bb9859c629",
      "name": "Professional 플랜",
      "quantity": 1,
      "price": 29900
    }
  ],
  "order_purchases": [
    {
      "order_purchase_id": "6870824fb0eacea5cd974f12",
      "order_purchase_number": "P25071182085082524116",
      "status": 4,
      "delivery_company_code": "CJGLS",
      "tracking_number": "620148310301",
      "d_ts": 3,
      "sent_at": "2025-07-12T09:10:00Z",
      "tracking_histories": [
        {
          "trakler_status": "in_transit",
          "delivery_tracking_status": 3,
          "location": "옥천HUB",
          "description": "간선상차 · CJ대한통운",
          "occurred_at": "2025-07-12T21:40:00Z",
          "source": "webhook"
        }
      ]
    }
  ],
  "created_at": "2025-07-11T10:25:00Z"
}
```

::: info 값이 없는 필드는 키가 빠집니다
응답은 값이 없는(`null`) 필드를 지우고 보냅니다. 예를 들어 배송 완료 전 발주에는 `delivered_at` 키가 없고, 구독이 아닌 주문에는 `order_subscriptions` 키가 없습니다.
:::

#### 에러 응답

HTTP 상태 코드(`404`)는 헤더로 오고, 본문에는 코드 이름이 문자열로 옵니다.

```json
{
  "error_code": "ORDER_NOT_FOUND",
  "message": "주문내역을 찾지 못했습니다."
}
```

## 응답 필드 설명

| 필드 | 타입 | 설명 |
|------|------|------|
| `order_name` | String | 주문명 |
| `order_number` | String | 주문 번호 |
| `request_id` | String | 주문서 요청 때 넘긴 가맹점 식별자 |
| `price` | Integer | 결제 금액 |
| `status` | String | 주문 상태 — 아래 표 참고 |
| `receipt_status` | String | 결제(영수증) 상태 — [커머스 Enum](https://commerce.bootpay.ai/api/reference/enum#결제영수증-상태-receipt_status) 참고 |
| `receipt_id` | String | 결제 영수증 ID |
| `purchased_at` | String | 결제 완료 시각 |
| `user` | Object | 구매자 정보 (`user_id`·`name`·`email`·`phone` 등) |
| `result_data` | Object | 결제 결과 상세 (카드사, 카드번호 등) |
| `products` | Array | 주문 상품 목록 |
| `order_purchases` | Array | 발주(배송) 목록 — 아래 표 참고. 배송이 없는 주문이면 빈 배열 |
| `order_subscriptions` | Array | 구독 계약 목록 (구독 주문인 경우만. 아니면 키가 없습니다) |
| `charge_key` | String | 수시결제 재결제 키. 회원을 지정하지 않은 가맹점 서버 조회에서만 올 수 있습니다. 서버에만 보관합니다 |

::: info `order_id` 는 상세 응답에 없습니다
주문 문서 ID(`order_id`)는 [주문 목록](https://commerce.bootpay.ai/api/orders/list) 응답에만 있습니다. 상세·웹훅에서는 `order_number` 로 주문을 맞춥니다.
:::

## 발주(배송) 필드

한 주문이 여러 건으로 나뉘어 나가면 `order_purchases`도 그만큼 늘어납니다. 운송장은 발주 단위입니다.

| 필드 | 타입 | 설명 |
|------|------|------|
| `order_purchase_id` | String | 발주 고유 ID |
| `order_purchase_number` | String | 발주 번호 |
| `status` | Integer | 발주 상태 — [커머스 Enum](https://commerce.bootpay.ai/api/reference/enum#발주-상태-status) 참고 |
| `delivery_company_code` | String | 택배사 코드 |
| `tracking_number` | String | 운송장 번호 |
| `d_ts` | Integer | 배송추적 상태 — [커머스 Enum](https://commerce.bootpay.ai/api/reference/enum#배송추적-상태-d_ts) 참고 |
| `sent_at` | String | 발송 처리 시각 |
| `delivered_at` | String | 배송 완료 시각 |
| `tracking_histories` | Array | 추적 단계 이력 (최신 순) |

::: info 발주 상태와 배송추적 상태는 다릅니다
`status`는 가맹점이 처리한 단계(발주 확인·발송 처리)고, `d_ts`는 택배사가 알려준 단계(집화·배송 완료)입니다.
운송장을 등록하기 전에는 `d_ts`가 `0`(추적 없음)입니다.
:::

::: tip 배송만 볼 거라면
운송장을 넣는 건 [발송처리](https://commerce.bootpay.ai/api/orders/shipping), 배송 단계만 읽는 건 [배송추적 조회](https://commerce.bootpay.ai/api/orders/tracking)입니다.
:::

## 결제(영수증) 상태 (`receipt_status`)

자주 쓰는 값만 추렸습니다. 전체 값은 [결제(영수증) 상태](https://commerce.bootpay.ai/api/reference/enum#결제영수증-상태-receipt_status)에 있습니다. 응답의 상태 값은 영문 enum 문자열입니다.

| 키 | 값 | 설명 |
|----|----|------|
| `receipt_ready` | `0` | 결제 준비 (미결제) |
| `receipt_success` | `1` | 결제 성공 |
| `receipt_issued` | `5` | 발행 완료 (가상계좌 등) |
| `receipt_cancelled` | `20` | 결제 취소 |
| `receipt_fail` | `-1` | 결제 실패 |

## 주문 상태 코드 (`status`)

| 키 | 값 | 설명 |
|----|----|------|
| `order_pending` | `0` | 주문 생성, 결제 대기 |
| `payment_pending` | `1` | 결제 진행 중 |
| `payment_completed` | `2` | 결제 완료 |
| `subscription_request_completed` | `3` | 구독 요청 완료 |
| `subscription_pending` | `4` | 구독 대기 |
| `payment_delayed` | `5` | 결제 지연 |
| `payment_confirm_ready` | `6` | 결제 승인 대기 |
| `purchase_confirmed` | `8` | 구매 확정 |
| `cancellation_completed` | `10` | 취소 완료 |
| `return_completed` | `11` | 반품 완료 |
| `exchange_completed` | `12` | 교환 완료 |
| `subscription_terminated` | `13` | 구독 종료 |
| `order_expired` | `-1` | 주문 만료 |
| `payment_failed` | `-2` | 결제 실패 |
| `payment_authorization_failed` | `-3` | 결제 승인 실패 |
| `subscription_error` | `-4` | 구독 오류 |
| `subscription_server_error` | `-5` | 구독 서버 오류 |
| `order_abandoned` | `-100` | 주문 포기 |

## 에러 코드

::: info 공통 에러
인증·권한 관련 에러는 [에러 코드표](https://commerce.bootpay.ai/api/reference/codes#커머스-api-인증-에러)를 참고합니다.
:::

::: error-codes

| 코드 | 메시지 | 대처 방법 |
|------|--------|-----------|
| `ORDER_NOT_FOUND` | 주문내역을 찾지 못했습니다. | order_number를 넣었는지 확인합니다 (order_id 아님) |
| `ORDER_DENIED` | 주문 정보를 조회할 권한이 없습니다. | API 인증 권한을 확인합니다 |

:::
