Skip to content

KDS Order API

주방 디스플레이 시스템(KDS)의 주문을 조회하고, 주문 상태 변경 이벤트를 수신하는 API예요.

Types

PluginKdsOrderItem

KDS 주문 항목을 나타내는 객체예요.

ts
{
  id: string;                                    // KDS 주문 항목 ID
  state: PluginKdsOrderItemState;                // KDS 주문 상태
  order: PluginOrder;                            // 주문 정보
  lineItems: PluginKdsLineItem[];                // 주문 메뉴 목록
  diningOption: 'HERE' | 'TOGO' | 'DELIVERY' | 'PICKUP';  // 주문 방식
  totalQuantity: number;                         // 총 수량
  orderRequestType: PluginKdsOrderRequestType;   // 주문 요청 유형
  cancelledAt: string;                           // 취소 시간
  completedAt: string;                           // 완료 시간
  createdAt: string;                             // 생성 시간
  updatedAt: string;                             // 수정 시간
}
NameTypeOptionalDescriptionExample
idstringfalseKDS 주문 항목 ID'kds-1'
statePluginKdsOrderItemStatefalseKDS 주문 상태'OPENED'
orderPluginOrderfalse원본 주문 정보
lineItemsPluginKdsLineItem[]falseKDS 주문의 메뉴 목록
diningOption'HERE' | 'TOGO' | 'DELIVERY' | 'PICKUP'false주문 방식'HERE'
totalQuantitynumberfalse총 주문 수량3
orderRequestTypePluginKdsOrderRequestTypefalse주문 요청 유형'NEW'
cancelledAtstringfalse취소 시간'2025-01-01T00:00:00'
completedAtstringfalse완료 시간'2025-01-01T00:00:00'
createdAtstringfalse생성 시간'2025-01-01T00:00:00'
updatedAtstringfalse수정 시간'2025-01-01T00:00:00'

PluginKdsOrderItemState

KDS 주문 항목의 상태예요.

설명
OPENED진행 중 (주방에서 처리 대기 또는 처리 중)
COMPLETED완료 (조리 완료)
CANCELLED취소

PluginKdsOrderRequestType

KDS 주문의 요청 유형이에요.

설명
NEW신규 주문
ADDED추가 주문
CHANGED변경된 주문
CANCELLED취소된 주문
MERGED합석/병합된 주문

PluginKdsLineItem

KDS 주문 항목의 개별 메뉴 정보예요.

ts
{
  id: string;                             // 메뉴 항목 ID
  itemId: string;                         // 상품 ID
  title: string;                          // 상품명
  diningOption: 'HERE' | 'TOGO' | 'DELIVERY' | 'PICKUP';  // 주문 방식
  memo: string;                           // 메모
  optionChoices: PluginOrderItemOptionChoice[];  // 선택된 옵션
  orderPrice: {
    orderDiscountValue: number;           // 할인 금액
    orderListPriceValue: number;          // 정가
    orderPriceValue: number;              // 실제 결제 금액
  };
  quantity: {
    previous: number;                     // 이전 수량
    current: number;                      // 현재 수량
  };
  appliedDiscounts: PluginDiscount[];     // 적용된 할인 목록
  item: {
    id: number;                           // 상품 ID
    category: {
      id: number;                         // 카테고리 ID
      order: number;                      // 카테고리 순서
    };
  };
  createdAt: string;                      // 생성 시간
  updatedAt: string;                      // 수정 시간
}
NameTypeOptionalDescriptionExample
idstringfalse메뉴 항목 ID'line-1'
itemIdstringfalse상품 ID'item-1'
titlestringfalse상품명'아메리카노'
diningOption'HERE' | 'TOGO' | 'DELIVERY' | 'PICKUP'false주문 방식'HERE'
memostringfalse메뉴 메모'샷 추가'
optionChoicesPluginOrderItemOptionChoice[]false선택된 옵션
orderPrice.orderDiscountValuenumberfalse할인 금액1000
orderPrice.orderListPriceValuenumberfalse정가5000
orderPrice.orderPriceValuenumberfalse실제 결제 금액4000
quantity.previousnumberfalse이전 수량 (변경 전)1
quantity.currentnumberfalse현재 수량2
appliedDiscountsPluginDiscount[]false적용된 할인 목록
item.idnumberfalse상품 ID1
item.category.idnumberfalse카테고리 ID10
item.category.ordernumberfalse카테고리 정렬 순서1
createdAtstringfalse생성 시간'2025-01-01T00:00:00'
updatedAtstringfalse수정 시간'2025-01-01T00:00:00'

Methods

on

KDS 주문 상태 변경 이벤트를 수신하기 위한 핸들러를 등록해요. 콜백은 KDS 주문 항목 ID(string)를 전달받아요.

open

KDS 주문이 새로 접수(오픈)되었을 때 실행돼요.

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

posPluginSdk.kdsOrder.on('open', (id: string) => {
  console.log('접수된 KDS 주문 ID:', id);
});

complete

KDS 주문이 완료(조리 완료)되었을 때 실행돼요.

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

posPluginSdk.kdsOrder.on('complete', (id: string) => {
  console.log('완료된 KDS 주문 ID:', id);
});

cancel

KDS 주문이 취소되었을 때 실행돼요.

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

posPluginSdk.kdsOrder.on('cancel', (id: string) => {
  console.log('취소된 KDS 주문 ID:', id);
});

getKdsOrderItems

KDS 주문 항목 목록을 조회해요. 상태, 주문 ID, 카테고리, 상품 등 다양한 조건으로 필터링할 수 있어요.

페이징은 결과의 lasttrue가 될 때까지 조회하면 완료돼요.

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

const result = await posPluginSdk.kdsOrder.getKdsOrderItems({
  page: 1,
  size: 20,
  states: ['OPENED'],
});

Parameters

파라미터타입필수설명
pagenumberO페이지 번호 (1부터 시작)
sizenumberO페이지당 결과 수
statesPluginKdsOrderItemState[]XKDS 주문 상태 필터. 지정하지 않으면 전체 상태 조회
orderIdsstring[]X특정 주문 ID 목록으로 필터링
categoryIdsnumber[]X특정 카테고리 ID 목록으로 필터링
itemIdsnumber[]X특정 상품 ID 목록으로 필터링

Response

필드타입설명
contentsPluginKdsOrderItem[]KDS 주문 항목 목록
lastboolean마지막 페이지 여부
totalElementsnumber전체 항목 수

사용 예시

KDS 주문 실시간 모니터링

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

posPluginSdk.kdsOrder.on('open', async (id: string) => {
  const result = await posPluginSdk.kdsOrder.getKdsOrderItems({
    page: 1,
    size: 20,
    states: ['OPENED'],
  });

  const kdsItem = result.contents.find((item) => item.id === id);
  if (kdsItem != null) {
    console.log('새 주문 접수:', kdsItem.lineItems.map((li) => li.title));
  }
});

진행 중인 KDS 주문 전체 조회

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

async function getAllOpenedKdsOrders() {
  const allItems = [];
  let page = 1;

  while (true) {
    const result = await posPluginSdk.kdsOrder.getKdsOrderItems({
      page,
      size: 20,
      states: ['OPENED'],
    });

    allItems.push(...result.contents);

    if (result.last) {
      break;
    }

    page++;
  }

  return allItems;
}