@sellosh/commerce 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AuthProviders, AuthResult, AuthUser, CartItemInput, ConfirmTossInput, ConfirmTossResult, MetaConfig, Order, OrderWithItems, PaymentConfig, ProductDetailResult, ProductListResult, ProfileInput, ReviewListParams, ReviewListResult } from "./types";
1
+ import type { AuthProviders, AuthResult, AuthUser, CartItemInput, ConfirmTossInput, ConfirmTossResult, CouponPreview, MetaConfig, Order, OrderWithItems, PaymentConfig, ProductDetailResult, ProductListResult, ProfileInput, ReviewListParams, ReviewListResult } from "./types";
2
2
  export interface SelloClientConfig {
3
3
  /** API 베이스 URL. "" = 동일 출처(프록시/리라이트). 예: "https://www.sello.sh" */
4
4
  apiBase?: string;
@@ -12,6 +12,12 @@ export interface CreateOrderInput {
12
12
  customer_name: string;
13
13
  phone: string;
14
14
  address: string;
15
+ couponCode?: string;
16
+ }
17
+ export interface ValidateCouponInput {
18
+ code: string;
19
+ items: CartItemInput[];
20
+ businessSlug?: string;
15
21
  }
16
22
  export interface SelloClient {
17
23
  readonly businessSlug: string | null;
@@ -43,6 +49,8 @@ export interface SelloClient {
43
49
  status: string;
44
50
  };
45
51
  }>;
52
+ /** 쿠폰 적용 미리보기 (읽기 전용 — 사용횟수 차감 없음). 서버가 상품합계 재계산 후 할인 산출. */
53
+ validateCoupon(input: ValidateCouponInput): Promise<CouponPreview>;
46
54
  register(input: {
47
55
  slug: string;
48
56
  email: string;
package/dist/client.js CHANGED
@@ -43,6 +43,14 @@ export function createSelloClient(config = {}) {
43
43
  }),
44
44
  claimOrder: (id, guestToken) => req(`/api/frontend/orders/${id}/claim`, { method: "POST", body: JSON.stringify({ guestToken }) }, true),
45
45
  createOrder: (input) => req(`/api/frontend/orders`, { method: "POST", body: JSON.stringify(input) }, true),
46
+ validateCoupon: (input) => req(`/api/frontend/coupons/validate`, {
47
+ method: "POST",
48
+ body: JSON.stringify({
49
+ code: input.code,
50
+ items: input.items,
51
+ businessSlug: requireSlug(input.businessSlug),
52
+ }),
53
+ }, true),
46
54
  register: (input) => req(`/api/frontend/auth/register`, {
47
55
  method: "POST",
48
56
  body: JSON.stringify(input),
package/dist/draft.d.ts CHANGED
@@ -7,6 +7,8 @@ export interface CheckoutDraft {
7
7
  email?: string | null;
8
8
  amount: number;
9
9
  businessSlug?: string;
10
+ /** 적용한 쿠폰 코드(선택) — 승인 페이지가 confirm 호출 시 그대로 전달, 서버가 재검증 */
11
+ couponCode?: string;
10
12
  /** 바로구매(단품) 주문 — true 면 결제 성공 후 장바구니를 비우지 않는다(카트 보존) */
11
13
  instant?: boolean;
12
14
  }
package/dist/types.d.ts CHANGED
@@ -61,6 +61,8 @@ export interface Order {
61
61
  id: number;
62
62
  status: OrderStatus | string;
63
63
  total: number;
64
+ discount_amount?: number;
65
+ coupon_code?: string | null;
64
66
  customer_name?: string;
65
67
  phone?: string;
66
68
  address?: string;
@@ -105,7 +107,7 @@ export interface PaymentConfig {
105
107
  provider: string;
106
108
  tossClientKey: string;
107
109
  }
108
- /** 토스 결제 승인 입력 — 서버가 buildOrder 로 가격·재고 재검증 후 total === amount 확인. */
110
+ /** 토스 결제 승인 입력 — 서버가 buildOrder 로 가격·재고 재검증 후 (할인 적용)finalTotal === amount 확인. */
109
111
  export interface ConfirmTossInput {
110
112
  paymentKey: string;
111
113
  orderId: string;
@@ -116,6 +118,18 @@ export interface ConfirmTossInput {
116
118
  address: string;
117
119
  email?: string;
118
120
  businessSlug?: string;
121
+ couponCode?: string;
122
+ }
123
+ /** 쿠폰 적용 미리보기 — 서버가 상품합계를 재계산해 산출. valid=false 면 error 에 사유. */
124
+ export interface CouponPreview {
125
+ valid: boolean;
126
+ error?: string;
127
+ code?: string;
128
+ discount_type?: "percent" | "fixed";
129
+ discount_value?: number;
130
+ discount?: number;
131
+ subtotal: number;
132
+ finalTotal?: number;
119
133
  }
120
134
  export interface ConfirmTossResult {
121
135
  order: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellosh/commerce",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Sello 커머스 SDK — 모든 스토어프론트(손코딩/AI생성)가 공유하는 타입드 클라이언트 + React 훅. 결제·재고·인증의 안전 경계를 한 곳에 둔다.",