@sayren/store-sdk 0.7.0 → 0.8.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
@@ -2042,6 +2042,7 @@ export declare const orderSchema: z.ZodObject<{
2042
2042
  MIXED: "MIXED";
2043
2043
  }>;
2044
2044
  approvedMethod: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
2045
+ easyPayProvider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
2045
2046
  productAmount: z.ZodNumber;
2046
2047
  deliveryFee: z.ZodNumber;
2047
2048
  discountAmount: z.ZodNumber;
@@ -2401,18 +2402,23 @@ export declare const pgPaymentMethodSchema: z.ZodEnum<{
2401
2402
  EASY_PAY: "EASY_PAY";
2402
2403
  }>;
2403
2404
  export type PgPaymentMethod = z.infer<typeof pgPaymentMethodSchema>;
2404
- export declare const paymentRoutingModeSchema: z.ZodEnum<{
2405
- PRIORITY_DISPLAY: "PRIORITY_DISPLAY";
2406
- AUTO_FAILOVER: "AUTO_FAILOVER";
2407
- }>;
2408
- export type PaymentRoutingMode = z.infer<typeof paymentRoutingModeSchema>;
2409
- export declare const effectivePaymentRoutingModeSchema: z.ZodEnum<{
2410
- PRIORITY_DISPLAY: "PRIORITY_DISPLAY";
2411
- AUTO_FAILOVER: "AUTO_FAILOVER";
2412
- NONE: "NONE";
2413
- SINGLE: "SINGLE";
2405
+ /**
2406
+ * 간편결제사 — 결제 옵션(스토어프론트 `paymentOptions`)과 PG 설정의 `easyPayProviders`에 쓴다.
2407
+ * `@sayren/storefront-sdk`의 `easyPayProviderSchema`와 같은 값이다(api 계약 테스트가 고정한다)
2408
+ */
2409
+ export declare const easyPayProviderSchema: z.ZodEnum<{
2410
+ NAVERPAY: "NAVERPAY";
2411
+ KAKAOPAY: "KAKAOPAY";
2412
+ TOSSPAY: "TOSSPAY";
2413
+ PAYCO: "PAYCO";
2414
2414
  }>;
2415
- export type EffectivePaymentRoutingMode = z.infer<typeof effectivePaymentRoutingModeSchema>;
2415
+ export type EasyPayProvider = z.infer<typeof easyPayProviderSchema>;
2416
+ /**
2417
+ * 응답에 실리는 간편결제사 — 서버가 간편결제사를 추가해도 파싱이 깨지지 않게 문자열로 받는다
2418
+ * (`pgProvider`·결제수단과 같은 방식). 요청(`easyPayProviders`)은 값을 골라 보내는 자리라 enum 그대로다.
2419
+ * 현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 화면은 모르는 값을 원문 그대로 보여 준다.
2420
+ */
2421
+ export declare const easyPayProviderResponseSchema: z.ZodString;
2416
2422
  export declare const pgEnvironmentSchema: z.ZodEnum<{
2417
2423
  TEST: "TEST";
2418
2424
  LIVE: "LIVE";
@@ -2512,6 +2518,12 @@ export type UpsertPortOneProviderRequest = z.infer<typeof upsertPortOneProviderR
2512
2518
  export declare const updatePaymentProviderRequestSchema: z.ZodObject<{
2513
2519
  enabled: z.ZodOptional<z.ZodBoolean>;
2514
2520
  sandboxMode: z.ZodOptional<z.ZodBoolean>;
2521
+ easyPayProviders: z.ZodOptional<z.ZodArray<z.ZodEnum<{
2522
+ NAVERPAY: "NAVERPAY";
2523
+ KAKAOPAY: "KAKAOPAY";
2524
+ TOSSPAY: "TOSSPAY";
2525
+ PAYCO: "PAYCO";
2526
+ }>>>;
2515
2527
  }, z.core.$strip>;
2516
2528
  export type UpdatePaymentProviderRequest = z.infer<typeof updatePaymentProviderRequestSchema>;
2517
2529
  export declare const verifyPaymentProviderRequestSchema: z.ZodObject<{
@@ -2522,14 +2534,11 @@ export declare const verifyPaymentProviderRequestSchema: z.ZodObject<{
2522
2534
  }, z.core.$strip>;
2523
2535
  export type VerifyPaymentProviderRequest = z.infer<typeof verifyPaymentProviderRequestSchema>;
2524
2536
  export declare const updatePaymentSettingsRequestSchema: z.ZodObject<{
2525
- routingMode: z.ZodEnum<{
2526
- PRIORITY_DISPLAY: "PRIORITY_DISPLAY";
2527
- AUTO_FAILOVER: "AUTO_FAILOVER";
2528
- }>;
2529
- priority: z.ZodArray<z.ZodEnum<{
2537
+ priority: z.ZodOptional<z.ZodArray<z.ZodEnum<{
2530
2538
  tosspayments: "tosspayments";
2531
2539
  portone: "portone";
2532
- }>>;
2540
+ }>>>;
2541
+ checkoutOrigins: z.ZodOptional<z.ZodArray<z.ZodString>>;
2533
2542
  }, z.core.$strip>;
2534
2543
  export type UpdatePaymentSettingsRequest = z.infer<typeof updatePaymentSettingsRequestSchema>;
2535
2544
  export declare const maskedSecretSchema: z.ZodObject<{
@@ -2768,6 +2777,7 @@ export declare const paymentProviderSchema: z.ZodObject<{
2768
2777
  }, z.core.$strip>>;
2769
2778
  openedAt: z.ZodNullable<z.ZodString>;
2770
2779
  }, z.core.$strip>;
2780
+ easyPayProviders: z.ZodArray<z.ZodString>;
2771
2781
  retiredCredentialCount: z.ZodNumber;
2772
2782
  routingExclusion: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
2773
2783
  }, z.core.$strip>;
@@ -2779,16 +2789,7 @@ export type PaymentProvider = z.infer<typeof paymentProviderSchema>;
2779
2789
  export declare const PAYMENT_ROUTING_EXCLUSION_CODES: readonly ["NOT_CONNECTED", "DISABLED", "CREDENTIAL_MISSING", "SANDBOX_IN_LIVE_STORE", "PLATFORM_BLOCKED", "MODE_MISMATCH"];
2780
2790
  export type KnownPaymentRoutingExclusion = (typeof PAYMENT_ROUTING_EXCLUSION_CODES)[number];
2781
2791
  export declare const paymentSettingsSchema: z.ZodObject<{
2782
- routingMode: z.ZodEnum<{
2783
- PRIORITY_DISPLAY: "PRIORITY_DISPLAY";
2784
- AUTO_FAILOVER: "AUTO_FAILOVER";
2785
- }>;
2786
- effectiveRoutingMode: z.ZodEnum<{
2787
- PRIORITY_DISPLAY: "PRIORITY_DISPLAY";
2788
- AUTO_FAILOVER: "AUTO_FAILOVER";
2789
- NONE: "NONE";
2790
- SINGLE: "SINGLE";
2791
- }>;
2792
+ checkoutOrigins: z.ZodArray<z.ZodString>;
2792
2793
  providers: z.ZodArray<z.ZodObject<{
2793
2794
  provider: z.ZodEnum<{
2794
2795
  tosspayments: "tosspayments";
@@ -2925,6 +2926,7 @@ export declare const paymentSettingsSchema: z.ZodObject<{
2925
2926
  }, z.core.$strip>>;
2926
2927
  openedAt: z.ZodNullable<z.ZodString>;
2927
2928
  }, z.core.$strip>;
2929
+ easyPayProviders: z.ZodArray<z.ZodString>;
2928
2930
  retiredCredentialCount: z.ZodNumber;
2929
2931
  routingExclusion: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
2930
2932
  }, z.core.$strip>>;
@@ -3109,6 +3111,7 @@ export declare const paymentRecordSchema: z.ZodObject<{
3109
3111
  MOBILE: "MOBILE";
3110
3112
  EASY_PAY: "EASY_PAY";
3111
3113
  }>>;
3114
+ easyPayProvider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3112
3115
  environment: z.ZodNullable<z.ZodEnum<{
3113
3116
  TEST: "TEST";
3114
3117
  LIVE: "LIVE";
@@ -3153,6 +3156,7 @@ export declare const paymentRecordPageSchema: z.ZodObject<{
3153
3156
  MOBILE: "MOBILE";
3154
3157
  EASY_PAY: "EASY_PAY";
3155
3158
  }>>;
3159
+ easyPayProvider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3156
3160
  environment: z.ZodNullable<z.ZodEnum<{
3157
3161
  TEST: "TEST";
3158
3162
  LIVE: "LIVE";
@@ -3183,6 +3187,7 @@ export declare const paymentAttemptRecordSchema: z.ZodObject<{
3183
3187
  MOBILE: "MOBILE";
3184
3188
  EASY_PAY: "EASY_PAY";
3185
3189
  }>;
3190
+ easyPayProvider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3186
3191
  approvedMethod: z.ZodNullable<z.ZodEnum<{
3187
3192
  CARD: "CARD";
3188
3193
  BANK_TRANSFER: "BANK_TRANSFER";
@@ -3190,6 +3195,7 @@ export declare const paymentAttemptRecordSchema: z.ZodObject<{
3190
3195
  MOBILE: "MOBILE";
3191
3196
  EASY_PAY: "EASY_PAY";
3192
3197
  }>>;
3198
+ approvedEasyPayProvider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3193
3199
  amount: z.ZodNumber;
3194
3200
  environment: z.ZodEnum<{
3195
3201
  TEST: "TEST";
@@ -3238,6 +3244,7 @@ export declare const paymentRecordDetailSchema: z.ZodObject<{
3238
3244
  MOBILE: "MOBILE";
3239
3245
  EASY_PAY: "EASY_PAY";
3240
3246
  }>>;
3247
+ easyPayProvider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3241
3248
  environment: z.ZodNullable<z.ZodEnum<{
3242
3249
  TEST: "TEST";
3243
3250
  LIVE: "LIVE";
@@ -3267,6 +3274,7 @@ export declare const paymentRecordDetailSchema: z.ZodObject<{
3267
3274
  MOBILE: "MOBILE";
3268
3275
  EASY_PAY: "EASY_PAY";
3269
3276
  }>;
3277
+ easyPayProvider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3270
3278
  approvedMethod: z.ZodNullable<z.ZodEnum<{
3271
3279
  CARD: "CARD";
3272
3280
  BANK_TRANSFER: "BANK_TRANSFER";
@@ -3274,6 +3282,7 @@ export declare const paymentRecordDetailSchema: z.ZodObject<{
3274
3282
  MOBILE: "MOBILE";
3275
3283
  EASY_PAY: "EASY_PAY";
3276
3284
  }>>;
3285
+ approvedEasyPayProvider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3277
3286
  amount: z.ZodNumber;
3278
3287
  environment: z.ZodEnum<{
3279
3288
  TEST: "TEST";
@@ -4570,6 +4579,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
4570
4579
  payment: {
4571
4580
  method: "CARD" | "BANK_TRANSFER" | "VIRTUAL_ACCOUNT" | "MOBILE" | "POINT" | "MIXED";
4572
4581
  approvedMethod: string | null;
4582
+ easyPayProvider: string | null;
4573
4583
  productAmount: number;
4574
4584
  deliveryFee: number;
4575
4585
  discountAmount: number;
@@ -5396,6 +5406,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5396
5406
  refundedAmount: number;
5397
5407
  provider: "tosspayments" | "portone" | null;
5398
5408
  method: "CARD" | "BANK_TRANSFER" | "VIRTUAL_ACCOUNT" | "MOBILE" | "EASY_PAY" | null;
5409
+ easyPayProvider: string | null;
5399
5410
  environment: "TEST" | "LIVE" | null;
5400
5411
  testPayment: boolean;
5401
5412
  pgTransactionId: string | null;
@@ -5418,6 +5429,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5418
5429
  refundedAmount: number;
5419
5430
  provider: "tosspayments" | "portone" | null;
5420
5431
  method: "CARD" | "BANK_TRANSFER" | "VIRTUAL_ACCOUNT" | "MOBILE" | "EASY_PAY" | null;
5432
+ easyPayProvider: string | null;
5421
5433
  environment: "TEST" | "LIVE" | null;
5422
5434
  testPayment: boolean;
5423
5435
  pgTransactionId: string | null;
@@ -5435,7 +5447,9 @@ export declare function createStoreClient(options: StoreClientOptions): {
5435
5447
  provider: "tosspayments" | "portone";
5436
5448
  status: string;
5437
5449
  method: "CARD" | "BANK_TRANSFER" | "VIRTUAL_ACCOUNT" | "MOBILE" | "EASY_PAY";
5450
+ easyPayProvider: string | null;
5438
5451
  approvedMethod: "CARD" | "BANK_TRANSFER" | "VIRTUAL_ACCOUNT" | "MOBILE" | "EASY_PAY" | null;
5452
+ approvedEasyPayProvider: string | null;
5439
5453
  amount: number;
5440
5454
  environment: "TEST" | "LIVE";
5441
5455
  pgTransactionId: string | null;
@@ -5465,8 +5479,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5465
5479
  paymentSettings: {
5466
5480
  /** `GET /v1/store/payment-settings` — 라우팅 모드와 지원 PG 전부(연결된 것은 우선순위순) */
5467
5481
  get: () => Promise<{
5468
- routingMode: "PRIORITY_DISPLAY" | "AUTO_FAILOVER";
5469
- effectiveRoutingMode: "PRIORITY_DISPLAY" | "AUTO_FAILOVER" | "NONE" | "SINGLE";
5482
+ checkoutOrigins: string[];
5470
5483
  providers: {
5471
5484
  provider: "tosspayments" | "portone";
5472
5485
  displayName: string;
@@ -5555,6 +5568,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5555
5568
  }[];
5556
5569
  openedAt: string | null;
5557
5570
  };
5571
+ easyPayProviders: string[];
5558
5572
  retiredCredentialCount: number;
5559
5573
  routingExclusion: string | null;
5560
5574
  }[];
@@ -5566,8 +5580,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5566
5580
  * (빠지거나 중복되면 400 `INVALID_PRIORITY`). 진행 중인 결제에는 적용되지 않는다.
5567
5581
  */
5568
5582
  update: (body: UpdatePaymentSettingsRequest) => Promise<{
5569
- routingMode: "PRIORITY_DISPLAY" | "AUTO_FAILOVER";
5570
- effectiveRoutingMode: "PRIORITY_DISPLAY" | "AUTO_FAILOVER" | "NONE" | "SINGLE";
5583
+ checkoutOrigins: string[];
5571
5584
  providers: {
5572
5585
  provider: "tosspayments" | "portone";
5573
5586
  displayName: string;
@@ -5656,6 +5669,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5656
5669
  }[];
5657
5670
  openedAt: string | null;
5658
5671
  };
5672
+ easyPayProviders: string[];
5659
5673
  retiredCredentialCount: number;
5660
5674
  routingExclusion: string | null;
5661
5675
  }[];
@@ -5761,6 +5775,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5761
5775
  }[];
5762
5776
  openedAt: string | null;
5763
5777
  };
5778
+ easyPayProviders: string[];
5764
5779
  retiredCredentialCount: number;
5765
5780
  routingExclusion: string | null;
5766
5781
  }>;
@@ -5856,6 +5871,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5856
5871
  }[];
5857
5872
  openedAt: string | null;
5858
5873
  };
5874
+ easyPayProviders: string[];
5859
5875
  retiredCredentialCount: number;
5860
5876
  routingExclusion: string | null;
5861
5877
  }>;
@@ -5961,6 +5977,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
5961
5977
  }[];
5962
5978
  openedAt: string | null;
5963
5979
  };
5980
+ easyPayProviders: string[];
5964
5981
  retiredCredentialCount: number;
5965
5982
  routingExclusion: string | null;
5966
5983
  }>;
@@ -6056,6 +6073,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
6056
6073
  }[];
6057
6074
  openedAt: string | null;
6058
6075
  };
6076
+ easyPayProviders: string[];
6059
6077
  retiredCredentialCount: number;
6060
6078
  routingExclusion: string | null;
6061
6079
  }>;
@@ -6160,6 +6178,7 @@ export declare function createStoreClient(options: StoreClientOptions): {
6160
6178
  }[];
6161
6179
  openedAt: string | null;
6162
6180
  };
6181
+ easyPayProviders: string[];
6163
6182
  retiredCredentialCount: number;
6164
6183
  routingExclusion: string | null;
6165
6184
  }>;
package/dist/index.mjs CHANGED
@@ -1182,205 +1182,6 @@ const reviewReportResultSchema = z.object({
1182
1182
  status: z.literal("PENDING_REVIEW")
1183
1183
  });
1184
1184
  //#endregion
1185
- //#region src/schemas/order.ts
1186
- const orderSummarySchema = z.object({
1187
- orderId: z.string(),
1188
- ordererName: z.string(),
1189
- itemCount: z.number().int(),
1190
- totalAmount: z.number().int(),
1191
- representativeStatus: orderItemStatusSchema,
1192
- orderedAt: z.string(),
1193
- testPayment: z.boolean().describe("테스트 결제(샌드박스 결제) 주문인가. true면 실제로 돈이 오가지 않았어요. 상품을 발송하지 않도록 주의하세요")
1194
- });
1195
- const shippingAddressSchema = z.object({
1196
- receiverName: z.string(),
1197
- phone: z.string(),
1198
- zipCode: z.string(),
1199
- address1: z.string(),
1200
- address2: z.string().nullish(),
1201
- deliveryMemo: z.string().nullish(),
1202
- entranceCode: z.string().nullish()
1203
- });
1204
- const orderItemSchema = z.object({
1205
- orderItemId: z.string(),
1206
- orderId: z.string(),
1207
- status: orderItemStatusSchema,
1208
- claimStatus: z.enum([
1209
- "CANCEL_REQUESTED",
1210
- "RETURN_REQUESTED",
1211
- "EXCHANGE_REQUESTED"
1212
- ]).nullable(),
1213
- productId: z.string(),
1214
- productName: z.string(),
1215
- optionId: z.string().nullable(),
1216
- optionName: z.string().nullable(),
1217
- sellerCode: z.string().nullable(),
1218
- quantity: z.number().int(),
1219
- unitPrice: z.number().int(),
1220
- discountAmount: z.number().int(),
1221
- totalPrice: z.number().int(),
1222
- hold: z.object({
1223
- reason: z.string(),
1224
- expectedDispatchDate: z.string()
1225
- }).nullable(),
1226
- autoDecisionDate: z.string().nullable(),
1227
- sellerMemo: z.string().nullable(),
1228
- orderedAt: z.string(),
1229
- lastChangedAt: z.string(),
1230
- lastChangedType: changeTypeSchema,
1231
- testPayment: z.boolean().describe("소속 주문이 테스트 결제(샌드박스 결제) 주문인가. true면 실제로 돈이 오가지 않았어요")
1232
- });
1233
- const orderSchema = z.object({
1234
- orderId: z.string(),
1235
- orderedAt: z.string(),
1236
- orderer: z.object({
1237
- name: z.string(),
1238
- phone: z.string(),
1239
- email: z.email().optional()
1240
- }),
1241
- shippingAddress: shippingAddressSchema,
1242
- payment: z.object({
1243
- method: z.enum([
1244
- "CARD",
1245
- "BANK_TRANSFER",
1246
- "VIRTUAL_ACCOUNT",
1247
- "MOBILE",
1248
- "POINT",
1249
- "MIXED"
1250
- ]).describe("method는 호환용이며 간편결제를 CARD로 표시한다. 실제 수단은 approvedMethod를 본다"),
1251
- approvedMethod: z.string().nullable().optional().default(null).describe("실제 결제수단. method는 호환용이며 간편결제를 CARD로 표시한다. 실제 수단은 approvedMethod를 본다. 현재 값은 `pgPaymentMethodSchema`(`PgPaymentMethod`: CARD·BANK_TRANSFER·VIRTUAL_ACCOUNT·MOBILE·EASY_PAY)이고 매출 리포트·스토어프론트·환불 원장과 같은 값이다. 값이 추가될 수 있어 문자열로 받는다. PG가 알려 주지 않았으면 요청 수단, 시도 기록이 없는 오래된 주문은 null. 서버는 항상 싣는다"),
1252
- productAmount: z.number().int(),
1253
- deliveryFee: z.number().int(),
1254
- discountAmount: z.number().int(),
1255
- totalAmount: z.number().int(),
1256
- paidAt: z.string().nullable()
1257
- }),
1258
- testPayment: z.boolean().describe("테스트 결제(샌드박스 결제) 주문인가. true면 실제로 돈이 오가지 않았어요. 상품을 발송하지 않도록 주의하세요"),
1259
- items: z.array(orderItemSchema)
1260
- });
1261
- /** 주문 목록 응답 — `GET /v1/orders` */
1262
- const orderSummaryPageSchema = pageSchema(orderSummarySchema);
1263
- /** 주문상품 변경 목록 응답 — `GET /v1/order-items` */
1264
- const orderItemPageSchema = pageSchema(orderItemSchema);
1265
- const testPaymentQuery = z.enum(["true", "false"]).optional().describe("테스트 결제(샌드박스 결제) 필터. `true`면 테스트 결제만, `false`면 실결제만, 생략하면 전부예요");
1266
- const pageQuery = { page: z.string().optional().describe("페이지 번호 (1부터, 기본 1)") };
1267
- /**
1268
- * `GET /v1/orders` 쿼리 — OpenAPI 문서용 형태(값은 쿼리 문자열). 검증 규칙은 서버가 적용한다:
1269
- * `orderedFrom` 누락 400 `MISSING_PARAMETER`, 날짜 형식 오류 400 `INVALID_PARAMETER`, 31일 초과 400 `RANGE_TOO_WIDE`,
1270
- * `testPayment`가 `true`·`false`가 아니면 400 `INVALID_PARAMETER`
1271
- */
1272
- const orderListQuerySchema = z.object({
1273
- orderedFrom: z.string().describe("조회 시작 시각 (ISO 8601 날짜 또는 일시, 포함). 필수"),
1274
- orderedTo: z.string().optional().describe("조회 끝 시각 (ISO 8601, 포함). 생략하면 orderedFrom부터 31일. 기간은 최대 31일"),
1275
- status: orderItemStatusSchema.optional().describe("주문상품 상태 필터 — 이 상태의 주문상품이 하나라도 있는 주문"),
1276
- keyword: z.string().optional().describe("주문번호(일치)·주문자명·수령인명(포함) 검색"),
1277
- testPayment: testPaymentQuery,
1278
- ...pageQuery,
1279
- size: z.string().optional().describe("페이지 크기 (기본 20, 최대 100)")
1280
- });
1281
- /**
1282
- * `GET /v1/order-items` 쿼리 — OpenAPI 문서용 형태. `lastChangedFrom` 누락 400 `MISSING_PARAMETER`, 형식 오류 400
1283
- * `INVALID_PARAMETER`, 24시간 초과 400 `RANGE_TOO_WIDE`, `testPayment` 값 오류 400 `INVALID_PARAMETER`
1284
- */
1285
- const orderItemListQuerySchema = z.object({
1286
- lastChangedFrom: z.string().describe("마지막 변경 시각 조회 시작 (ISO 8601, 포함). 필수"),
1287
- lastChangedTo: z.string().optional().describe("마지막 변경 시각 조회 끝 (ISO 8601, 포함). 생략하면 시작부터 24시간. 기간은 최대 24시간"),
1288
- lastChangedType: changeTypeSchema.optional().describe("마지막 변경 유형 필터"),
1289
- testPayment: testPaymentQuery,
1290
- ...pageQuery,
1291
- size: z.string().optional().describe("페이지 크기 (기본 100, 최대 300)")
1292
- });
1293
- const deliveryMethodSchema = z.enum([
1294
- "COURIER",
1295
- "DIRECT",
1296
- "QUICK",
1297
- "NOTHING"
1298
- ]);
1299
- const dispatchRequestSchema = z.object({
1300
- deliveryMethod: deliveryMethodSchema,
1301
- carrierCode: z.string().optional(),
1302
- trackingNumber: z.string().optional(),
1303
- dispatchedAt: z.string().optional()
1304
- }).refine((value) => value.deliveryMethod === "DIRECT" || value.deliveryMethod === "NOTHING" ? true : !!value.carrierCode && !!value.trackingNumber, { message: "COURIER/QUICK 발송은 carrierCode와 trackingNumber가 필수입니다" });
1305
- const deliveryInfoSchema = z.object({
1306
- orderItemId: z.string(),
1307
- deliveryMethod: deliveryMethodSchema,
1308
- carrierCode: z.string().nullable(),
1309
- carrierName: z.string().nullable(),
1310
- trackingNumber: z.string().nullable(),
1311
- trackingUrl: z.url().nullable(),
1312
- status: z.enum([
1313
- "DISPATCHED",
1314
- "DELIVERING",
1315
- "DELIVERED"
1316
- ]),
1317
- dispatchedAt: z.string(),
1318
- deliveredAt: z.string().nullable()
1319
- });
1320
- /** `GET /v1/order-items/{orderItemId}/delivery` 응답 — 배송 정보 + 배송 추적 이벤트 */
1321
- const deliveryStatusSchema = deliveryInfoSchema.extend({ trackingEvents: z.array(z.object({
1322
- status: z.string(),
1323
- location: z.string(),
1324
- occurredAt: z.string()
1325
- })).optional() });
1326
- /** `PUT /v1/order-items/{orderItemId}/dispatch/tracking` 응답 — 바뀐 송장 */
1327
- const trackingUpdateResultSchema = z.object({
1328
- orderItemId: z.string(),
1329
- carrierCode: z.string(),
1330
- trackingNumber: z.string()
1331
- });
1332
- const carrierSchema = z.object({
1333
- carrierCode: z.string(),
1334
- name: z.string(),
1335
- trackingUrlTemplate: z.string()
1336
- });
1337
- const holdOrderItemRequestSchema = z.object({
1338
- reason: z.enum([
1339
- "OUT_OF_STOCK",
1340
- "CUSTOMER_REQUEST",
1341
- "CUSTOMS",
1342
- "ETC"
1343
- ]),
1344
- detail: z.string().max(500).optional(),
1345
- expectedDispatchDate: z.string()
1346
- });
1347
- const cancelBySellerRequestSchema = z.object({
1348
- reason: z.enum([
1349
- "OUT_OF_STOCK",
1350
- "PRICE_ERROR",
1351
- "DELIVERY_IMPOSSIBLE",
1352
- "ETC"
1353
- ]),
1354
- detail: z.string().max(500).optional()
1355
- });
1356
- /** `POST /v1/order-items/{orderItemId}/cancel` 응답 — 셀러 직권취소 환불 결과 */
1357
- const cancelBySellerResultSchema = z.object({
1358
- orderItemId: z.string(),
1359
- refundAmount: z.number().int(),
1360
- refundedAt: z.string()
1361
- });
1362
- /** `PUT /v1/order-items/{orderItemId}/memo` 응답 — 빈 문자열로 저장하면 메모가 지워져 `null`이다 */
1363
- const orderItemMemoResultSchema = z.object({
1364
- orderItemId: z.string(),
1365
- sellerMemo: z.string().nullable()
1366
- });
1367
- /** `POST /v1/order-items/{orderItemId}/purchase-decision/request` 응답 */
1368
- const purchaseDecisionRequestResultSchema = z.object({
1369
- orderItemId: z.string(),
1370
- requestedAt: z.string()
1371
- });
1372
- /** `POST /v1/order-items/{orderItemId}/purchase-decision/extend` 응답 — 연장은 최대 2회 */
1373
- const purchaseDecisionExtendResultSchema = z.object({
1374
- orderItemId: z.string(),
1375
- autoDecisionDate: z.string(),
1376
- extendCount: z.number().int().max(2)
1377
- });
1378
- /**
1379
- * `GET /v1/orders/{orderId}/address-change-requests` 응답 — 배송지 변경 요청 플로우는 아직 제공하지 않아
1380
- * 현재는 항상 빈 배열이다
1381
- */
1382
- const addressChangeRequestListSchema = z.array(z.record(z.string(), z.unknown())).describe("배송지 변경 요청 목록 (현재 항상 빈 배열)");
1383
- //#endregion
1384
1185
  //#region src/schemas/payment.ts
1385
1186
  /**
1386
1187
  * 스토어 결제(PG) 설정과 매출 리포트 계약.
@@ -1397,13 +1198,22 @@ const pgPaymentMethodSchema = z.enum([
1397
1198
  "MOBILE",
1398
1199
  "EASY_PAY"
1399
1200
  ]).describe("결제수단 (스토어프론트 결제 요청의 `paymentMethod`와 같은 값)");
1400
- const paymentRoutingModeSchema = z.enum(["PRIORITY_DISPLAY", "AUTO_FAILOVER"]).describe("PG가 둘 이상 사용 중일 때의 라우팅 방식. `PRIORITY_DISPLAY`=결제창에 사용 중인 PG를 모두 보여 주고 1순위를 기본 선택, `AUTO_FAILOVER`=1순위로 결제창을 열고, 결제창을 띄우기 전 장애(PG 준비 실패)일 때만 다음 순위로 자동 전환");
1401
- const effectivePaymentRoutingModeSchema = z.enum([
1402
- "NONE",
1403
- "SINGLE",
1404
- "PRIORITY_DISPLAY",
1405
- "AUTO_FAILOVER"
1406
- ]).describe("실제로 적용되는 라우팅. 사용 중인 PG가 0개면 `NONE`(결제 불가), 1개면 `SINGLE`, 2개 이상이면 `routingMode` 값");
1201
+ /**
1202
+ * 간편결제사 — 결제 옵션(스토어프론트 `paymentOptions`)과 PG 설정의 `easyPayProviders`에 쓴다.
1203
+ * `@sayren/storefront-sdk`의 `easyPayProviderSchema`와 같은 값이다(api 계약 테스트가 고정한다)
1204
+ */
1205
+ const easyPayProviderSchema = z.enum([
1206
+ "NAVERPAY",
1207
+ "KAKAOPAY",
1208
+ "TOSSPAY",
1209
+ "PAYCO"
1210
+ ]);
1211
+ /**
1212
+ * 응답에 실리는 간편결제사 — 서버가 간편결제사를 추가해도 파싱이 깨지지 않게 문자열로 받는다
1213
+ * (`pgProvider`·결제수단과 같은 방식). 요청(`easyPayProviders`)은 값을 골라 보내는 자리라 enum 그대로다.
1214
+ * 현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 화면은 모르는 값을 원문 그대로 보여 준다.
1215
+ */
1216
+ const easyPayProviderResponseSchema = z.string();
1407
1217
  const pgEnvironmentSchema = z.enum(["TEST", "LIVE"]).describe("PG 결제 환경. `TEST`=PG 샌드박스(테스트 키, 실제로 돈이 오가지 않음), `LIVE`=실결제(운영 키)");
1408
1218
  const pgVerificationResultSchema = z.enum(["SUCCESS", "FAILED"]).describe("연결 테스트 결과");
1409
1219
  /** 비밀 값 입력 — 저장 후 다시 조회할 수 없다 */
@@ -1462,13 +1272,14 @@ const upsertPortOneProviderRequestSchema = z.object({
1462
1272
  });
1463
1273
  const updatePaymentProviderRequestSchema = z.object({
1464
1274
  enabled: z.boolean().optional().describe("사용 여부. 켜려면 활성 환경(샌드박스면 TEST, 아니면 LIVE) 자격 증명이 모두 저장돼 있어야 한다(`PAYMENT_PROVIDER_INCOMPLETE`)"),
1465
- sandboxMode: z.boolean().optional().describe("샌드박스 스위치. `true`면 새 결제에 TEST 세트를 쓴다(항상 허용). `false`(라이브 전환)는 라이브 개방 조건을 모두 충족해야 한다(`LIVE_GATE_NOT_MET`)")
1466
- }).refine((body) => body.enabled !== void 0 || body.sandboxMode !== void 0, { message: "enabled 또는 sandboxMode 중 하나는 보내야 해요" });
1275
+ sandboxMode: z.boolean().optional().describe("샌드박스 스위치. `true`면 새 결제에 TEST 세트를 쓴다(항상 허용). `false`(라이브 전환)는 라이브 개방 조건을 모두 충족해야 한다(`LIVE_GATE_NOT_MET`)"),
1276
+ easyPayProviders: z.array(easyPayProviderSchema).max(easyPayProviderSchema.options.length).optional().describe("이 PG로 받는 간편결제사 — 통째로 바꾼다. PG 계약(포트원은 채널)에 추가한 간편결제만 켠다. 켠 간편결제사마다 스토어프론트 결제 옵션이 하나씩 생긴다(포트원은 간편결제를 받는 채널이 있어야 한다)")
1277
+ }).refine((body) => body.enabled !== void 0 || body.sandboxMode !== void 0 || body.easyPayProviders !== void 0, { message: "enabled·sandboxMode·easyPayProviders 중 하나는 보내야 해요" });
1467
1278
  const verifyPaymentProviderRequestSchema = z.object({ environment: pgEnvironmentSchema.optional().describe("연결 테스트할 자격 증명 세트. 생략하면 활성 환경(샌드박스면 TEST, 아니면 LIVE)") });
1468
1279
  const updatePaymentSettingsRequestSchema = z.object({
1469
- routingMode: paymentRoutingModeSchema,
1470
- priority: z.array(pgProviderSchema).min(1).max(50).describe("PG 우선순위(앞이 1순위). 연결된 PG 수만큼 **모두 한 번씩** 나열한다(길이 상한 50은 안전장치다). 빠지거나 중복되거나 연결되지 않은 PG가 있으면 `INVALID_PRIORITY`")
1471
- });
1280
+ priority: z.array(pgProviderSchema).min(1).max(50).optional().describe("PG 우선순위(앞이 1순위) — 스토어프론트 결제 옵션 목록의 PG 순서다. 연결된 PG 수만큼 **모두 한 번씩** 나열한다(길이 상한 50은 안전장치다). 빠지거나 중복되거나 연결되지 않은 PG가 있으면 `INVALID_PRIORITY`"),
1281
+ checkoutOrigins: z.array(z.string().max(200)).max(20).optional().describe("결제 도메인 — 통째로 바꾼다. 결제를 마친 구매자가 돌아올 스토어프론트 origin(`https://shop.example.com`, https·경로 없음). 결제 시작의 `returnUrl`은 이 목록 안이어야 한다. 비어 있으면 실결제를 시작할 수 없다(테스트 결제는 localhost 허용). 같은 도메인을 PG 가맹 정보에도 등록한다. 형식이 틀리면 `INVALID_CHECKOUT_ORIGIN`")
1282
+ }).refine((body) => body.priority !== void 0 || body.checkoutOrigins !== void 0, { message: "priority 또는 checkoutOrigins 중 하나는 보내야 해요" });
1472
1283
  const maskedSecretSchema = z.object({
1473
1284
  field: z.string().describe("비밀 필드 이름 (`secretKey`·`apiSecret`·`webhookSecret`)"),
1474
1285
  configured: z.boolean().describe("값이 저장돼 있는가"),
@@ -1529,6 +1340,7 @@ const paymentProviderSchema = z.object({
1529
1340
  LIVE: paymentCredentialSetSchema.nullable()
1530
1341
  }).describe("환경별 자격 증명 세트. 등록되지 않은 세트는 null"),
1531
1342
  liveGate: liveGateSchema.describe("라이브 개방 조건. 조건을 모두 충족해야 샌드박스를 끌 수 있다"),
1343
+ easyPayProviders: z.array(easyPayProviderResponseSchema).describe("이 PG로 받는 간편결제사. 연결되지 않았으면 빈 목록. 현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 값이 추가될 수 있어 문자열로 받는다"),
1532
1344
  retiredCredentialCount: z.number().int().describe("보관된(가맹점 교체·연결 해제로 새 결제에 더 쓰이지 않는) 자격 증명 수. 그 가맹점으로 받은 결제의 환불·대사에 계속 쓰인다"),
1533
1345
  routingExclusion: z.string().nullable().optional().default(null).describe("지금 새 결제의 후보가 아닌 사유. 후보면 null. 판정 원천은 서버 라우팅이다(콘솔이 다시 계산하지 않는다). 후보가 아닌 PG에는 항상 사유 코드를 붙인다(연결 안 된 PG 포함) — 모든 PG는 `candidates`에 있거나 이 값이 null이 아니다. 현재 값: `NOT_CONNECTED`(연결 안 됨) · `DISABLED`(사용 중지) · `CREDENTIAL_MISSING`(활성 환경 자격 증명 없음) · `SANDBOX_IN_LIVE_STORE`(다른 PG가 라이브라 이 샌드박스 PG는 실구매자 결제에 쓰지 않음) · `PLATFORM_BLOCKED`(플랫폼이 실결제를 막음) · `MODE_MISMATCH`(라이브를 연 서버 모드와 현재 모드가 다름). 값이 추가될 수 있어 문자열로 받는다 — 모르는 값은 후보 아님으로 다룬다. 서버는 항상 싣는다. 이 필드가 없는 이전 서버 응답은 기본값(null)으로 읽는다")
1534
1346
  });
@@ -1545,8 +1357,7 @@ const PAYMENT_ROUTING_EXCLUSION_CODES = [
1545
1357
  "MODE_MISMATCH"
1546
1358
  ];
1547
1359
  const paymentSettingsSchema = z.object({
1548
- routingMode: paymentRoutingModeSchema.describe("저장된 라우팅 방식 (기본 `AUTO_FAILOVER`). PG가 하나뿐이면 무시된다"),
1549
- effectiveRoutingMode: effectivePaymentRoutingModeSchema,
1360
+ checkoutOrigins: z.array(z.string()).describe("결제 도메인 — 결제를 마친 구매자가 돌아올 스토어프론트 origin 목록"),
1550
1361
  providers: z.array(paymentProviderSchema).describe("지원하는 모든 PG. 연결된 것은 우선순위순, 연결되지 않은 것은 뒤에 온다"),
1551
1362
  environment: pgEnvironmentSchema.nullable().optional().default(null).describe("지금 결제를 시작하면 쓰는 결제 환경. 사용 가능한 PG 중 하나라도 라이브면 `LIVE`(샌드박스 PG는 제외), 아니면 `TEST`. 사용 가능한 PG가 없으면 null. 서버는 항상 싣는다. 이 필드가 없는 이전 서버 응답은 기본값(null)으로 읽는다"),
1552
1363
  candidates: z.array(z.string()).optional().default(() => []).describe("지금 결제를 시작하면 쓰는 PG, 우선순위순(`tosspayments`·`portone`). 비어 있으면 구매자가 결제할 수 없다. 빠진 PG의 사유는 `providers[].routingExclusion` — 후보가 아닌 PG에는 항상 사유 코드를 붙인다. 서버는 항상 싣는다. 이 필드가 없는 이전 서버 응답은 기본값(빈 배열)으로 읽는다")
@@ -1623,6 +1434,7 @@ const paymentRecordSchema = z.object({
1623
1434
  refundedAmount: z.number().int().describe("환불 완료 금액 합계. 실패한 환불은 빼고 센다"),
1624
1435
  provider: pgProviderSchema.nullable().describe("승인한 PG. 승인 전에 끝났으면 마지막 시도의 PG"),
1625
1436
  method: pgPaymentMethodSchema.nullable().describe("실제 결제수단. 모르면 요청 수단"),
1437
+ easyPayProvider: easyPayProviderResponseSchema.nullable().optional().default(null).describe("간편결제사. `method`가 `EASY_PAY`일 때만 값이 있고, PG가 알려 주지 않았으면 요청한 간편결제사다. 그 밖의 결제수단과 간편결제 이전 결제는 null. 서버는 항상 싣는다. 현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 값이 추가될 수 있어 문자열로 받는다"),
1626
1438
  environment: pgEnvironmentSchema.nullable().describe("결제 환경"),
1627
1439
  testPayment: z.boolean().describe("샌드박스 결제인가"),
1628
1440
  pgTransactionId: z.string().nullable().describe("PG 거래 id (토스 paymentKey, 포트원 txId)"),
@@ -1640,7 +1452,9 @@ const paymentAttemptRecordSchema = z.object({
1640
1452
  provider: pgProviderSchema,
1641
1453
  status: paymentAttemptStatusSchema,
1642
1454
  method: pgPaymentMethodSchema.describe("주문서에서 고른 결제수단"),
1455
+ easyPayProvider: easyPayProviderResponseSchema.nullable().optional().default(null).describe("주문서에서 고른 간편결제사. 간편결제가 아니면 null. 서버는 항상 싣는다(값이 추가될 수 있어 문자열)"),
1643
1456
  approvedMethod: pgPaymentMethodSchema.nullable().describe("PG가 보고한 실제 결제수단"),
1457
+ approvedEasyPayProvider: easyPayProviderResponseSchema.nullable().optional().default(null).describe("PG가 보고한 실제 간편결제사. 모르거나 간편결제가 아니면 null. 서버는 항상 싣는다(값이 추가될 수 있어 문자열)"),
1644
1458
  amount: z.number().int(),
1645
1459
  environment: pgEnvironmentSchema,
1646
1460
  pgTransactionId: z.string().nullable(),
@@ -1678,6 +1492,206 @@ const paymentListQuerySchema = z.object({
1678
1492
  size: z.string().optional().describe("페이지 크기 (기본 20, 최대 100)")
1679
1493
  });
1680
1494
  //#endregion
1495
+ //#region src/schemas/order.ts
1496
+ const orderSummarySchema = z.object({
1497
+ orderId: z.string(),
1498
+ ordererName: z.string(),
1499
+ itemCount: z.number().int(),
1500
+ totalAmount: z.number().int(),
1501
+ representativeStatus: orderItemStatusSchema,
1502
+ orderedAt: z.string(),
1503
+ testPayment: z.boolean().describe("테스트 결제(샌드박스 결제) 주문인가. true면 실제로 돈이 오가지 않았어요. 상품을 발송하지 않도록 주의하세요")
1504
+ });
1505
+ const shippingAddressSchema = z.object({
1506
+ receiverName: z.string(),
1507
+ phone: z.string(),
1508
+ zipCode: z.string(),
1509
+ address1: z.string(),
1510
+ address2: z.string().nullish(),
1511
+ deliveryMemo: z.string().nullish(),
1512
+ entranceCode: z.string().nullish()
1513
+ });
1514
+ const orderItemSchema = z.object({
1515
+ orderItemId: z.string(),
1516
+ orderId: z.string(),
1517
+ status: orderItemStatusSchema,
1518
+ claimStatus: z.enum([
1519
+ "CANCEL_REQUESTED",
1520
+ "RETURN_REQUESTED",
1521
+ "EXCHANGE_REQUESTED"
1522
+ ]).nullable(),
1523
+ productId: z.string(),
1524
+ productName: z.string(),
1525
+ optionId: z.string().nullable(),
1526
+ optionName: z.string().nullable(),
1527
+ sellerCode: z.string().nullable(),
1528
+ quantity: z.number().int(),
1529
+ unitPrice: z.number().int(),
1530
+ discountAmount: z.number().int(),
1531
+ totalPrice: z.number().int(),
1532
+ hold: z.object({
1533
+ reason: z.string(),
1534
+ expectedDispatchDate: z.string()
1535
+ }).nullable(),
1536
+ autoDecisionDate: z.string().nullable(),
1537
+ sellerMemo: z.string().nullable(),
1538
+ orderedAt: z.string(),
1539
+ lastChangedAt: z.string(),
1540
+ lastChangedType: changeTypeSchema,
1541
+ testPayment: z.boolean().describe("소속 주문이 테스트 결제(샌드박스 결제) 주문인가. true면 실제로 돈이 오가지 않았어요")
1542
+ });
1543
+ const orderSchema = z.object({
1544
+ orderId: z.string(),
1545
+ orderedAt: z.string(),
1546
+ orderer: z.object({
1547
+ name: z.string(),
1548
+ phone: z.string(),
1549
+ email: z.email().optional()
1550
+ }),
1551
+ shippingAddress: shippingAddressSchema,
1552
+ payment: z.object({
1553
+ method: z.enum([
1554
+ "CARD",
1555
+ "BANK_TRANSFER",
1556
+ "VIRTUAL_ACCOUNT",
1557
+ "MOBILE",
1558
+ "POINT",
1559
+ "MIXED"
1560
+ ]).describe("method는 호환용이며 간편결제를 CARD로 표시한다. 실제 수단은 approvedMethod를 본다"),
1561
+ approvedMethod: z.string().nullable().optional().default(null).describe("실제 결제수단. method는 호환용이며 간편결제를 CARD로 표시한다. 실제 수단은 approvedMethod를 본다. 현재 값은 `pgPaymentMethodSchema`(`PgPaymentMethod`: CARD·BANK_TRANSFER·VIRTUAL_ACCOUNT·MOBILE·EASY_PAY)이고 매출 리포트·스토어프론트·환불 원장과 같은 값이다. 값이 추가될 수 있어 문자열로 받는다. PG가 알려 주지 않았으면 요청 수단, 시도 기록이 없는 오래된 주문은 null. 서버는 항상 싣는다"),
1562
+ easyPayProvider: easyPayProviderResponseSchema.nullable().optional().default(null).describe("승인된 간편결제사. `approvedMethod`가 `EASY_PAY`일 때만 값이 있고, PG가 알려 주지 않았으면 요청한 간편결제사다. 그 밖의 결제수단과 간편결제 이전 주문은 null. 서버는 항상 싣는다. 현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 값이 추가될 수 있어 문자열로 받는다"),
1563
+ productAmount: z.number().int(),
1564
+ deliveryFee: z.number().int(),
1565
+ discountAmount: z.number().int(),
1566
+ totalAmount: z.number().int(),
1567
+ paidAt: z.string().nullable()
1568
+ }),
1569
+ testPayment: z.boolean().describe("테스트 결제(샌드박스 결제) 주문인가. true면 실제로 돈이 오가지 않았어요. 상품을 발송하지 않도록 주의하세요"),
1570
+ items: z.array(orderItemSchema)
1571
+ });
1572
+ /** 주문 목록 응답 — `GET /v1/orders` */
1573
+ const orderSummaryPageSchema = pageSchema(orderSummarySchema);
1574
+ /** 주문상품 변경 목록 응답 — `GET /v1/order-items` */
1575
+ const orderItemPageSchema = pageSchema(orderItemSchema);
1576
+ const testPaymentQuery = z.enum(["true", "false"]).optional().describe("테스트 결제(샌드박스 결제) 필터. `true`면 테스트 결제만, `false`면 실결제만, 생략하면 전부예요");
1577
+ const pageQuery = { page: z.string().optional().describe("페이지 번호 (1부터, 기본 1)") };
1578
+ /**
1579
+ * `GET /v1/orders` 쿼리 — OpenAPI 문서용 형태(값은 쿼리 문자열). 검증 규칙은 서버가 적용한다:
1580
+ * `orderedFrom` 누락 400 `MISSING_PARAMETER`, 날짜 형식 오류 400 `INVALID_PARAMETER`, 31일 초과 400 `RANGE_TOO_WIDE`,
1581
+ * `testPayment`가 `true`·`false`가 아니면 400 `INVALID_PARAMETER`
1582
+ */
1583
+ const orderListQuerySchema = z.object({
1584
+ orderedFrom: z.string().describe("조회 시작 시각 (ISO 8601 날짜 또는 일시, 포함). 필수"),
1585
+ orderedTo: z.string().optional().describe("조회 끝 시각 (ISO 8601, 포함). 생략하면 orderedFrom부터 31일. 기간은 최대 31일"),
1586
+ status: orderItemStatusSchema.optional().describe("주문상품 상태 필터 — 이 상태의 주문상품이 하나라도 있는 주문"),
1587
+ keyword: z.string().optional().describe("주문번호(일치)·주문자명·수령인명(포함) 검색"),
1588
+ testPayment: testPaymentQuery,
1589
+ ...pageQuery,
1590
+ size: z.string().optional().describe("페이지 크기 (기본 20, 최대 100)")
1591
+ });
1592
+ /**
1593
+ * `GET /v1/order-items` 쿼리 — OpenAPI 문서용 형태. `lastChangedFrom` 누락 400 `MISSING_PARAMETER`, 형식 오류 400
1594
+ * `INVALID_PARAMETER`, 24시간 초과 400 `RANGE_TOO_WIDE`, `testPayment` 값 오류 400 `INVALID_PARAMETER`
1595
+ */
1596
+ const orderItemListQuerySchema = z.object({
1597
+ lastChangedFrom: z.string().describe("마지막 변경 시각 조회 시작 (ISO 8601, 포함). 필수"),
1598
+ lastChangedTo: z.string().optional().describe("마지막 변경 시각 조회 끝 (ISO 8601, 포함). 생략하면 시작부터 24시간. 기간은 최대 24시간"),
1599
+ lastChangedType: changeTypeSchema.optional().describe("마지막 변경 유형 필터"),
1600
+ testPayment: testPaymentQuery,
1601
+ ...pageQuery,
1602
+ size: z.string().optional().describe("페이지 크기 (기본 100, 최대 300)")
1603
+ });
1604
+ const deliveryMethodSchema = z.enum([
1605
+ "COURIER",
1606
+ "DIRECT",
1607
+ "QUICK",
1608
+ "NOTHING"
1609
+ ]);
1610
+ const dispatchRequestSchema = z.object({
1611
+ deliveryMethod: deliveryMethodSchema,
1612
+ carrierCode: z.string().optional(),
1613
+ trackingNumber: z.string().optional(),
1614
+ dispatchedAt: z.string().optional()
1615
+ }).refine((value) => value.deliveryMethod === "DIRECT" || value.deliveryMethod === "NOTHING" ? true : !!value.carrierCode && !!value.trackingNumber, { message: "COURIER/QUICK 발송은 carrierCode와 trackingNumber가 필수입니다" });
1616
+ const deliveryInfoSchema = z.object({
1617
+ orderItemId: z.string(),
1618
+ deliveryMethod: deliveryMethodSchema,
1619
+ carrierCode: z.string().nullable(),
1620
+ carrierName: z.string().nullable(),
1621
+ trackingNumber: z.string().nullable(),
1622
+ trackingUrl: z.url().nullable(),
1623
+ status: z.enum([
1624
+ "DISPATCHED",
1625
+ "DELIVERING",
1626
+ "DELIVERED"
1627
+ ]),
1628
+ dispatchedAt: z.string(),
1629
+ deliveredAt: z.string().nullable()
1630
+ });
1631
+ /** `GET /v1/order-items/{orderItemId}/delivery` 응답 — 배송 정보 + 배송 추적 이벤트 */
1632
+ const deliveryStatusSchema = deliveryInfoSchema.extend({ trackingEvents: z.array(z.object({
1633
+ status: z.string(),
1634
+ location: z.string(),
1635
+ occurredAt: z.string()
1636
+ })).optional() });
1637
+ /** `PUT /v1/order-items/{orderItemId}/dispatch/tracking` 응답 — 바뀐 송장 */
1638
+ const trackingUpdateResultSchema = z.object({
1639
+ orderItemId: z.string(),
1640
+ carrierCode: z.string(),
1641
+ trackingNumber: z.string()
1642
+ });
1643
+ const carrierSchema = z.object({
1644
+ carrierCode: z.string(),
1645
+ name: z.string(),
1646
+ trackingUrlTemplate: z.string()
1647
+ });
1648
+ const holdOrderItemRequestSchema = z.object({
1649
+ reason: z.enum([
1650
+ "OUT_OF_STOCK",
1651
+ "CUSTOMER_REQUEST",
1652
+ "CUSTOMS",
1653
+ "ETC"
1654
+ ]),
1655
+ detail: z.string().max(500).optional(),
1656
+ expectedDispatchDate: z.string()
1657
+ });
1658
+ const cancelBySellerRequestSchema = z.object({
1659
+ reason: z.enum([
1660
+ "OUT_OF_STOCK",
1661
+ "PRICE_ERROR",
1662
+ "DELIVERY_IMPOSSIBLE",
1663
+ "ETC"
1664
+ ]),
1665
+ detail: z.string().max(500).optional()
1666
+ });
1667
+ /** `POST /v1/order-items/{orderItemId}/cancel` 응답 — 셀러 직권취소 환불 결과 */
1668
+ const cancelBySellerResultSchema = z.object({
1669
+ orderItemId: z.string(),
1670
+ refundAmount: z.number().int(),
1671
+ refundedAt: z.string()
1672
+ });
1673
+ /** `PUT /v1/order-items/{orderItemId}/memo` 응답 — 빈 문자열로 저장하면 메모가 지워져 `null`이다 */
1674
+ const orderItemMemoResultSchema = z.object({
1675
+ orderItemId: z.string(),
1676
+ sellerMemo: z.string().nullable()
1677
+ });
1678
+ /** `POST /v1/order-items/{orderItemId}/purchase-decision/request` 응답 */
1679
+ const purchaseDecisionRequestResultSchema = z.object({
1680
+ orderItemId: z.string(),
1681
+ requestedAt: z.string()
1682
+ });
1683
+ /** `POST /v1/order-items/{orderItemId}/purchase-decision/extend` 응답 — 연장은 최대 2회 */
1684
+ const purchaseDecisionExtendResultSchema = z.object({
1685
+ orderItemId: z.string(),
1686
+ autoDecisionDate: z.string(),
1687
+ extendCount: z.number().int().max(2)
1688
+ });
1689
+ /**
1690
+ * `GET /v1/orders/{orderId}/address-change-requests` 응답 — 배송지 변경 요청 플로우는 아직 제공하지 않아
1691
+ * 현재는 항상 빈 배열이다
1692
+ */
1693
+ const addressChangeRequestListSchema = z.array(z.record(z.string(), z.unknown())).describe("배송지 변경 요청 목록 (현재 항상 빈 배열)");
1694
+ //#endregion
1681
1695
  //#region src/schemas/product.ts
1682
1696
  const productStatusSchema = z.enum([
1683
1697
  "SALE",
@@ -2912,4 +2926,4 @@ function createStoreSession(options) {
2912
2926
  };
2913
2927
  }
2914
2928
  //#endregion
2915
- export { ApiError, MAX_ANALYTICS_ALLOWED_ORIGINS, MAX_OPTION_GROUPS, MAX_VALUES_PER_GROUP, MAX_VARIANTS, PAYMENT_ROUTING_EXCLUSION_CODES, PORTONE_CHANNEL_NAME_MAX_LENGTH, PORTONE_MAX_CHANNELS, PORTONE_MIN_CHANNELS, RESERVED_STORE_CODES, STORE_CODE_PATTERN, STORE_ROLE_SCOPES, STORE_SCOPE_RESOURCES, STORE_SESSION_KEYS, TOSS_WIDGET_CLIENT_KEY_PATTERN, TOSS_WIDGET_KEY_MESSAGE, TOSS_WIDGET_SECRET_KEY_PATTERN, VARIANT_STOCK_EXCLUSIVE_MESSAGE, WEBHOOK_DEFAULT_TOLERANCE_SEC, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_EVENT_TYPE_HEADER, WEBHOOK_HEADERS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_USER_AGENT, addressChangeRequestListSchema, addressTypeSchema, analyticsChannelSchema, analyticsCheckoutOutcomeSchema, analyticsCheckoutSchema, analyticsDeviceRowSchema, analyticsDevicesSchema, analyticsFunnelStepSchema, analyticsOriginSchema, analyticsOverviewSchema, analyticsPagesQuerySchema, analyticsPagesSchema, analyticsProductRowSchema, analyticsProductSortSchema, analyticsProductsQuerySchema, analyticsProductsSchema, analyticsRangeQuerySchema, analyticsRealtimeSchema, analyticsSearchQuerySchema, analyticsSearchSchema, analyticsSourceGroupBySchema, analyticsSourceRowSchema, analyticsSourcesQuerySchema, analyticsSourcesSchema, analyticsTotalsSchema, apiClientListQuerySchema, apiClientSchema, apiClientSecretRotatedSchema, apiClientStatusSchema, apiClientTypeSchema, apiLogErrorSchema, apiLogListQuerySchema, apiLogPageSchema, apiLogPrincipalSchema, apiLogPrincipalTypeSchema, apiLogSchema, apiLogStatusFilterSchema, apiLogSummarySchema, apiTokenCreateRequestSchema, apiTokenCreatedSchema, apiTokenSchema, approveClaimResultSchema, buildAuthorizeUrl, buildQuery, bulkResultSchema, cancelBySellerRequestSchema, cancelBySellerResultSchema, carrierSchema, categoryAttributeSchema, categoryCreateRequestSchema, categoryDeleteQuerySchema, categoryDeleteStrategySchema, categoryListQuerySchema, categoryPatchRequestSchema, categoryProductSortSchema, categorySchema, categorySearchResultSchema, categoryTreeNodeSchema, categoryWithPathSchema, changeTypeSchema, claimDetailSchema, claimHoldResultSchema, claimListQuerySchema, claimReasonSchema, claimSchema, claimStatusSchema, claimTypeSchema, claimWebhookEventDataSchema, claimWebhookEventSchema, clientCredentialsTokenResponseSchema, createPkcePair, createStoreClient, createStoreSession, customerAddressSchema, customerDetailSchema, customerInquiryCategorySchema, customerInquiryListQuerySchema, customerListQuerySchema, customerOrderSchema, customerSortSchema, customerStatsSchema, customerSummarySchema, customerWithdrawalBlockedDetailsSchema, deliveryInfoSchema, deliveryMethodSchema, deliveryStatusSchema, deliveryTypeSchema, discountRequestSchema, discountSchema, dispatchRequestSchema, effectivePaymentRoutingModeSchema, eventTypeSchema, exchangeAuthorizationCode, exchangeStoreTokenViaOAuth, holdOrderItemRequestSchema, inquiryListQuerySchema, inquirySchema, inquiryWebhookEventDataSchema, inquiryWebhookEventSchema, invitationListQuerySchema, invitationSchema, isReservedStoreCode, isStoreScope, isWebOrigin, liveGateConditionCodeSchema, liveGateConditionSchema, liveGateErrorDetailsSchema, liveGateSchema, loginProviderSchema, loginProviderStatusSchema, loginProviderTestSchema, loginSettingsSchema, maskedSecretSchema, myAccountSchema, myStoreSchema, oauthClientRegistrationRequestSchema, oauthClientRegistrationResponseSchema, oauthTokenResponseSchema, optionGroupRequestSchema, optionGroupSchema, optionModelRequestSchema, optionModelSchema, optionValueRequestSchema, optionValueSchema, orderItemListQuerySchema, orderItemMemoResultSchema, orderItemPageSchema, orderItemSchema, orderItemStatusSchema, orderListQuerySchema, orderSchema, orderSummaryPageSchema, orderSummarySchema, orderWebhookEventDataSchema, orderWebhookEventSchema, pageInfoSchema, pageQueryShape, pageSchema, paymentAttemptRecordSchema, paymentAttemptStatusSchema, paymentCredentialSetSchema, paymentListQuerySchema, paymentProviderSchema, paymentProviderVerificationSchema, paymentRecordDetailSchema, paymentRecordPageSchema, paymentRecordSchema, paymentRecordStatusSchema, paymentRefundRecordSchema, paymentRoutingModeSchema, paymentSettingsSchema, pgEnvironmentSchema, pgPaymentMethodSchema, pgProviderSchema, pgVerificationResultSchema, portOneChannelSchema, portOneCredentialsInputSchema, productCreateRequestSchema, productImageUploadResultSchema, productListQuerySchema, productOutOfStockWebhookEventDataSchema, productOutOfStockWebhookEventSchema, productPatchRequestSchema, productSchema, productSortSchema, productStatusSchema, productSummarySchema, productVariantRequestSchema, productVariantSchema, purchaseDecisionExtendResultSchema, purchaseDecisionRequestResultSchema, refreshUserToken, rejectClaimRequestSchema, reviewListQuerySchema, reviewReportResultSchema, reviewSchema, reviewSortSchema, reviewWebhookEventDataSchema, reviewWebhookEventSchema, salesReportGroupBySchema, salesReportQuerySchema, salesReportRowSchema, salesReportSchema, salesTotalsSchema, saveLoginProviderRequestSchema, scopeAccessSchema, sellerAddressListQuerySchema, sellerAddressRequestSchema, sellerAddressSchema, sellerCustomerInquirySchema, settlementDetailQuerySchema, settlementDetailSchema, settlementListQuerySchema, settlementStatusSchema, settlementSummarySchema, settlementWithDetailsSchema, shippingAddressSchema, storeCodeSchema, storeMemberRoleUpdatedSchema, storeMemberSchema, storeRoleSchema, storeSchema, storeScopeResourceSchema, storeTokenResponseSchema, tossPaymentsCredentialsInputSchema, trackingUpdateResultSchema, updateLoginProviderRequestSchema, updateLoginSettingsRequestSchema, updatePaymentProviderRequestSchema, updatePaymentSettingsRequestSchema, updateStoreRequestSchema, uploadRequestSchema, uploadTicketSchema, upsertPortOneProviderRequestSchema, upsertTossPaymentsProviderRequestSchema, userTokenResponseSchema, variantStockRequestSchema, variantStockSchema, verifyPaymentProviderRequestSchema, webhookCreatedSchema, webhookDeliveryErrorCodeSchema, webhookDeliveryListQuerySchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEventSchema, webhookRedeliverFailedResultSchema, webhookRequestSchema, webhookSchema, webhookSecretRotatedSchema, webhookStatusSchema, webhookTestRequestSchema, webhookTestResultSchema, withdrawCustomerRequestSchema };
2929
+ export { ApiError, MAX_ANALYTICS_ALLOWED_ORIGINS, MAX_OPTION_GROUPS, MAX_VALUES_PER_GROUP, MAX_VARIANTS, PAYMENT_ROUTING_EXCLUSION_CODES, PORTONE_CHANNEL_NAME_MAX_LENGTH, PORTONE_MAX_CHANNELS, PORTONE_MIN_CHANNELS, RESERVED_STORE_CODES, STORE_CODE_PATTERN, STORE_ROLE_SCOPES, STORE_SCOPE_RESOURCES, STORE_SESSION_KEYS, TOSS_WIDGET_CLIENT_KEY_PATTERN, TOSS_WIDGET_KEY_MESSAGE, TOSS_WIDGET_SECRET_KEY_PATTERN, VARIANT_STOCK_EXCLUSIVE_MESSAGE, WEBHOOK_DEFAULT_TOLERANCE_SEC, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_EVENT_TYPE_HEADER, WEBHOOK_HEADERS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_USER_AGENT, addressChangeRequestListSchema, addressTypeSchema, analyticsChannelSchema, analyticsCheckoutOutcomeSchema, analyticsCheckoutSchema, analyticsDeviceRowSchema, analyticsDevicesSchema, analyticsFunnelStepSchema, analyticsOriginSchema, analyticsOverviewSchema, analyticsPagesQuerySchema, analyticsPagesSchema, analyticsProductRowSchema, analyticsProductSortSchema, analyticsProductsQuerySchema, analyticsProductsSchema, analyticsRangeQuerySchema, analyticsRealtimeSchema, analyticsSearchQuerySchema, analyticsSearchSchema, analyticsSourceGroupBySchema, analyticsSourceRowSchema, analyticsSourcesQuerySchema, analyticsSourcesSchema, analyticsTotalsSchema, apiClientListQuerySchema, apiClientSchema, apiClientSecretRotatedSchema, apiClientStatusSchema, apiClientTypeSchema, apiLogErrorSchema, apiLogListQuerySchema, apiLogPageSchema, apiLogPrincipalSchema, apiLogPrincipalTypeSchema, apiLogSchema, apiLogStatusFilterSchema, apiLogSummarySchema, apiTokenCreateRequestSchema, apiTokenCreatedSchema, apiTokenSchema, approveClaimResultSchema, buildAuthorizeUrl, buildQuery, bulkResultSchema, cancelBySellerRequestSchema, cancelBySellerResultSchema, carrierSchema, categoryAttributeSchema, categoryCreateRequestSchema, categoryDeleteQuerySchema, categoryDeleteStrategySchema, categoryListQuerySchema, categoryPatchRequestSchema, categoryProductSortSchema, categorySchema, categorySearchResultSchema, categoryTreeNodeSchema, categoryWithPathSchema, changeTypeSchema, claimDetailSchema, claimHoldResultSchema, claimListQuerySchema, claimReasonSchema, claimSchema, claimStatusSchema, claimTypeSchema, claimWebhookEventDataSchema, claimWebhookEventSchema, clientCredentialsTokenResponseSchema, createPkcePair, createStoreClient, createStoreSession, customerAddressSchema, customerDetailSchema, customerInquiryCategorySchema, customerInquiryListQuerySchema, customerListQuerySchema, customerOrderSchema, customerSortSchema, customerStatsSchema, customerSummarySchema, customerWithdrawalBlockedDetailsSchema, deliveryInfoSchema, deliveryMethodSchema, deliveryStatusSchema, deliveryTypeSchema, discountRequestSchema, discountSchema, dispatchRequestSchema, easyPayProviderResponseSchema, easyPayProviderSchema, eventTypeSchema, exchangeAuthorizationCode, exchangeStoreTokenViaOAuth, holdOrderItemRequestSchema, inquiryListQuerySchema, inquirySchema, inquiryWebhookEventDataSchema, inquiryWebhookEventSchema, invitationListQuerySchema, invitationSchema, isReservedStoreCode, isStoreScope, isWebOrigin, liveGateConditionCodeSchema, liveGateConditionSchema, liveGateErrorDetailsSchema, liveGateSchema, loginProviderSchema, loginProviderStatusSchema, loginProviderTestSchema, loginSettingsSchema, maskedSecretSchema, myAccountSchema, myStoreSchema, oauthClientRegistrationRequestSchema, oauthClientRegistrationResponseSchema, oauthTokenResponseSchema, optionGroupRequestSchema, optionGroupSchema, optionModelRequestSchema, optionModelSchema, optionValueRequestSchema, optionValueSchema, orderItemListQuerySchema, orderItemMemoResultSchema, orderItemPageSchema, orderItemSchema, orderItemStatusSchema, orderListQuerySchema, orderSchema, orderSummaryPageSchema, orderSummarySchema, orderWebhookEventDataSchema, orderWebhookEventSchema, pageInfoSchema, pageQueryShape, pageSchema, paymentAttemptRecordSchema, paymentAttemptStatusSchema, paymentCredentialSetSchema, paymentListQuerySchema, paymentProviderSchema, paymentProviderVerificationSchema, paymentRecordDetailSchema, paymentRecordPageSchema, paymentRecordSchema, paymentRecordStatusSchema, paymentRefundRecordSchema, paymentSettingsSchema, pgEnvironmentSchema, pgPaymentMethodSchema, pgProviderSchema, pgVerificationResultSchema, portOneChannelSchema, portOneCredentialsInputSchema, productCreateRequestSchema, productImageUploadResultSchema, productListQuerySchema, productOutOfStockWebhookEventDataSchema, productOutOfStockWebhookEventSchema, productPatchRequestSchema, productSchema, productSortSchema, productStatusSchema, productSummarySchema, productVariantRequestSchema, productVariantSchema, purchaseDecisionExtendResultSchema, purchaseDecisionRequestResultSchema, refreshUserToken, rejectClaimRequestSchema, reviewListQuerySchema, reviewReportResultSchema, reviewSchema, reviewSortSchema, reviewWebhookEventDataSchema, reviewWebhookEventSchema, salesReportGroupBySchema, salesReportQuerySchema, salesReportRowSchema, salesReportSchema, salesTotalsSchema, saveLoginProviderRequestSchema, scopeAccessSchema, sellerAddressListQuerySchema, sellerAddressRequestSchema, sellerAddressSchema, sellerCustomerInquirySchema, settlementDetailQuerySchema, settlementDetailSchema, settlementListQuerySchema, settlementStatusSchema, settlementSummarySchema, settlementWithDetailsSchema, shippingAddressSchema, storeCodeSchema, storeMemberRoleUpdatedSchema, storeMemberSchema, storeRoleSchema, storeSchema, storeScopeResourceSchema, storeTokenResponseSchema, tossPaymentsCredentialsInputSchema, trackingUpdateResultSchema, updateLoginProviderRequestSchema, updateLoginSettingsRequestSchema, updatePaymentProviderRequestSchema, updatePaymentSettingsRequestSchema, updateStoreRequestSchema, uploadRequestSchema, uploadTicketSchema, upsertPortOneProviderRequestSchema, upsertTossPaymentsProviderRequestSchema, userTokenResponseSchema, variantStockRequestSchema, variantStockSchema, verifyPaymentProviderRequestSchema, webhookCreatedSchema, webhookDeliveryErrorCodeSchema, webhookDeliveryListQuerySchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEventSchema, webhookRedeliverFailedResultSchema, webhookRequestSchema, webhookSchema, webhookSecretRotatedSchema, webhookStatusSchema, webhookTestRequestSchema, webhookTestResultSchema, withdrawCustomerRequestSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sayren/store-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "main": "./dist/index.mjs",
5
5
  "types": "./dist/index.d.mts",
6
6
  "exports": {
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { changeTypeSchema, orderItemStatusSchema, type PageParams, pageSchema } from "./common";
3
+ import { easyPayProviderResponseSchema } from "./payment";
3
4
 
4
5
  export const orderSummarySchema = z.object({
5
6
  orderId: z.string(),
@@ -84,6 +85,15 @@ export const orderSchema = z.object({
84
85
  "매출 리포트·스토어프론트·환불 원장과 같은 값이다. 값이 추가될 수 있어 문자열로 받는다. PG가 알려 주지 않았으면 요청 수단, " +
85
86
  "시도 기록이 없는 오래된 주문은 null. 서버는 항상 싣는다",
86
87
  ),
88
+ easyPayProvider: easyPayProviderResponseSchema
89
+ .nullable()
90
+ .optional()
91
+ .default(null)
92
+ .describe(
93
+ "승인된 간편결제사. `approvedMethod`가 `EASY_PAY`일 때만 값이 있고, PG가 알려 주지 않았으면 요청한 간편결제사다. " +
94
+ "그 밖의 결제수단과 간편결제 이전 주문은 null. 서버는 항상 싣는다. " +
95
+ "현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 값이 추가될 수 있어 문자열로 받는다",
96
+ ),
87
97
  productAmount: z.number().int(),
88
98
  deliveryFee: z.number().int(),
89
99
  discountAmount: z.number().int(),
@@ -19,20 +19,19 @@ export const pgPaymentMethodSchema = z
19
19
  .describe("결제수단 (스토어프론트 결제 요청의 `paymentMethod`와 같은 값)");
20
20
  export type PgPaymentMethod = z.infer<typeof pgPaymentMethodSchema>;
21
21
 
22
- export const paymentRoutingModeSchema = z
23
- .enum(["PRIORITY_DISPLAY", "AUTO_FAILOVER"])
24
- .describe(
25
- "PG가 둘 이상 사용 중일 때의 라우팅 방식. `PRIORITY_DISPLAY`=결제창에 사용 중인 PG를 모두 보여 주고 1순위를 기본 선택, " +
26
- "`AUTO_FAILOVER`=1순위로 결제창을 열고, 결제창을 띄우기 전 장애(PG 준비 실패)일 때만 다음 순위로 자동 전환",
27
- );
28
- export type PaymentRoutingMode = z.infer<typeof paymentRoutingModeSchema>;
22
+ /**
23
+ * 간편결제사 — 결제 옵션(스토어프론트 `paymentOptions`)과 PG 설정의 `easyPayProviders`에 쓴다.
24
+ * `@sayren/storefront-sdk`의 `easyPayProviderSchema`와 같은 값이다(api 계약 테스트가 고정한다)
25
+ */
26
+ export const easyPayProviderSchema = z.enum(["NAVERPAY", "KAKAOPAY", "TOSSPAY", "PAYCO"]);
27
+ export type EasyPayProvider = z.infer<typeof easyPayProviderSchema>;
29
28
 
30
- export const effectivePaymentRoutingModeSchema = z
31
- .enum(["NONE", "SINGLE", "PRIORITY_DISPLAY", "AUTO_FAILOVER"])
32
- .describe(
33
- "실제로 적용되는 라우팅. 사용 중인 PG가 0개면 `NONE`(결제 불가), 1개면 `SINGLE`, 2개 이상이면 `routingMode` 값",
34
- );
35
- export type EffectivePaymentRoutingMode = z.infer<typeof effectivePaymentRoutingModeSchema>;
29
+ /**
30
+ * 응답에 실리는 간편결제사 — 서버가 간편결제사를 추가해도 파싱이 깨지지 않게 문자열로 받는다
31
+ * (`pgProvider`·결제수단과 같은 방식). 요청(`easyPayProviders`)은 값을 골라 보내는 자리라 enum 그대로다.
32
+ * 현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 화면은 모르는 값을 원문 그대로 보여 준다.
33
+ */
34
+ export const easyPayProviderResponseSchema = z.string();
36
35
 
37
36
  export const pgEnvironmentSchema = z
38
37
  .enum(["TEST", "LIVE"])
@@ -174,10 +173,22 @@ export const updatePaymentProviderRequestSchema = z
174
173
  "샌드박스 스위치. `true`면 새 결제에 TEST 세트를 쓴다(항상 허용). `false`(라이브 전환)는 라이브 개방 조건을 " +
175
174
  "모두 충족해야 한다(`LIVE_GATE_NOT_MET`)",
176
175
  ),
176
+ easyPayProviders: z
177
+ .array(easyPayProviderSchema)
178
+ .max(easyPayProviderSchema.options.length)
179
+ .optional()
180
+ .describe(
181
+ "이 PG로 받는 간편결제사 — 통째로 바꾼다. PG 계약(포트원은 채널)에 추가한 간편결제만 켠다. " +
182
+ "켠 간편결제사마다 스토어프론트 결제 옵션이 하나씩 생긴다(포트원은 간편결제를 받는 채널이 있어야 한다)",
183
+ ),
177
184
  })
178
- .refine((body) => body.enabled !== undefined || body.sandboxMode !== undefined, {
179
- message: "enabled 또는 sandboxMode 중 하나는 보내야 해요",
180
- });
185
+ .refine(
186
+ (body) =>
187
+ body.enabled !== undefined ||
188
+ body.sandboxMode !== undefined ||
189
+ body.easyPayProviders !== undefined,
190
+ { message: "enabled·sandboxMode·easyPayProviders 중 하나는 보내야 해요" },
191
+ );
181
192
  export type UpdatePaymentProviderRequest = z.infer<typeof updatePaymentProviderRequestSchema>;
182
193
 
183
194
  export const verifyPaymentProviderRequestSchema = z.object({
@@ -187,18 +198,31 @@ export const verifyPaymentProviderRequestSchema = z.object({
187
198
  });
188
199
  export type VerifyPaymentProviderRequest = z.infer<typeof verifyPaymentProviderRequestSchema>;
189
200
 
190
- export const updatePaymentSettingsRequestSchema = z.object({
191
- routingMode: paymentRoutingModeSchema,
192
- priority: z
193
- .array(pgProviderSchema)
194
- .min(1)
195
- // PG 개수와 무관한 안전장치 — 거대한 배열이 파싱을 거치지 않게만 막는다. 실제 개수는 서버가 본다
196
- .max(50)
197
- .describe(
198
- "PG 우선순위(앞이 1순위). 연결된 PG 수만큼 **모두 한 번씩** 나열한다(길이 상한 50은 안전장치다). " +
199
- "빠지거나 중복되거나 연결되지 않은 PG가 있으면 `INVALID_PRIORITY`",
200
- ),
201
- });
201
+ export const updatePaymentSettingsRequestSchema = z
202
+ .object({
203
+ priority: z
204
+ .array(pgProviderSchema)
205
+ .min(1)
206
+ // PG 개수와 무관한 안전장치 — 거대한 배열이 파싱을 거치지 않게만 막는다. 실제 개수는 서버가 본다
207
+ .max(50)
208
+ .optional()
209
+ .describe(
210
+ "PG 우선순위(앞이 1순위) — 스토어프론트 결제 옵션 목록의 PG 순서다. 연결된 PG 수만큼 **모두 한 번씩** 나열한다" +
211
+ "(길이 상한 50은 안전장치다). 빠지거나 중복되거나 연결되지 않은 PG가 있으면 `INVALID_PRIORITY`",
212
+ ),
213
+ checkoutOrigins: z
214
+ .array(z.string().max(200))
215
+ .max(20)
216
+ .optional()
217
+ .describe(
218
+ "결제 도메인 — 통째로 바꾼다. 결제를 마친 구매자가 돌아올 스토어프론트 origin(`https://shop.example.com`, https·경로 없음). " +
219
+ "결제 시작의 `returnUrl`은 이 목록 안이어야 한다. 비어 있으면 실결제를 시작할 수 없다(테스트 결제는 localhost 허용). " +
220
+ "같은 도메인을 PG 가맹 정보에도 등록한다. 형식이 틀리면 `INVALID_CHECKOUT_ORIGIN`",
221
+ ),
222
+ })
223
+ .refine((body) => body.priority !== undefined || body.checkoutOrigins !== undefined, {
224
+ message: "priority 또는 checkoutOrigins 중 하나는 보내야 해요",
225
+ });
202
226
  export type UpdatePaymentSettingsRequest = z.infer<typeof updatePaymentSettingsRequestSchema>;
203
227
 
204
228
  // ─── 조회 응답 ─────────────────────────────────────────────
@@ -318,6 +342,12 @@ export const paymentProviderSchema = z.object({
318
342
  })
319
343
  .describe("환경별 자격 증명 세트. 등록되지 않은 세트는 null"),
320
344
  liveGate: liveGateSchema.describe("라이브 개방 조건. 조건을 모두 충족해야 샌드박스를 끌 수 있다"),
345
+ easyPayProviders: z
346
+ .array(easyPayProviderResponseSchema)
347
+ .describe(
348
+ "이 PG로 받는 간편결제사. 연결되지 않았으면 빈 목록. " +
349
+ "현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 값이 추가될 수 있어 문자열로 받는다",
350
+ ),
321
351
  retiredCredentialCount: z
322
352
  .number()
323
353
  .int()
@@ -356,10 +386,9 @@ export const PAYMENT_ROUTING_EXCLUSION_CODES = [
356
386
  export type KnownPaymentRoutingExclusion = (typeof PAYMENT_ROUTING_EXCLUSION_CODES)[number];
357
387
 
358
388
  export const paymentSettingsSchema = z.object({
359
- routingMode: paymentRoutingModeSchema.describe(
360
- "저장된 라우팅 방식 (기본 `AUTO_FAILOVER`). PG가 하나뿐이면 무시된다",
361
- ),
362
- effectiveRoutingMode: effectivePaymentRoutingModeSchema,
389
+ checkoutOrigins: z
390
+ .array(z.string())
391
+ .describe("결제 도메인 — 결제를 마친 구매자가 돌아올 스토어프론트 origin 목록"),
363
392
  providers: z
364
393
  .array(paymentProviderSchema)
365
394
  .describe("지원하는 모든 PG. 연결된 것은 우선순위순, 연결되지 않은 것은 뒤에 온다"),
@@ -495,6 +524,15 @@ export const paymentRecordSchema = z.object({
495
524
  refundedAmount: z.number().int().describe("환불 완료 금액 합계. 실패한 환불은 빼고 센다"),
496
525
  provider: pgProviderSchema.nullable().describe("승인한 PG. 승인 전에 끝났으면 마지막 시도의 PG"),
497
526
  method: pgPaymentMethodSchema.nullable().describe("실제 결제수단. 모르면 요청 수단"),
527
+ easyPayProvider: easyPayProviderResponseSchema
528
+ .nullable()
529
+ .optional()
530
+ .default(null)
531
+ .describe(
532
+ "간편결제사. `method`가 `EASY_PAY`일 때만 값이 있고, PG가 알려 주지 않았으면 요청한 간편결제사다. " +
533
+ "그 밖의 결제수단과 간편결제 이전 결제는 null. 서버는 항상 싣는다. " +
534
+ "현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 값이 추가될 수 있어 문자열로 받는다",
535
+ ),
498
536
  environment: pgEnvironmentSchema.nullable().describe("결제 환경"),
499
537
  testPayment: z.boolean().describe("샌드박스 결제인가"),
500
538
  pgTransactionId: z.string().nullable().describe("PG 거래 id (토스 paymentKey, 포트원 txId)"),
@@ -516,7 +554,21 @@ export const paymentAttemptRecordSchema = z.object({
516
554
  provider: pgProviderSchema,
517
555
  status: paymentAttemptStatusSchema,
518
556
  method: pgPaymentMethodSchema.describe("주문서에서 고른 결제수단"),
557
+ easyPayProvider: easyPayProviderResponseSchema
558
+ .nullable()
559
+ .optional()
560
+ .default(null)
561
+ .describe(
562
+ "주문서에서 고른 간편결제사. 간편결제가 아니면 null. 서버는 항상 싣는다(값이 추가될 수 있어 문자열)",
563
+ ),
519
564
  approvedMethod: pgPaymentMethodSchema.nullable().describe("PG가 보고한 실제 결제수단"),
565
+ approvedEasyPayProvider: easyPayProviderResponseSchema
566
+ .nullable()
567
+ .optional()
568
+ .default(null)
569
+ .describe(
570
+ "PG가 보고한 실제 간편결제사. 모르거나 간편결제가 아니면 null. 서버는 항상 싣는다(값이 추가될 수 있어 문자열)",
571
+ ),
520
572
  amount: z.number().int(),
521
573
  environment: pgEnvironmentSchema,
522
574
  pgTransactionId: z.string().nullable(),