@sayren/store-sdk 0.55.0 → 0.56.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/index.d.mts CHANGED
@@ -3368,6 +3368,7 @@ export declare const orderCanceledWebhookEventDataSchema: z$1.ZodObject<{
3368
3368
  couponChargeAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
3369
3369
  couponChargeRefundAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
3370
3370
  pointRefundAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
3371
+ deductAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
3371
3372
  currency: z$1.ZodOptional<z$1.ZodString>;
3372
3373
  testPayment: z$1.ZodBoolean;
3373
3374
  }, z$1.core.$strip>;
@@ -3613,6 +3614,7 @@ export declare const orderCanceledWebhookEventSchema: z$1.ZodObject<{
3613
3614
  couponChargeAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
3614
3615
  couponChargeRefundAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
3615
3616
  pointRefundAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
3617
+ deductAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
3616
3618
  currency: z$1.ZodOptional<z$1.ZodString>;
3617
3619
  testPayment: z$1.ZodBoolean;
3618
3620
  }, z$1.core.$strip>;
@@ -4013,6 +4015,7 @@ export declare const webhookEventSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObjec
4013
4015
  couponChargeAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
4014
4016
  couponChargeRefundAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
4015
4017
  pointRefundAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
4018
+ deductAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
4016
4019
  currency: z$1.ZodOptional<z$1.ZodString>;
4017
4020
  testPayment: z$1.ZodBoolean;
4018
4021
  }, z$1.core.$strip>;
@@ -6176,8 +6179,8 @@ export declare const claimSchema: z$1.ZodObject<{
6176
6179
  }>;
6177
6180
  reasonDetail: z$1.ZodNullable<z$1.ZodString>;
6178
6181
  responsibility: z$1.ZodEnum<{
6179
- BUYER: "BUYER";
6180
6182
  SELLER: "SELLER";
6183
+ BUYER: "BUYER";
6181
6184
  }>;
6182
6185
  claimDeliveryFee: z$1.ZodNumber;
6183
6186
  expectedRefundAmount: z$1.ZodNullable<z$1.ZodNumber>;
@@ -6266,8 +6269,8 @@ export declare const claimDetailSchema: z$1.ZodObject<{
6266
6269
  }>;
6267
6270
  reasonDetail: z$1.ZodNullable<z$1.ZodString>;
6268
6271
  responsibility: z$1.ZodEnum<{
6269
- BUYER: "BUYER";
6270
6272
  SELLER: "SELLER";
6273
+ BUYER: "BUYER";
6271
6274
  }>;
6272
6275
  claimDeliveryFee: z$1.ZodNumber;
6273
6276
  expectedRefundAmount: z$1.ZodNullable<z$1.ZodNumber>;
@@ -6311,9 +6314,9 @@ export declare const claimDetailSchema: z$1.ZodObject<{
6311
6314
  WITHDRAWN: "WITHDRAWN";
6312
6315
  }>;
6313
6316
  actor: z$1.ZodEnum<{
6314
- SYSTEM: "SYSTEM";
6315
- BUYER: "BUYER";
6316
6317
  SELLER: "SELLER";
6318
+ BUYER: "BUYER";
6319
+ SYSTEM: "SYSTEM";
6317
6320
  }>;
6318
6321
  occurredAt: z$1.ZodString;
6319
6322
  }, z$1.core.$strip>>>;
@@ -7135,6 +7138,7 @@ export type OrderItemFlow = z$1.infer<typeof orderItemFlowSchema>;
7135
7138
  export declare const moveFlowStateRequestSchema: z$1.ZodObject<{
7136
7139
  to: z$1.ZodString;
7137
7140
  reason: z$1.ZodOptional<z$1.ZodString>;
7141
+ restock: z$1.ZodOptional<z$1.ZodBoolean>;
7138
7142
  }, z$1.core.$strip>;
7139
7143
  export type MoveFlowStateRequest = z$1.infer<typeof moveFlowStateRequestSchema>;
7140
7144
  export declare const flowRunStepSchema: z$1.ZodObject<{
@@ -9010,8 +9014,8 @@ export type ConsentAction = z$1.infer<typeof consentActionSchema>;
9010
9014
  * `RECONSENT` 약관 개정 재동의 · `MEMBER_UPDATE` 구매자가 직접 변경 · `SELLER` 셀러가 처리
9011
9015
  */
9012
9016
  export declare const consentSourceSchema: z$1.ZodEnum<{
9013
- SIGNUP: "SIGNUP";
9014
9017
  SELLER: "SELLER";
9018
+ SIGNUP: "SIGNUP";
9015
9019
  SOCIAL_SIGNUP: "SOCIAL_SIGNUP";
9016
9020
  DELEGATED: "DELEGATED";
9017
9021
  RECONSENT: "RECONSENT";
@@ -9033,8 +9037,8 @@ export declare const customerConsentSchema: z$1.ZodObject<{
9033
9037
  AGREED: "AGREED";
9034
9038
  }>;
9035
9039
  source: z$1.ZodEnum<{
9036
- SIGNUP: "SIGNUP";
9037
9040
  SELLER: "SELLER";
9041
+ SIGNUP: "SIGNUP";
9038
9042
  SOCIAL_SIGNUP: "SOCIAL_SIGNUP";
9039
9043
  DELEGATED: "DELEGATED";
9040
9044
  RECONSENT: "RECONSENT";
@@ -11139,6 +11143,12 @@ export declare const shippingOrderItemSchema: z$1.ZodObject<{
11139
11143
  dispatchedAt: z$1.ZodString;
11140
11144
  deliveredAt: z$1.ZodNullable<z$1.ZodString>;
11141
11145
  }, z$1.core.$strip>>;
11146
+ flowStep: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNullable<z$1.ZodObject<{
11147
+ key: z$1.ZodString;
11148
+ label: z$1.ZodString;
11149
+ acceptsConfirm: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
11150
+ acceptsDispatch: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
11151
+ }, z$1.core.$strip>>>>;
11142
11152
  }, z$1.core.$strip>;
11143
11153
  export type ShippingOrderItem = z$1.infer<typeof shippingOrderItemSchema>;
11144
11154
  export declare const shippingOrderItemPageSchema: z$1.ZodObject<{
@@ -11293,6 +11303,12 @@ export declare const shippingOrderItemPageSchema: z$1.ZodObject<{
11293
11303
  dispatchedAt: z$1.ZodString;
11294
11304
  deliveredAt: z$1.ZodNullable<z$1.ZodString>;
11295
11305
  }, z$1.core.$strip>>;
11306
+ flowStep: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNullable<z$1.ZodObject<{
11307
+ key: z$1.ZodString;
11308
+ label: z$1.ZodString;
11309
+ acceptsConfirm: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
11310
+ acceptsDispatch: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
11311
+ }, z$1.core.$strip>>>>;
11296
11312
  }, z$1.core.$strip>>;
11297
11313
  }, z$1.core.$strip>;
11298
11314
  export type ShippingOrderItemPage = z$1.infer<typeof shippingOrderItemPageSchema>;
@@ -11400,6 +11416,13 @@ export declare const cancelBySellerRequestSchema: z$1.ZodObject<{
11400
11416
  detail: z$1.ZodOptional<z$1.ZodString>;
11401
11417
  quantity: z$1.ZodOptional<z$1.ZodNumber>;
11402
11418
  holdRefund: z$1.ZodOptional<z$1.ZodBoolean>;
11419
+ responsibility: z$1.ZodOptional<z$1.ZodEnum<{
11420
+ SELLER: "SELLER";
11421
+ BUYER: "BUYER";
11422
+ }>>;
11423
+ deductAmount: z$1.ZodOptional<z$1.ZodNumber>;
11424
+ restock: z$1.ZodOptional<z$1.ZodBoolean>;
11425
+ reclaimPurchasePoints: z$1.ZodOptional<z$1.ZodBoolean>;
11403
11426
  }, z$1.core.$strip>;
11404
11427
  export type CancelBySellerRequest = z$1.infer<typeof cancelBySellerRequestSchema>;
11405
11428
  /**
@@ -11429,8 +11452,16 @@ export declare const cancelBySellerResultSchema: z$1.ZodObject<{
11429
11452
  pointRefundAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
11430
11453
  refundedAt: z$1.ZodString;
11431
11454
  refundHeld: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
11455
+ deductAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
11456
+ purchasePointReclaimedAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
11432
11457
  }, z$1.core.$strip>;
11433
11458
  export type CancelBySellerResult = z$1.infer<typeof cancelBySellerResultSchema>;
11459
+ /** `GET /v1/order-items/{orderItemId}/cancel-preview` 쿼리 — 금액에 영향을 주는 취소 입력(#301). 생략하면 취소의 기본값이다 */
11460
+ export interface SellerCancelPreviewQuery {
11461
+ quantity?: number;
11462
+ responsibility?: "SELLER" | "BUYER";
11463
+ deductAmount?: number;
11464
+ }
11434
11465
  /**
11435
11466
  * `GET /v1/order-items/{orderItemId}/cancel-preview` 응답(#115) — 판매자 취소를 하면 돌려줄 금액. 실제 취소와 같은 계산을
11436
11467
  * 쓰기 없이 돌린 결과다. 취소할 수 없는 주문상품은 취소와 같은 409다
@@ -11442,6 +11473,9 @@ export declare const sellerCancelPreviewSchema: z$1.ZodObject<{
11442
11473
  pointRefundAmount: z$1.ZodNumber;
11443
11474
  deliveryFeeRefundAmount: z$1.ZodNumber;
11444
11475
  deliveryFeeChargeAmount: z$1.ZodNumber;
11476
+ deductAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
11477
+ restockRequired: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
11478
+ purchasePointAmount: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
11445
11479
  }, z$1.core.$strip>;
11446
11480
  export type SellerCancelPreview = z$1.infer<typeof sellerCancelPreviewSchema>;
11447
11481
  /** `PUT /v1/order-items/{orderItemId}/memo` 응답 — 빈 문자열로 저장하면 메모가 지워져 `null`이다 */
@@ -13025,7 +13059,7 @@ export declare function pointExpiresAtOf(earnedAt: Date, days: number | null): D
13025
13059
  export declare const POINT_LOT_SOURCES: readonly ["REVIEW", "PURCHASE", "ADJUST", "REFUND_RESTORE", "OPENING", "COUPON"];
13026
13060
  export type PointLotSource = (typeof POINT_LOT_SOURCES)[number];
13027
13061
  /** 원장 항목 유형 */
13028
- export declare const POINT_ENTRY_TYPES: readonly ["EARN_REVIEW", "REVOKE_REVIEW", "EARN_PURCHASE", "USE_RESERVE", "USE_RELEASE", "REFUND_RESTORE", "EXPIRE", "ADJUST", "OPENING", "EARN_COUPON"];
13062
+ export declare const POINT_ENTRY_TYPES: readonly ["EARN_REVIEW", "REVOKE_REVIEW", "EARN_PURCHASE", "REVOKE_PURCHASE", "USE_RESERVE", "USE_RELEASE", "REFUND_RESTORE", "EXPIRE", "ADJUST", "OPENING", "EARN_COUPON"];
13029
13063
  export type PointEntryType = (typeof POINT_ENTRY_TYPES)[number];
13030
13064
  /** 상점 플랫폼 알림 — `REVIEW_REWARD_PAUSED` 리뷰 자동 적립이 멈춤 · `POINTS_AVAILABLE` 적립금 설정을 쓸 수 있음 */
13031
13065
  export declare const pointPolicyNoticeSchema: z$1.ZodNullable<z$1.ZodEnum<{
@@ -13094,6 +13128,7 @@ export declare const responsePointEntryTypeSchema: z$1.ZodUnion<readonly [z$1.Zo
13094
13128
  EARN_REVIEW: "EARN_REVIEW";
13095
13129
  REVOKE_REVIEW: "REVOKE_REVIEW";
13096
13130
  EARN_PURCHASE: "EARN_PURCHASE";
13131
+ REVOKE_PURCHASE: "REVOKE_PURCHASE";
13097
13132
  USE_RESERVE: "USE_RESERVE";
13098
13133
  USE_RELEASE: "USE_RELEASE";
13099
13134
  REFUND_RESTORE: "REFUND_RESTORE";
@@ -13110,6 +13145,7 @@ export declare const pointEntrySchema: z$1.ZodObject<{
13110
13145
  EARN_REVIEW: "EARN_REVIEW";
13111
13146
  REVOKE_REVIEW: "REVOKE_REVIEW";
13112
13147
  EARN_PURCHASE: "EARN_PURCHASE";
13148
+ REVOKE_PURCHASE: "REVOKE_PURCHASE";
13113
13149
  USE_RESERVE: "USE_RESERVE";
13114
13150
  USE_RELEASE: "USE_RELEASE";
13115
13151
  REFUND_RESTORE: "REFUND_RESTORE";
@@ -13196,6 +13232,7 @@ export declare const pointAdjustmentResultSchema: z$1.ZodObject<{
13196
13232
  EARN_REVIEW: "EARN_REVIEW";
13197
13233
  REVOKE_REVIEW: "REVOKE_REVIEW";
13198
13234
  EARN_PURCHASE: "EARN_PURCHASE";
13235
+ REVOKE_PURCHASE: "REVOKE_PURCHASE";
13199
13236
  USE_RESERVE: "USE_RESERVE";
13200
13237
  USE_RELEASE: "USE_RELEASE";
13201
13238
  REFUND_RESTORE: "REFUND_RESTORE";
@@ -20796,6 +20833,12 @@ export declare function createStoreClient(options: StoreClientOptions): {
20796
20833
  dispatchedAt: string;
20797
20834
  deliveredAt: string | null;
20798
20835
  } | null;
20836
+ flowStep: {
20837
+ key: string;
20838
+ label: string;
20839
+ acceptsConfirm: boolean;
20840
+ acceptsDispatch: boolean;
20841
+ } | null;
20799
20842
  stay?: {
20800
20843
  checkIn: string;
20801
20844
  checkOut: string;
@@ -20820,13 +20863,16 @@ export declare function createStoreClient(options: StoreClientOptions): {
20820
20863
  hold: (orderItemId: string, body: HoldOrderItemRequest) => Promise<void>;
20821
20864
  releaseHold: (orderItemId: string) => Promise<void>;
20822
20865
  /** 판매자 취소 미리보기(#115) — 취소하면 돌려줄 현금·적립금. 생략한 수량은 남은 수량 전체다 */
20823
- cancelPreview: (orderItemId: string, quantity?: number) => Promise<{
20866
+ cancelPreview: (orderItemId: string, query?: number | SellerCancelPreviewQuery) => Promise<{
20824
20867
  orderItemId: string;
20825
20868
  quantity: number;
20826
20869
  refundAmount: number;
20827
20870
  pointRefundAmount: number;
20828
20871
  deliveryFeeRefundAmount: number;
20829
20872
  deliveryFeeChargeAmount: number;
20873
+ deductAmount: number;
20874
+ restockRequired: boolean;
20875
+ purchasePointAmount: number;
20830
20876
  }>;
20831
20877
  cancelBySeller: (orderItemId: string, body: CancelBySellerRequest, idempotencyKey?: string) => Promise<{
20832
20878
  orderItemId: string;
@@ -20840,6 +20886,8 @@ export declare function createStoreClient(options: StoreClientOptions): {
20840
20886
  pointRefundAmount: number;
20841
20887
  refundedAt: string;
20842
20888
  refundHeld: boolean;
20889
+ deductAmount: number;
20890
+ purchasePointReclaimedAmount: number;
20843
20891
  }>;
20844
20892
  updateMemo: (orderItemId: string, memo: string) => Promise<void>;
20845
20893
  requestPurchaseDecision: (orderItemId: string) => Promise<void>;
@@ -21961,7 +22009,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
21961
22009
  quantity: number;
21962
22010
  reason: "CHANGE_OF_MIND" | "WRONG_ORDER" | "DEFECTIVE" | "WRONG_DELIVERY" | "DIFFERENT_FROM_PAGE" | "DELAY";
21963
22011
  reasonDetail: string | null;
21964
- responsibility: "BUYER" | "SELLER";
22012
+ responsibility: "SELLER" | "BUYER";
21965
22013
  claimDeliveryFee: number;
21966
22014
  expectedRefundAmount: number | null;
21967
22015
  expectedDeliveryFeeRefundAmount: number | null;
@@ -22001,7 +22049,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
22001
22049
  quantity: number;
22002
22050
  reason: "CHANGE_OF_MIND" | "WRONG_ORDER" | "DEFECTIVE" | "WRONG_DELIVERY" | "DIFFERENT_FROM_PAGE" | "DELAY";
22003
22051
  reasonDetail: string | null;
22004
- responsibility: "BUYER" | "SELLER";
22052
+ responsibility: "SELLER" | "BUYER";
22005
22053
  claimDeliveryFee: number;
22006
22054
  expectedRefundAmount: number | null;
22007
22055
  expectedDeliveryFeeRefundAmount: number | null;
@@ -22030,7 +22078,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
22030
22078
  } | null;
22031
22079
  histories?: {
22032
22080
  status: "REJECTED" | "COMPLETED" | "REQUESTED" | "HELD" | "COLLECTING" | "COLLECTED" | "REDELIVERING" | "APPROVED" | "WITHDRAWN";
22033
- actor: "SYSTEM" | "BUYER" | "SELLER";
22081
+ actor: "SELLER" | "BUYER" | "SYSTEM";
22034
22082
  occurredAt: string;
22035
22083
  }[] | undefined;
22036
22084
  }>;
@@ -22078,7 +22126,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
22078
22126
  quantity: number;
22079
22127
  reason: "CHANGE_OF_MIND" | "WRONG_ORDER" | "DEFECTIVE" | "WRONG_DELIVERY" | "DIFFERENT_FROM_PAGE" | "DELAY";
22080
22128
  reasonDetail: string | null;
22081
- responsibility: "BUYER" | "SELLER";
22129
+ responsibility: "SELLER" | "BUYER";
22082
22130
  claimDeliveryFee: number;
22083
22131
  expectedRefundAmount: number | null;
22084
22132
  expectedDeliveryFeeRefundAmount: number | null;
@@ -22566,7 +22614,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
22566
22614
  version: string | null;
22567
22615
  documentUrl: string | null;
22568
22616
  action: "WITHDRAWN" | "AGREED";
22569
- source: "SIGNUP" | "SELLER" | "SOCIAL_SIGNUP" | "DELEGATED" | "RECONSENT" | "MEMBER_UPDATE";
22617
+ source: "SELLER" | "SIGNUP" | "SOCIAL_SIGNUP" | "DELEGATED" | "RECONSENT" | "MEMBER_UPDATE";
22570
22618
  occurredAt: string;
22571
22619
  }[];
22572
22620
  }>;
@@ -23912,7 +23960,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
23912
23960
  updatedAt: string;
23913
23961
  } | null;
23914
23962
  }>;
23915
- /** `POST /v1/payments/refunds/{refundId}/process` — 대기 환불(`HELD`)을 PG로 환불한다(#115). 409 `REFUND_NOT_HELD` */
23963
+ /** `POST /v1/payments/refunds/{refundId}/process` — 대기(`HELD`)·실패(`FAILED`) 환불을 PG로 환불한다(#115, #301). 409 `REFUND_NOT_HELD` */
23916
23964
  processRefund: (refundId: string) => Promise<{
23917
23965
  refundId: string;
23918
23966
  amount: number;
package/dist/index.mjs CHANGED
@@ -4015,6 +4015,7 @@ const POINT_ENTRY_TYPES = [
4015
4015
  "EARN_REVIEW",
4016
4016
  "REVOKE_REVIEW",
4017
4017
  "EARN_PURCHASE",
4018
+ "REVOKE_PURCHASE",
4018
4019
  "USE_RESERVE",
4019
4020
  "USE_RELEASE",
4020
4021
  "REFUND_RESTORE",
@@ -4047,7 +4048,7 @@ const updatePointPolicyRequestSchema = strictRequest(z$1.object({
4047
4048
  expiryDays: expiryDays.optional()
4048
4049
  }));
4049
4050
  /** 응답의 원장 유형 — 값이 추가될 수 있어 문자열로 받는다 */
4050
- const responsePointEntryTypeSchema = z$1.union([z$1.enum(POINT_ENTRY_TYPES), z$1.string()]).describe("유형. `EARN_REVIEW` 리뷰 적립 · `REVOKE_REVIEW` 리뷰 삭제 회수 · `EARN_PURCHASE` 구매 적립 · `EXPIRE` 소멸 · `ADJUST` 셀러 지급·차감 · `OPENING` 기존 잔액 이전 · `USE_RESERVE` 결제 사용(결제 시작 때 빠짐) · `USE_RELEASE` 결제가 실패·만료되어 되돌림 · `REFUND_RESTORE` 취소·반품 환불로 반환 · `EARN_COUPON` 적립금 지급 쿠폰. 값이 추가될 수 있어 문자열로 받는다");
4051
+ const responsePointEntryTypeSchema = z$1.union([z$1.enum(POINT_ENTRY_TYPES), z$1.string()]).describe("유형. `EARN_REVIEW` 리뷰 적립 · `REVOKE_REVIEW` 리뷰 삭제 회수 · `EARN_PURCHASE` 구매 적립 · `REVOKE_PURCHASE` 판매자 취소의 구매 적립 회수 · `EXPIRE` 소멸 · `ADJUST` 셀러 지급·차감 · `OPENING` 기존 잔액 이전 · `USE_RESERVE` 결제 사용(결제 시작 때 빠짐) · `USE_RELEASE` 결제가 실패·만료되어 되돌림 · `REFUND_RESTORE` 취소·반품 환불로 반환 · `EARN_COUPON` 적립금 지급 쿠폰. 값이 추가될 수 있어 문자열로 받는다");
4051
4052
  /** 원장 항목 — 셀러 조회용(사유·행위자 포함) */
4052
4053
  const pointEntrySchema = z$1.object({
4053
4054
  entryId: z$1.string(),
@@ -4987,12 +4988,13 @@ const orderCanceledWebhookEventDataSchema = z$1.object({
4987
4988
  reason: z$1.string().describe("취소 사유 코드 — 판매자 취소 요청의 `reason`(`OUT_OF_STOCK`·`PRICE_ERROR`·`DELIVERY_IMPOSSIBLE`·`ETC`). 사유가 늘어날 수 있어 문자열이다. 모르는 값은 `ETC`처럼 다룬다"),
4988
4989
  quantity: z$1.number().int().describe("이번에 취소한 수량"),
4989
4990
  canceledQuantity: z$1.number().int().describe("취소 후 누적 취소 수량"),
4990
- refundAmount: z$1.number().int().describe("환불액 (원). 수량 비율 상품 실결제 금액(쿠폰 배분을 뺀 금액) + 배송비 환불 − 조건부 무료배송 미달 차감 + 되돌린 쿠폰 차감(`couponChargeRefundAmount`)이다. 결제사 환불 결과는 결제 내역(`GET /v1/payments/{paymentId}`)으로 확인한다"),
4991
+ refundAmount: z$1.number().int().describe("환불액 (원). 수량 비율 상품 실결제 금액(쿠폰 배분을 뺀 금액) + 배송비 환불 − 조건부 무료배송 미달 차감 − 쿠폰 조건 미달 차감 + 되돌린 쿠폰 차감(`couponChargeRefundAmount`) − 추가 차감(`deductAmount`)이다. 결제사 환불 결과는 결제 내역(`GET /v1/payments/{paymentId}`)으로 확인한다"),
4991
4992
  deliveryFeeRefundAmount: z$1.number().int().describe("환불액에 포함된 배송비 (원)"),
4992
4993
  deliveryFeeChargeAmount: z$1.number().int().describe("환불액에서 뺀 배송비 (원) — 조건부 무료배송 기준 미달 차감"),
4993
- couponChargeAmount: z$1.number().int().optional().default(0).describe("환불액에서 뺀 쿠폰 조건 미달 차감 (원). 판매자 취소는 차감하지 않으므로 늘 0이다. 이 필드가 없는 이전 이벤트는 0으로 읽는다"),
4994
+ couponChargeAmount: z$1.number().int().optional().default(0).describe("환불액에서 뺀 쿠폰 조건 미달 차감 (원). 판매자 귀책 취소는 차감하지 않으므로 0이고, 구매자 귀책(`responsibility: BUYER`)이면 생길 수 있다. 이 필드가 없는 이전 이벤트는 0으로 읽는다"),
4994
4995
  couponChargeRefundAmount: z$1.number().int().optional().default(0).describe("환불액에 더한 금액 (원) — 앞선 환불에서 뺀 쿠폰 조건 미달 차감을 되돌린 몫이다. 전량 취소면 누적 차감이 모두 되돌아간다. 이 필드가 없는 이전 이벤트는 0으로 읽는다"),
4995
4996
  pointRefundAmount: z$1.number().int().optional().default(0).describe("돌려준 적립금 (원, #93) — 결제에 쓴 적립금 중 이번 취소·반품 수량의 몫이다. 현금 환불(`refundAmount`)과 별개다. 차감은 현금에서 먼저 빼고 모자란 몫만 여기서 뺀다. 적립금을 쓰지 않은 주문과 이 필드가 없는 이전 응답·이벤트는 0으로 읽는다"),
4997
+ deductAmount: z$1.number().int().optional().default(0).describe("환불액에서 뺀 추가 차감 (원, #301) — 판매자가 취소 요청에 넣은 `deductAmount`다. 배송비 차감과 따로 싣는다. 이 필드가 없는 이전 이벤트는 0으로 읽는다"),
4996
4998
  currency: z$1.string().optional().describe("주문 통화(ISO 4217, 이슈 #130). 이 이벤트의 금액은 모두 이 통화의 최소 단위다. 외화 주문이 생기면 이 값을 확인한다. 이 필드가 없는 이전 이벤트는 KRW다"),
4997
4999
  testPayment: z$1.boolean().describe("테스트 결제(샌드박스 결제) 주문인가. true면 실제로 돈이 오가지 않았다")
4998
5000
  });
@@ -7214,13 +7216,14 @@ const orderItemFlowSchema = z$1.object({
7214
7216
  key: z$1.string(),
7215
7217
  label: z$1.string().describe("셀러용 상태 이름"),
7216
7218
  coreStatus: orderItemStatusSchema.nullable()
7217
- })).optional().describe("상태 직접 이동으로 옮길 수 있는 상태(셀러 보기). 흐름이 끝났으면 빈 배열"),
7219
+ })).optional().describe("상태 직접 이동으로 옮길 수 있는 상태(셀러 보기). 흐름이 끝났으면 빈 배열. `coreStatus`가 `CANCELED`인 상태로 옮기면 판매자 취소와 같이 환불한다(#301)"),
7218
7220
  branches: z$1.array(flowStateSchema).optional().describe("활성 위치가 둘 이상(병렬 가지·하위 흐름)이면 각 위치의 상태. `flowState`는 그 가운데 가장 앞 단계다")
7219
7221
  });
7220
7222
  /** 상태 직접 이동(#115) — 연결선을 지나지 않고 다른 상태로 옮긴다. 블록(재고·환불·송장)은 실행하지 않는다 */
7221
7223
  const moveFlowStateRequestSchema = strictRequest(z$1.object({
7222
7224
  to: z$1.string().min(1).describe("옮길 상태 키(`moveTargets[].key`)"),
7223
- reason: z$1.string().trim().max(200).optional().describe("옮긴 사유(실행 기록에 남는다)")
7225
+ reason: z$1.string().trim().max(200).optional().describe("옮긴 사유(실행 기록에 남는다)"),
7226
+ restock: z$1.boolean().optional().describe("취소 상태(`moveTargets[].coreStatus` `CANCELED`)로 옮길 때 재고를 되돌리는가(#301). 취소 상태로 옮기면 판매자 취소와 같이 환불한다. 발송 전은 생략하면 true, 발송 뒤는 생략하면 400 `RESTOCK_REQUIRED`다. 다른 상태로 옮길 때는 무시한다")
7224
7227
  }));
7225
7228
  const flowRunStepSchema = z$1.object({
7226
7229
  step: z$1.number().int(),
@@ -11178,7 +11181,13 @@ const shippingOrderItemSchema = orderItemSchema.extend({
11178
11181
  ordererName: z$1.string(),
11179
11182
  ordererPhone: z$1.string(),
11180
11183
  shippingAddress: shippingAddressSchema,
11181
- delivery: deliveryInfoSchema.nullable().describe("발송 정보. 발송 전이면 null")
11184
+ delivery: deliveryInfoSchema.nullable().describe("발송 정보. 발송 전이면 null"),
11185
+ flowStep: z$1.object({
11186
+ key: z$1.string().describe("주문 흐름 안 단계 키(상점이 정한다). 화면 분기에 쓰지 않는다"),
11187
+ label: z$1.string().describe("셀러용 단계 이름"),
11188
+ acceptsConfirm: z$1.boolean().optional().default(true).describe("이 단계가 발주 확인(`POST /v1/order-items/{orderItemId}/confirm`)을 받는가. 거짓이면 발주 확인은 409 `INVALID_STATUS`다. 연결선 조건식은 실행 때 다시 판정한다"),
11189
+ acceptsDispatch: z$1.boolean().optional().default(true).describe("이 단계가 발송(`POST /v1/order-items/{orderItemId}/dispatch`)을 받는가. 거짓이면 발송은 409 `INVALID_STATUS`다. 연결선 조건식은 실행 때 다시 판정한다")
11190
+ }).nullable().optional().default(null).describe("주문 흐름의 지금 단계(`GET /v1/order-items/{orderItemId}/flow`의 `flowState` 키·이름). 같은 상태라도 단계가 발송을 받지 않으면 발송은 409 `INVALID_STATUS`다(`acceptsConfirm`·`acceptsDispatch`). 흐름이 없으면 null. 서버는 항상 싣는다")
11182
11191
  });
11183
11192
  const shippingOrderItemPageSchema = pageSchema(shippingOrderItemSchema);
11184
11193
  /**
@@ -11245,7 +11254,11 @@ const cancelBySellerRequestSchema = strictRequest(z$1.object({
11245
11254
  ]),
11246
11255
  detail: z$1.string().max(500).optional(),
11247
11256
  quantity: z$1.number().int().min(1).optional().describe("취소할 수량. 생략하면 남은 수량 전체다. 남은 수량보다 크면 400 `INVALID_QUANTITY`. 일부만 취소하면 주문상품은 상태를 유지한 채 `canceledQuantity`가 늘고, 전 수량이 소진되면 `CANCELED`가 된다"),
11248
- holdRefund: z$1.boolean().optional().describe("true면 주문만 취소하고 결제 환불은 대기로 남긴다(#115). 정산·재고·적립금 반환은 그대로 하고, PG 환불은 결제 상세의 `POST /v1/payments/refunds/{refundId}/process`로 따로 한다. 생략하면 취소와 함께 환불한다")
11257
+ holdRefund: z$1.boolean().optional().describe("true면 주문만 취소하고 결제 환불은 대기로 남긴다(#115). 정산·재고·적립금 반환은 그대로 하고, PG 환불은 결제 상세의 `POST /v1/payments/refunds/{refundId}/process`로 따로 한다. 생략하면 취소와 함께 환불한다"),
11258
+ responsibility: z$1.enum(["SELLER", "BUYER"]).optional().describe("귀책(#301). 생략하면 `SELLER`다. `SELLER`면 배송비를 판매자가 부담하고(환불 정책 `sellerFaultFreeShipping`) 쿠폰 조건 미달 차감을 하지 않는다. `BUYER`면 클레임 승인의 구매자 귀책과 같은 규칙이다(발송 뒤에는 배송비를 돌려주지 않는다). 반품 배송비는 자동으로 빼지 않는다 — 필요하면 `deductAmount`로 뺀다"),
11259
+ deductAmount: z$1.number().int().min(0).optional().describe("환불액에서 뺄 추가 차감(#301, 원). 생략하면 0이다. 현금에서 먼저 빼고 모자란 몫만 돌려줄 적립금에서 뺀다. 환불 원장·`ORDER.CANCELED` 웹훅에 따로 남는다"),
11260
+ restock: z$1.boolean().optional().describe("재고를 되돌리는가(#301). 발송 전(결제완료·발주확인, 배송 없는 상품은 제공 완료까지)은 생략하면 true다. 그 뒤(발송·배송중·배송완료·구매확정)는 생략하면 400 `RESTOCK_REQUIRED`다 — 물건이 돌아왔는지는 판매자가 정한다"),
11261
+ reclaimPurchasePoints: z$1.boolean().optional().describe("구매확정 때 지급한 구매 적립금 중 이번 수량의 몫을 회수하는가(#301). 지급된 구매 적립금이 없으면 무시한다. 생략하면 회수하지 않는다. 회원 잔액이 모자라면 있는 만큼만 회수한다(리뷰 적립 회수와 같은 규칙)")
11249
11262
  }));
11250
11263
  /**
11251
11264
  * 제공 처리 요청 (이슈 #48) — `POST /v1/order-items/{orderItemId}/fulfill`. 배송 없는 주문상품(`MANUAL`)을
@@ -11260,16 +11273,18 @@ const fulfillBulkRequestSchema = strictRequest(z$1.object({
11260
11273
  /** `POST /v1/order-items/{orderItemId}/cancel` 응답 — 셀러 직권취소 환불 결과 */
11261
11274
  const cancelBySellerResultSchema = z$1.object({
11262
11275
  orderItemId: z$1.string(),
11263
- refundAmount: z$1.number().int().describe("실제 환불한 금액 — 수량 비율 상품 실결제 금액(쿠폰 배분을 뺀 금액) + 배송비 환불 − 조건부 무료배송 미달 차감 + 되돌린 쿠폰 차감(`couponChargeRefundAmount`)"),
11276
+ refundAmount: z$1.number().int().describe("실제 환불한 금액 — 수량 비율 상품 실결제 금액(쿠폰 배분을 뺀 금액) + 배송비 환불 − 조건부 무료배송 미달 차감 − 쿠폰 조건 미달 차감 + 되돌린 쿠폰 차감(`couponChargeRefundAmount`) − 추가 차감(`deductAmount`)"),
11264
11277
  quantity: z$1.number().int().describe("취소한 수량"),
11265
11278
  canceledQuantity: z$1.number().int().describe("취소 후 누적 취소 수량"),
11266
11279
  deliveryFeeRefundAmount: z$1.number().int().describe("환불에 포함된 배송비. 배송 묶음(같은 상품)이 모두 취소됐고 환불 정책이 켜져 있을 때만 0보다 크다"),
11267
11280
  deliveryFeeChargeAmount: z$1.number().int().describe("조건부 무료배송 기준 미달로 환불액에서 뺀 배송비. 정책이 꺼져 있으면 항상 0이다"),
11268
- couponChargeAmount: z$1.number().int().optional().default(0).describe("쿠폰 조건 미달 차감. 판매자 취소는 차감하지 않으므로 늘 0이다. 서버는 항상 싣는다"),
11281
+ couponChargeAmount: z$1.number().int().optional().default(0).describe("쿠폰 조건 미달 차감. 판매자 귀책 취소는 차감하지 않으므로 0이고, 구매자 귀책(`responsibility: BUYER`)이면 생길 수 있다. 서버는 항상 싣는다"),
11269
11282
  couponChargeRefundAmount: z$1.number().int().optional().default(0).describe("환불액에 더한, 앞선 환불에서 뺀 쿠폰 차감을 되돌린 몫. 서버는 항상 싣는다"),
11270
11283
  pointRefundAmount: z$1.number().int().optional().default(0).describe("돌려준 적립금 (원, #93) — 결제에 쓴 적립금 중 이번 취소·반품 수량의 몫이다. 현금 환불(`refundAmount`)과 별개다. 차감은 현금에서 먼저 빼고 모자란 몫만 여기서 뺀다. 적립금을 쓰지 않은 주문과 이 필드가 없는 이전 응답·이벤트는 0으로 읽는다"),
11271
11284
  refundedAt: z$1.string().describe("환불을 요청한 시각. `refundHeld`면 취소 시각이고 환불은 아직 하지 않았다"),
11272
- refundHeld: z$1.boolean().optional().default(false).describe("결제 환불을 대기로 남겼다(`holdRefund`). 결제 상세에서 환불 처리한다")
11285
+ refundHeld: z$1.boolean().optional().default(false).describe("결제 환불을 대기로 남겼다(`holdRefund`). 결제 상세에서 환불 처리한다"),
11286
+ deductAmount: z$1.number().int().optional().default(0).describe("환불액에서 뺀 추가 차감(#301). 서버는 항상 싣는다"),
11287
+ purchasePointReclaimedAmount: z$1.number().int().optional().default(0).describe("회수한 구매 적립금(#301, `reclaimPurchasePoints`). 잔액이 모자라면 요청한 몫보다 작다. 서버는 항상 싣는다")
11273
11288
  });
11274
11289
  /**
11275
11290
  * `GET /v1/order-items/{orderItemId}/cancel-preview` 응답(#115) — 판매자 취소를 하면 돌려줄 금액. 실제 취소와 같은 계산을
@@ -11281,7 +11296,10 @@ const sellerCancelPreviewSchema = z$1.object({
11281
11296
  refundAmount: z$1.number().int().describe("현금 환불 예정 금액(배송비 환불·차감 포함)"),
11282
11297
  pointRefundAmount: z$1.number().int().describe("돌려줄 적립금 (원)"),
11283
11298
  deliveryFeeRefundAmount: z$1.number().int().describe("환불에 포함될 배송비"),
11284
- deliveryFeeChargeAmount: z$1.number().int().describe("조건부 무료배송 기준 미달로 뺄 배송비")
11299
+ deliveryFeeChargeAmount: z$1.number().int().describe("조건부 무료배송 기준 미달로 뺄 배송비"),
11300
+ deductAmount: z$1.number().int().optional().default(0).describe("뺄 추가 차감(쿼리 `deductAmount`). 서버는 항상 싣는다"),
11301
+ restockRequired: z$1.boolean().optional().default(false).describe("취소 요청에 `restock`이 있어야 하는가(#301) — 발송 뒤 주문상품이면 true다. 서버는 항상 싣는다"),
11302
+ purchasePointAmount: z$1.number().int().optional().default(0).describe("이번 수량에서 회수할 수 있는 구매 적립금(#301). 0이면 회수할 것이 없다(`reclaimPurchasePoints`를 묻지 않는다). 서버는 항상 싣는다")
11285
11303
  });
11286
11304
  /** `PUT /v1/order-items/{orderItemId}/memo` 응답 — 빈 문자열로 저장하면 메모가 지워져 `null`이다 */
11287
11305
  const orderItemMemoResultSchema = z$1.object({
@@ -12190,7 +12208,10 @@ function createStoreClient(options) {
12190
12208
  hold: (orderItemId, body) => storeHttp.requestVoid("POST", path`/order-items/${orderItemId}/hold`, { body: holdOrderItemRequestSchema.parse(body) }),
12191
12209
  releaseHold: (orderItemId) => storeHttp.requestVoid("DELETE", path`/order-items/${orderItemId}/hold`),
12192
12210
  /** 판매자 취소 미리보기(#115) — 취소하면 돌려줄 현금·적립금. 생략한 수량은 남은 수량 전체다 */
12193
- cancelPreview: (orderItemId, quantity) => storeHttp.request("GET", path`/order-items/${orderItemId}/cancel-preview`, sellerCancelPreviewSchema, { query: quantity ? { quantity } : {} }),
12211
+ cancelPreview: (orderItemId, query) => {
12212
+ const params = typeof query === "number" ? { quantity: query } : query ?? {};
12213
+ return storeHttp.request("GET", path`/order-items/${orderItemId}/cancel-preview`, sellerCancelPreviewSchema, { query: Object.fromEntries(Object.entries(params).filter(([, value]) => value !== void 0 && value !== 0)) });
12214
+ },
12194
12215
  cancelBySeller: (orderItemId, body, idempotencyKey) => storeHttp.request("POST", path`/order-items/${orderItemId}/cancel`, cancelBySellerResultSchema, {
12195
12216
  body: cancelBySellerRequestSchema.parse(body),
12196
12217
  headers: idempotency(idempotencyKey)
@@ -12510,7 +12531,7 @@ get: (params) => storeHttp.request("GET", "/sales-report", salesReportSchema, {
12510
12531
  list: (params = {}) => storeHttp.request("GET", "/payments", paymentRecordPageSchema, { query: params }),
12511
12532
  /** `GET /v1/payments/{paymentId}` — 시도·환불 이력 포함. 404 `PAYMENT_NOT_FOUND` */
12512
12533
  get: (paymentId) => storeHttp.request("GET", path`/payments/${paymentId}`, paymentRecordDetailSchema),
12513
- /** `POST /v1/payments/refunds/{refundId}/process` — 대기 환불(`HELD`)을 PG로 환불한다(#115). 409 `REFUND_NOT_HELD` */
12534
+ /** `POST /v1/payments/refunds/{refundId}/process` — 대기(`HELD`)·실패(`FAILED`) 환불을 PG로 환불한다(#115, #301). 409 `REFUND_NOT_HELD` */
12514
12535
  processRefund: (refundId) => storeHttp.request("POST", path`/payments/refunds/${refundId}/process`, paymentRefundRecordSchema)
12515
12536
  },
12516
12537
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sayren/store-sdk",
3
- "version": "0.55.0",
3
+ "version": "0.56.0",
4
4
  "main": "./dist/index.mjs",
5
5
  "types": "./dist/index.d.mts",
6
6
  "exports": {
package/src/client.ts CHANGED
@@ -274,6 +274,7 @@ import {
274
274
  orderSchema,
275
275
  orderSummarySchema,
276
276
  purchaseDecisionExtendResultSchema,
277
+ type SellerCancelPreviewQuery,
277
278
  type ShippingOrderItemListParams,
278
279
  sellerCancelPreviewSchema,
279
280
  shippingOrderItemSchema,
@@ -1086,13 +1087,21 @@ export function createStoreClient(options: StoreClientOptions) {
1086
1087
  releaseHold: (orderItemId: string) =>
1087
1088
  storeHttp.requestVoid("DELETE", path`/order-items/${orderItemId}/hold`),
1088
1089
  /** 판매자 취소 미리보기(#115) — 취소하면 돌려줄 현금·적립금. 생략한 수량은 남은 수량 전체다 */
1089
- cancelPreview: (orderItemId: string, quantity?: number) =>
1090
- storeHttp.request(
1090
+ cancelPreview: (orderItemId: string, query?: number | SellerCancelPreviewQuery) => {
1091
+ // 두 번째 인자는 수량(이전 호출) 또는 귀책·추가 차감까지 담은 쿼리(#301)다
1092
+ const params: SellerCancelPreviewQuery =
1093
+ typeof query === "number" ? { quantity: query } : (query ?? {});
1094
+ return storeHttp.request(
1091
1095
  "GET",
1092
1096
  path`/order-items/${orderItemId}/cancel-preview`,
1093
1097
  sellerCancelPreviewSchema,
1094
- { query: (quantity ? { quantity } : {}) as Query },
1095
- ),
1098
+ {
1099
+ query: Object.fromEntries(
1100
+ Object.entries(params).filter(([, value]) => value !== undefined && value !== 0),
1101
+ ) as Query,
1102
+ },
1103
+ );
1104
+ },
1096
1105
  cancelBySeller: (orderItemId: string, body: CancelBySellerRequest, idempotencyKey?: string) =>
1097
1106
  storeHttp.request(
1098
1107
  "POST",
@@ -1754,7 +1763,7 @@ export function createStoreClient(options: StoreClientOptions) {
1754
1763
  /** `GET /v1/payments/{paymentId}` — 시도·환불 이력 포함. 404 `PAYMENT_NOT_FOUND` */
1755
1764
  get: (paymentId: string) =>
1756
1765
  storeHttp.request("GET", path`/payments/${paymentId}`, paymentRecordDetailSchema),
1757
- /** `POST /v1/payments/refunds/{refundId}/process` — 대기 환불(`HELD`)을 PG로 환불한다(#115). 409 `REFUND_NOT_HELD` */
1766
+ /** `POST /v1/payments/refunds/{refundId}/process` — 대기(`HELD`)·실패(`FAILED`) 환불을 PG로 환불한다(#115, #301). 409 `REFUND_NOT_HELD` */
1758
1767
  processRefund: (refundId: string) =>
1759
1768
  storeHttp.request(
1760
1769
  "POST",
@@ -136,7 +136,9 @@ export const orderItemFlowSchema = z.object({
136
136
  }),
137
137
  )
138
138
  .optional()
139
- .describe("상태 직접 이동으로 옮길 수 있는 상태(셀러 보기). 흐름이 끝났으면 빈 배열"),
139
+ .describe(
140
+ "상태 직접 이동으로 옮길 수 있는 상태(셀러 보기). 흐름이 끝났으면 빈 배열. `coreStatus`가 `CANCELED`인 상태로 옮기면 판매자 취소와 같이 환불한다(#301)",
141
+ ),
140
142
  branches: z
141
143
  .array(flowStateSchema)
142
144
  .optional()
@@ -151,6 +153,13 @@ export const moveFlowStateRequestSchema = strictRequest(
151
153
  z.object({
152
154
  to: z.string().min(1).describe("옮길 상태 키(`moveTargets[].key`)"),
153
155
  reason: z.string().trim().max(200).optional().describe("옮긴 사유(실행 기록에 남는다)"),
156
+ restock: z
157
+ .boolean()
158
+ .optional()
159
+ .describe(
160
+ "취소 상태(`moveTargets[].coreStatus` `CANCELED`)로 옮길 때 재고를 되돌리는가(#301). 취소 상태로 옮기면 판매자 취소와 같이 환불한다. " +
161
+ "발송 전은 생략하면 true, 발송 뒤는 생략하면 400 `RESTOCK_REQUIRED`다. 다른 상태로 옮길 때는 무시한다",
162
+ ),
154
163
  }),
155
164
  );
156
165
  export type MoveFlowStateRequest = z.infer<typeof moveFlowStateRequestSchema>;
@@ -489,6 +489,31 @@ export const shippingOrderItemSchema = orderItemSchema.extend({
489
489
  ordererPhone: z.string(),
490
490
  shippingAddress: shippingAddressSchema,
491
491
  delivery: deliveryInfoSchema.nullable().describe("발송 정보. 발송 전이면 null"),
492
+ flowStep: z
493
+ .object({
494
+ key: z.string().describe("주문 흐름 안 단계 키(상점이 정한다). 화면 분기에 쓰지 않는다"),
495
+ label: z.string().describe("셀러용 단계 이름"),
496
+ acceptsConfirm: z
497
+ .boolean()
498
+ .optional()
499
+ .default(true)
500
+ .describe(
501
+ "이 단계가 발주 확인(`POST /v1/order-items/{orderItemId}/confirm`)을 받는가. 거짓이면 발주 확인은 409 `INVALID_STATUS`다. 연결선 조건식은 실행 때 다시 판정한다",
502
+ ),
503
+ acceptsDispatch: z
504
+ .boolean()
505
+ .optional()
506
+ .default(true)
507
+ .describe(
508
+ "이 단계가 발송(`POST /v1/order-items/{orderItemId}/dispatch`)을 받는가. 거짓이면 발송은 409 `INVALID_STATUS`다. 연결선 조건식은 실행 때 다시 판정한다",
509
+ ),
510
+ })
511
+ .nullable()
512
+ .optional()
513
+ .default(null)
514
+ .describe(
515
+ "주문 흐름의 지금 단계(`GET /v1/order-items/{orderItemId}/flow`의 `flowState` 키·이름). 같은 상태라도 단계가 발송을 받지 않으면 발송은 409 `INVALID_STATUS`다(`acceptsConfirm`·`acceptsDispatch`). 흐름이 없으면 null. 서버는 항상 싣는다",
516
+ ),
492
517
  });
493
518
 
494
519
  export type ShippingOrderItem = z.infer<typeof shippingOrderItemSchema>;
@@ -650,6 +675,35 @@ export const cancelBySellerRequestSchema = strictRequest(
650
675
  "true면 주문만 취소하고 결제 환불은 대기로 남긴다(#115). 정산·재고·적립금 반환은 그대로 하고, PG 환불은 결제 상세의 " +
651
676
  "`POST /v1/payments/refunds/{refundId}/process`로 따로 한다. 생략하면 취소와 함께 환불한다",
652
677
  ),
678
+ responsibility: z
679
+ .enum(["SELLER", "BUYER"])
680
+ .optional()
681
+ .describe(
682
+ "귀책(#301). 생략하면 `SELLER`다. `SELLER`면 배송비를 판매자가 부담하고(환불 정책 `sellerFaultFreeShipping`) 쿠폰 조건 미달 차감을 하지 않는다. " +
683
+ "`BUYER`면 클레임 승인의 구매자 귀책과 같은 규칙이다(발송 뒤에는 배송비를 돌려주지 않는다). 반품 배송비는 자동으로 빼지 않는다 — 필요하면 `deductAmount`로 뺀다",
684
+ ),
685
+ deductAmount: z
686
+ .number()
687
+ .int()
688
+ .min(0)
689
+ .optional()
690
+ .describe(
691
+ "환불액에서 뺄 추가 차감(#301, 원). 생략하면 0이다. 현금에서 먼저 빼고 모자란 몫만 돌려줄 적립금에서 뺀다. 환불 원장·`ORDER.CANCELED` 웹훅에 따로 남는다",
692
+ ),
693
+ restock: z
694
+ .boolean()
695
+ .optional()
696
+ .describe(
697
+ "재고를 되돌리는가(#301). 발송 전(결제완료·발주확인, 배송 없는 상품은 제공 완료까지)은 생략하면 true다. " +
698
+ "그 뒤(발송·배송중·배송완료·구매확정)는 생략하면 400 `RESTOCK_REQUIRED`다 — 물건이 돌아왔는지는 판매자가 정한다",
699
+ ),
700
+ reclaimPurchasePoints: z
701
+ .boolean()
702
+ .optional()
703
+ .describe(
704
+ "구매확정 때 지급한 구매 적립금 중 이번 수량의 몫을 회수하는가(#301). 지급된 구매 적립금이 없으면 무시한다. 생략하면 회수하지 않는다. " +
705
+ "회원 잔액이 모자라면 있는 만큼만 회수한다(리뷰 적립 회수와 같은 규칙)",
706
+ ),
653
707
  }),
654
708
  );
655
709
 
@@ -690,7 +744,7 @@ export const cancelBySellerResultSchema = z.object({
690
744
  .int()
691
745
  .describe(
692
746
  "실제 환불한 금액 — 수량 비율 상품 실결제 금액(쿠폰 배분을 뺀 금액) + 배송비 환불 − 조건부 무료배송 미달 차감 " +
693
- "+ 되돌린 쿠폰 차감(`couponChargeRefundAmount`)",
747
+ "− 쿠폰 조건 미달 차감 + 되돌린 쿠폰 차감(`couponChargeRefundAmount`) − 추가 차감(`deductAmount`)",
694
748
  ),
695
749
  quantity: z.number().int().describe("취소한 수량"),
696
750
  canceledQuantity: z.number().int().describe("취소 후 누적 취소 수량"),
@@ -709,7 +763,9 @@ export const cancelBySellerResultSchema = z.object({
709
763
  .int()
710
764
  .optional()
711
765
  .default(0)
712
- .describe("쿠폰 조건 미달 차감. 판매자 취소는 차감하지 않으므로 늘 0이다. 서버는 항상 싣는다"),
766
+ .describe(
767
+ "쿠폰 조건 미달 차감. 판매자 귀책 취소는 차감하지 않으므로 0이고, 구매자 귀책(`responsibility: BUYER`)이면 생길 수 있다. 서버는 항상 싣는다",
768
+ ),
713
769
  couponChargeRefundAmount: z
714
770
  .number()
715
771
  .int()
@@ -733,10 +789,31 @@ export const cancelBySellerResultSchema = z.object({
733
789
  .optional()
734
790
  .default(false)
735
791
  .describe("결제 환불을 대기로 남겼다(`holdRefund`). 결제 상세에서 환불 처리한다"),
792
+ deductAmount: z
793
+ .number()
794
+ .int()
795
+ .optional()
796
+ .default(0)
797
+ .describe("환불액에서 뺀 추가 차감(#301). 서버는 항상 싣는다"),
798
+ purchasePointReclaimedAmount: z
799
+ .number()
800
+ .int()
801
+ .optional()
802
+ .default(0)
803
+ .describe(
804
+ "회수한 구매 적립금(#301, `reclaimPurchasePoints`). 잔액이 모자라면 요청한 몫보다 작다. 서버는 항상 싣는다",
805
+ ),
736
806
  });
737
807
 
738
808
  export type CancelBySellerResult = z.infer<typeof cancelBySellerResultSchema>;
739
809
 
810
+ /** `GET /v1/order-items/{orderItemId}/cancel-preview` 쿼리 — 금액에 영향을 주는 취소 입력(#301). 생략하면 취소의 기본값이다 */
811
+ export interface SellerCancelPreviewQuery {
812
+ quantity?: number;
813
+ responsibility?: "SELLER" | "BUYER";
814
+ deductAmount?: number;
815
+ }
816
+
740
817
  /**
741
818
  * `GET /v1/order-items/{orderItemId}/cancel-preview` 응답(#115) — 판매자 취소를 하면 돌려줄 금액. 실제 취소와 같은 계산을
742
819
  * 쓰기 없이 돌린 결과다. 취소할 수 없는 주문상품은 취소와 같은 409다
@@ -748,6 +825,27 @@ export const sellerCancelPreviewSchema = z.object({
748
825
  pointRefundAmount: z.number().int().describe("돌려줄 적립금 (원)"),
749
826
  deliveryFeeRefundAmount: z.number().int().describe("환불에 포함될 배송비"),
750
827
  deliveryFeeChargeAmount: z.number().int().describe("조건부 무료배송 기준 미달로 뺄 배송비"),
828
+ deductAmount: z
829
+ .number()
830
+ .int()
831
+ .optional()
832
+ .default(0)
833
+ .describe("뺄 추가 차감(쿼리 `deductAmount`). 서버는 항상 싣는다"),
834
+ restockRequired: z
835
+ .boolean()
836
+ .optional()
837
+ .default(false)
838
+ .describe(
839
+ "취소 요청에 `restock`이 있어야 하는가(#301) — 발송 뒤 주문상품이면 true다. 서버는 항상 싣는다",
840
+ ),
841
+ purchasePointAmount: z
842
+ .number()
843
+ .int()
844
+ .optional()
845
+ .default(0)
846
+ .describe(
847
+ "이번 수량에서 회수할 수 있는 구매 적립금(#301). 0이면 회수할 것이 없다(`reclaimPurchasePoints`를 묻지 않는다). 서버는 항상 싣는다",
848
+ ),
751
849
  });
752
850
 
753
851
  export type SellerCancelPreview = z.infer<typeof sellerCancelPreviewSchema>;
@@ -189,6 +189,7 @@ export const POINT_ENTRY_TYPES = [
189
189
  "EARN_REVIEW",
190
190
  "REVOKE_REVIEW",
191
191
  "EARN_PURCHASE",
192
+ "REVOKE_PURCHASE",
192
193
  "USE_RESERVE",
193
194
  "USE_RELEASE",
194
195
  "REFUND_RESTORE",
@@ -257,7 +258,7 @@ export type UpdatePointPolicyRequest = z.infer<typeof updatePointPolicyRequestSc
257
258
  export const responsePointEntryTypeSchema = z
258
259
  .union([z.enum(POINT_ENTRY_TYPES), z.string()])
259
260
  .describe(
260
- "유형. `EARN_REVIEW` 리뷰 적립 · `REVOKE_REVIEW` 리뷰 삭제 회수 · `EARN_PURCHASE` 구매 적립 · `EXPIRE` 소멸 · `ADJUST` 셀러 지급·차감 · " +
261
+ "유형. `EARN_REVIEW` 리뷰 적립 · `REVOKE_REVIEW` 리뷰 삭제 회수 · `EARN_PURCHASE` 구매 적립 · `REVOKE_PURCHASE` 판매자 취소의 구매 적립 회수 · `EXPIRE` 소멸 · `ADJUST` 셀러 지급·차감 · " +
261
262
  "`OPENING` 기존 잔액 이전 · `USE_RESERVE` 결제 사용(결제 시작 때 빠짐) · `USE_RELEASE` 결제가 실패·만료되어 되돌림 · " +
262
263
  "`REFUND_RESTORE` 취소·반품 환불로 반환 · `EARN_COUPON` 적립금 지급 쿠폰. 값이 추가될 수 있어 문자열로 받는다",
263
264
  );
@@ -176,7 +176,7 @@ export const orderCanceledWebhookEventDataSchema = z.object({
176
176
  .int()
177
177
  .describe(
178
178
  "환불액 (원). 수량 비율 상품 실결제 금액(쿠폰 배분을 뺀 금액) + 배송비 환불 − 조건부 무료배송 미달 차감 " +
179
- "+ 되돌린 쿠폰 차감(`couponChargeRefundAmount`)이다. " +
179
+ "− 쿠폰 조건 미달 차감 + 되돌린 쿠폰 차감(`couponChargeRefundAmount`) − 추가 차감(`deductAmount`)이다. " +
180
180
  "결제사 환불 결과는 결제 내역(`GET /v1/payments/{paymentId}`)으로 확인한다",
181
181
  ),
182
182
  deliveryFeeRefundAmount: z.number().int().describe("환불액에 포함된 배송비 (원)"),
@@ -190,7 +190,7 @@ export const orderCanceledWebhookEventDataSchema = z.object({
190
190
  .optional()
191
191
  .default(0)
192
192
  .describe(
193
- "환불액에서 뺀 쿠폰 조건 미달 차감 (원). 판매자 취소는 차감하지 않으므로 늘 0이다. 이 필드가 없는 이전 이벤트는 0으로 읽는다",
193
+ "환불액에서 뺀 쿠폰 조건 미달 차감 (원). 판매자 귀책 취소는 차감하지 않으므로 0이고, 구매자 귀책(`responsibility: BUYER`)이면 생길 수 있다. 이 필드가 없는 이전 이벤트는 0으로 읽는다",
194
194
  ),
195
195
  couponChargeRefundAmount: z
196
196
  .number()
@@ -210,6 +210,14 @@ export const orderCanceledWebhookEventDataSchema = z.object({
210
210
  "돌려준 적립금 (원, #93) — 결제에 쓴 적립금 중 이번 취소·반품 수량의 몫이다. 현금 환불(`refundAmount`)과 별개다. " +
211
211
  "차감은 현금에서 먼저 빼고 모자란 몫만 여기서 뺀다. 적립금을 쓰지 않은 주문과 이 필드가 없는 이전 응답·이벤트는 0으로 읽는다",
212
212
  ),
213
+ deductAmount: z
214
+ .number()
215
+ .int()
216
+ .optional()
217
+ .default(0)
218
+ .describe(
219
+ "환불액에서 뺀 추가 차감 (원, #301) — 판매자가 취소 요청에 넣은 `deductAmount`다. 배송비 차감과 따로 싣는다. 이 필드가 없는 이전 이벤트는 0으로 읽는다",
220
+ ),
213
221
  currency: z
214
222
  .string()
215
223
  .optional()