@sellosh/commerce 0.1.0 → 0.3.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, ShippingConfig, 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,12 +12,20 @@ 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;
18
24
  listProducts(slug?: string): Promise<ProductListResult>;
19
25
  getProduct(id: number, slug?: string): Promise<ProductDetailResult>;
20
26
  getPaymentConfig(slug?: string): Promise<PaymentConfig>;
27
+ /** 배송 설정 조회 (배송비 + 무료배송 기준). 최종 결제액은 서버가 재검증. */
28
+ getShippingConfig(slug?: string): Promise<ShippingConfig>;
21
29
  confirmTossPayment(input: ConfirmTossInput): Promise<ConfirmTossResult>;
22
30
  listOrders(): Promise<{
23
31
  orders: Order[];
@@ -43,6 +51,8 @@ export interface SelloClient {
43
51
  status: string;
44
52
  };
45
53
  }>;
54
+ /** 쿠폰 적용 미리보기 (읽기 전용 — 사용횟수 차감 없음). 서버가 상품합계 재계산 후 할인 산출. */
55
+ validateCoupon(input: ValidateCouponInput): Promise<CouponPreview>;
46
56
  register(input: {
47
57
  slug: string;
48
58
  email: string;
package/dist/client.js CHANGED
@@ -34,6 +34,7 @@ export function createSelloClient(config = {}) {
34
34
  listProducts: (slug) => req(`/api/frontend/products?business=${q(requireSlug(slug))}`),
35
35
  getProduct: (id, slug) => req(`/api/frontend/products/${id}?business=${q(requireSlug(slug))}`),
36
36
  getPaymentConfig: (slug) => req(`/api/frontend/payments/config?business=${q(requireSlug(slug))}`),
37
+ getShippingConfig: (slug) => req(`/api/frontend/shipping/config?business=${q(requireSlug(slug))}`),
37
38
  confirmTossPayment: (input) => req(`/api/frontend/payments/toss/confirm`, { method: "POST", body: JSON.stringify(input) }, true),
38
39
  listOrders: () => req(`/api/frontend/orders`, {}, true),
39
40
  getOrder: (id, opts) => req(`/api/frontend/orders/${id}${opts?.guestToken ? `?guestToken=${q(opts.guestToken)}` : ""}`, {}, true),
@@ -43,6 +44,14 @@ export function createSelloClient(config = {}) {
43
44
  }),
44
45
  claimOrder: (id, guestToken) => req(`/api/frontend/orders/${id}/claim`, { method: "POST", body: JSON.stringify({ guestToken }) }, true),
45
46
  createOrder: (input) => req(`/api/frontend/orders`, { method: "POST", body: JSON.stringify(input) }, true),
47
+ validateCoupon: (input) => req(`/api/frontend/coupons/validate`, {
48
+ method: "POST",
49
+ body: JSON.stringify({
50
+ code: input.code,
51
+ items: input.items,
52
+ businessSlug: requireSlug(input.businessSlug),
53
+ }),
54
+ }, true),
46
55
  register: (input) => req(`/api/frontend/auth/register`, {
47
56
  method: "POST",
48
57
  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,9 @@ 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;
66
+ shipping_fee?: number;
64
67
  customer_name?: string;
65
68
  phone?: string;
66
69
  address?: string;
@@ -105,7 +108,12 @@ export interface PaymentConfig {
105
108
  provider: string;
106
109
  tossClientKey: string;
107
110
  }
108
- /** 토스 결제 승인 입력 서버가 buildOrder 가격·재고 재검증 total === amount 확인. */
111
+ /** 공개 배송 설정스토어가 결제 배송비를 표시·합산. 최종액은 서버가 재검증. */
112
+ export interface ShippingConfig {
113
+ shippingFee: number;
114
+ freeShippingThreshold: number | null;
115
+ }
116
+ /** 토스 결제 승인 입력 — 서버가 buildOrder 로 가격·재고 재검증 후 (할인 적용)finalTotal === amount 확인. */
109
117
  export interface ConfirmTossInput {
110
118
  paymentKey: string;
111
119
  orderId: string;
@@ -116,6 +124,18 @@ export interface ConfirmTossInput {
116
124
  address: string;
117
125
  email?: string;
118
126
  businessSlug?: string;
127
+ couponCode?: string;
128
+ }
129
+ /** 쿠폰 적용 미리보기 — 서버가 상품합계를 재계산해 산출. valid=false 면 error 에 사유. */
130
+ export interface CouponPreview {
131
+ valid: boolean;
132
+ error?: string;
133
+ code?: string;
134
+ discount_type?: "percent" | "fixed";
135
+ discount_value?: number;
136
+ discount?: number;
137
+ subtotal: number;
138
+ finalTotal?: number;
119
139
  }
120
140
  export interface ConfirmTossResult {
121
141
  order: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellosh/commerce",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Sello 커머스 SDK — 모든 스토어프론트(손코딩/AI생성)가 공유하는 타입드 클라이언트 + React 훅. 결제·재고·인증의 안전 경계를 한 곳에 둔다.",