@sayren/storefront-sdk 0.9.0 → 0.11.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/auth/index.d.mts +12 -3
- package/dist/auth/index.mjs +13 -4
- package/dist/checkout-CHpxo2Ap.mjs +310 -0
- package/dist/{client-D9iQIWnV.mjs → client-CHfCafer.mjs} +134 -13
- package/dist/{http-BbFHVGBf.d.mts → http-CeRVoUGu.d.mts} +19 -1
- package/dist/{index-DvHOQm2-.d.mts → index-OqvbJ6Xi.d.mts} +459 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/payments/index.d.mts +5 -1
- package/dist/payments/index.mjs +4 -2
- package/package.json +1 -1
- package/src/auth/index.ts +18 -3
- package/src/client.ts +28 -0
- package/src/index.ts +1 -0
- package/src/payments/index.ts +11 -1
- package/src/schemas/auth.ts +16 -0
- package/src/schemas/checkout.ts +192 -1
- package/src/schemas/claim.ts +63 -3
- package/src/schemas/consent.ts +72 -0
- package/src/schemas/member.ts +6 -0
- package/src/schemas/order.ts +52 -8
- package/dist/checkout-JFk3b8RG.mjs +0 -189
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { $ as
|
|
3
|
-
export { ANALYTICS_MAX_BATCH_BYTES, ANALYTICS_SESSION_COOKIE, ANALYTICS_SESSION_HEADER, ANALYTICS_VISITOR_COOKIE, ANALYTICS_VISITOR_HEADER, AddCartItemRequest, AnalyticsBatch, AnalyticsClientEvent, AnalyticsClientEventName, AnalyticsEventName, AnalyticsServerEventName, AnonymousSession, ApiError, AvailablePaymentOption, Cart, CartItem, CategoryNode, CheckoutSession, ClaimReason, ClaimStatus, ClaimType, CreateCheckoutRequest, CreateClaimRequest, CreateClaimResult, CreateCustomerInquiryRequest, CreateInquiryRequest, CreateInquiryResult, CreateReviewRequest, CreateReviewResult, CustomerInquiry, CustomerInquiryCategory, DeliveryTracking, EasyPayProvider, GuestInfo, IdpAuthorizeRequest, IdpTokenRequest, KnownPaymentResult, KnownPaymentStatus, LinkIdentityRequest, LoginRequest, Member, MemberAddress, MemberAddressRequest, MemberIdentities, MyClaim, MyOrder, MyOrderItem, OrderItemStatus, OrderShippingAddress, PAYMENT_RESULT_VALUES, PAYMENT_STATUS_VALUES, PageInfo, PageParams, PaymentFailureCategory, PaymentMessage, PaymentMethod, PaymentOption, PaymentStart, PaymentStatus, PgProvider, ProductCard, ProductDetail, ProductFacets, ProductPage, ProductSearchParams, ProductSort, PublicInquiry, PublicReview, PurchaseDecisionResult, type Query, RetryPaymentRequest, ReviewPage, ReviewSummary, STOREFRONT_SESSION_KEYS, type SessionStorage, ShippingAddressInput, SignupRequest, SocialProvider, StartPaymentRequest, type StorefrontClient, type StorefrontClientOptions, type StorefrontSession, type StorefrontSessionOptions, StorefrontStore, TokenPair, type TokenSource, UpdateCartItemRequest, UpdateProfileRequest, UpdateReviewRequest, UpdateReviewResult, WishlistAddResult, WithdrawRequest, WithdrawalBlockedDetails, WritableReview, addCartItemRequestSchema, analyticsBatchSchema, analyticsClientEventNameSchema, analyticsClientEventSchema, analyticsIdSchema, analyticsIdsFromCookie, analyticsServerEventNameSchema, anonymousSessionSchema, availablePaymentOptionSchema, buildQuery, cartItemSchema, cartSchema, categoryNodeSchema, checkoutSessionSchema, claimReasonSchema, claimStatusSchema, claimTypeSchema, createCheckoutRequestSchema, createClaimRequestSchema, createClaimResultSchema, createCustomerInquiryRequestSchema, createInquiryRequestSchema, createInquiryResultSchema, createReviewRequestSchema, createReviewResultSchema, createStorefrontClient, createStorefrontSession, customerInquiryCategorySchema, customerInquirySchema, deliveryTrackingSchema, easyPayProviderResponseSchema, easyPayProviderSchema, guestInfoSchema, idpAuthorizeRequestSchema, idpAuthorizeResponseSchema, idpTokenRequestSchema, linkIdentityRequestSchema, loginRequestSchema, memberAddressRequestSchema, memberAddressSchema, memberIdentitiesSchema, memberSchema, myClaimSchema, myOrderItemSchema, myOrderSchema, orderItemStatusSchema, orderShippingAddressSchema, pageInfoSchema, pageSchema, paymentFailureCategorySchema, paymentMessageSchema, paymentMethodSchema, paymentOptionKey, paymentOptionListSchema, paymentOptionSchema, paymentStartSchema, paymentStatusSchema, pgProviderSchema, productCardSchema, productDetailSchema, productFacetsSchema, productPageSchema, productSortSchema, publicInquirySchema, publicReviewSchema, purchaseDecisionResultSchema, retryPaymentRequestSchema, reviewPageSchema, reviewSummarySchema, shippingAddressInputSchema, signupRequestSchema, socialProviderSchema, startPaymentRequestSchema, storefrontStoreSchema, tokenPairSchema, updateCartItemRequestSchema, updateProfileRequestSchema, updateReviewRequestSchema, updateReviewResultSchema, wishlistAddResultSchema, withdrawRequestSchema, withdrawalBlockedDetailsSchema, writableReviewSchema };
|
|
1
|
+
import { C as loginRequestSchema, D as tokenPairSchema, E as socialProviderSchema, O as withdrawRequestSchema, S as linkIdentityRequestSchema, T as signupRequestSchema, _ as anonymousSessionSchema, a as AnonymousSession, b as idpAuthorizeResponseSchema, c as IdpTokenRequest, d as MemberIdentities, f as SignupRequest, g as WithdrawalBlockedDetails, h as WithdrawRequest, i as buildQuery, k as withdrawalBlockedDetailsSchema, l as LinkIdentityRequest, m as TokenPair, n as Query, o as IdpAgreements, p as SocialProvider, r as TokenSource, s as IdpAuthorizeRequest, t as ApiError, u as LoginRequest, v as idpAgreementsSchema, w as memberIdentitiesSchema, x as idpTokenRequestSchema, y as idpAuthorizeRequestSchema } from "./http-CeRVoUGu.mjs";
|
|
2
|
+
import { $ as Member, $n as productCardSchema, $t as DeliveryQuoteRequest, A as StorefrontClientOptions, An as guestInfoSchema, At as consentStateSchema, B as ReviewPage, Bn as remoteAreaSchema, Bt as claimReturnAddressSchema, C as AnalyticsServerEventName, Cn as checkoutDeliverySchema, Ct as ConsentSource, D as analyticsIdSchema, Dn as deliveryQuoteSchema, Dt as consentActionSchema, E as analyticsClientEventSchema, En as deliveryQuoteRequestSchema, Et as MemberConsents, F as StorefrontSessionOptions, Fn as paymentOptionListSchema, Ft as ClaimType, G as createReviewRequestSchema, Gn as CategoryNode, Gt as AvailablePaymentOption, H as UpdateReviewRequest, Hn as retryPaymentRequestSchema, Ht as createClaimRequestSchema, I as createStorefrontSession, In as paymentOptionSchema, It as CreateClaimRequest, J as reviewPageSchema, Jn as ProductFacets, Jt as CashReceiptRequest, K as createReviewResultSchema, Kn as ProductCard, Kt as CASH_RECEIPT_METHODS, L as CreateReviewRequest, Ln as paymentStartSchema, Lt as CreateClaimResult, M as STOREFRONT_SESSION_KEYS, Mn as paymentMessageSchema, Mt as memberConsentsSchema, N as SessionStorage, Nn as paymentMethodSchema, Nt as ClaimReason, O as analyticsServerEventNameSchema, On as easyPayProviderResponseSchema, Ot as consentKindSchema, P as StorefrontSession, Pn as paymentOptionKey, Pt as ClaimReturnAddress, Q as writableReviewSchema, Qn as categoryNodeSchema, Qt as CreateCheckoutRequest, R as CreateReviewResult, Rn as paymentStatusSchema, Rt as MyClaim, S as AnalyticsEventName, Sn as cashReceiptTypeSchema, St as ConsentKind, T as analyticsClientEventNameSchema, Tn as createCheckoutRequestSchema, Tt as ConsentUpdateRequest, U as UpdateReviewResult, Un as shippingAddressInputSchema, Ut as createClaimResultSchema, V as ReviewSummary, Vn as residentNumberLike, Vt as claimTypeSchema, W as WritableReview, Wn as startPaymentRequestSchema, Wt as myClaimSchema, X as updateReviewRequestSchema, Xn as ProductSearchParams, Xt as CheckoutDelivery, Y as reviewSummarySchema, Yn as ProductPage, Yt as CashReceiptType, Z as updateReviewResultSchema, Zn as ProductSort, Zt as CheckoutSession, _ as ANALYTICS_VISITOR_COOKIE, _n as StartPaymentRequest, _r as cartItemSchema, _t as CustomerInquiryCategory, a as MyOrderItem, an as PAYMENT_RESULT_VALUES, ar as OrderItemStatus, at as memberAddressSchema, b as AnalyticsClientEvent, bn as cashReceiptIdentityTypeOf, br as analyticsIdsFromCookie, bt as customerInquirySchema, c as deliveryTrackingSchema, cn as PaymentMessage, cr as claimStatusSchema, ct as wishlistAddResultSchema, d as orderShippingAddressSchema, dn as PaymentStart, dr as pageSchema, dt as PublicInquiry, en as DeliveryQuoteResult, er as productDetailSchema, et as MemberAddress, f as purchaseDecisionResultSchema, fn as PaymentStatus, fr as AddCartItemRequest, ft as createInquiryRequestSchema, g as ANALYTICS_SESSION_HEADER, gn as ShippingAddressInput, gr as addCartItemRequestSchema, gt as CustomerInquiry, h as ANALYTICS_SESSION_COOKIE, hn as RetryPaymentRequest, hr as UpdateCartItemRequest, ht as CreateCustomerInquiryRequest, i as MyOrder, in as KnownPaymentStatus, ir as ClaimStatus, it as memberAddressRequestSchema, j as createStorefrontClient, jn as paymentFailureCategorySchema, jt as consentUpdateRequestSchema, k as StorefrontClient, kn as easyPayProviderSchema, kt as consentSourceSchema, l as myOrderItemSchema, ln as PaymentMethod, lr as orderItemStatusSchema, lt as CreateInquiryRequest, m as ANALYTICS_MAX_BATCH_BYTES, mn as RemoteArea, mr as CartItem, mt as publicInquirySchema, n as storefrontStoreSchema, nn as GuestInfo, nr as productPageSchema, nt as UpdateProfileRequest, o as OrderShippingAddress, on as PAYMENT_STATUS_VALUES, or as PageInfo, ot as memberSchema, p as trackingStageResponseSchema, pn as PgProvider, pr as Cart, pt as createInquiryResultSchema, q as publicReviewSchema, qn as ProductDetail, qt as CashReceiptIdentityType, r as DeliveryTracking, rn as KnownPaymentResult, rr as productSortSchema, rt as WishlistAddResult, s as PurchaseDecisionResult, sn as PaymentFailureCategory, sr as PageParams, st as updateProfileRequestSchema, t as StorefrontStore, tn as EasyPayProvider, tr as productFacetsSchema, tt as MemberAddressRequest, u as myOrderSchema, un as PaymentOption, ur as pageInfoSchema, ut as CreateInquiryResult, v as ANALYTICS_VISITOR_HEADER, vn as availablePaymentOptionSchema, vr as cartSchema, vt as createCustomerInquiryRequestSchema, w as analyticsBatchSchema, wn as checkoutSessionSchema, wt as ConsentState, x as AnalyticsClientEventName, xn as cashReceiptRequestSchema, xt as ConsentAction, y as AnalyticsBatch, yn as cashReceiptAvailable, yr as updateCartItemRequestSchema, yt as customerInquiryCategorySchema, z as PublicReview, zn as pgProviderSchema, zt as claimReasonSchema } from "./index-OqvbJ6Xi.mjs";
|
|
3
|
+
export { ANALYTICS_MAX_BATCH_BYTES, ANALYTICS_SESSION_COOKIE, ANALYTICS_SESSION_HEADER, ANALYTICS_VISITOR_COOKIE, ANALYTICS_VISITOR_HEADER, AddCartItemRequest, AnalyticsBatch, AnalyticsClientEvent, AnalyticsClientEventName, AnalyticsEventName, AnalyticsServerEventName, AnonymousSession, ApiError, AvailablePaymentOption, CASH_RECEIPT_METHODS, Cart, CartItem, CashReceiptIdentityType, CashReceiptRequest, CashReceiptType, CategoryNode, CheckoutDelivery, CheckoutSession, ClaimReason, ClaimReturnAddress, ClaimStatus, ClaimType, ConsentAction, ConsentKind, ConsentSource, ConsentState, ConsentUpdateRequest, CreateCheckoutRequest, CreateClaimRequest, CreateClaimResult, CreateCustomerInquiryRequest, CreateInquiryRequest, CreateInquiryResult, CreateReviewRequest, CreateReviewResult, CustomerInquiry, CustomerInquiryCategory, DeliveryQuoteRequest, DeliveryQuoteResult, DeliveryTracking, EasyPayProvider, GuestInfo, IdpAgreements, IdpAuthorizeRequest, IdpTokenRequest, KnownPaymentResult, KnownPaymentStatus, LinkIdentityRequest, LoginRequest, Member, MemberAddress, MemberAddressRequest, MemberConsents, MemberIdentities, MyClaim, MyOrder, MyOrderItem, OrderItemStatus, OrderShippingAddress, PAYMENT_RESULT_VALUES, PAYMENT_STATUS_VALUES, PageInfo, PageParams, PaymentFailureCategory, PaymentMessage, PaymentMethod, PaymentOption, PaymentStart, PaymentStatus, PgProvider, ProductCard, ProductDetail, ProductFacets, ProductPage, ProductSearchParams, ProductSort, PublicInquiry, PublicReview, PurchaseDecisionResult, type Query, RemoteArea, RetryPaymentRequest, ReviewPage, ReviewSummary, STOREFRONT_SESSION_KEYS, type SessionStorage, ShippingAddressInput, SignupRequest, SocialProvider, StartPaymentRequest, type StorefrontClient, type StorefrontClientOptions, type StorefrontSession, type StorefrontSessionOptions, StorefrontStore, TokenPair, type TokenSource, UpdateCartItemRequest, UpdateProfileRequest, UpdateReviewRequest, UpdateReviewResult, WishlistAddResult, WithdrawRequest, WithdrawalBlockedDetails, WritableReview, addCartItemRequestSchema, analyticsBatchSchema, analyticsClientEventNameSchema, analyticsClientEventSchema, analyticsIdSchema, analyticsIdsFromCookie, analyticsServerEventNameSchema, anonymousSessionSchema, availablePaymentOptionSchema, buildQuery, cartItemSchema, cartSchema, cashReceiptAvailable, cashReceiptIdentityTypeOf, cashReceiptRequestSchema, cashReceiptTypeSchema, categoryNodeSchema, checkoutDeliverySchema, checkoutSessionSchema, claimReasonSchema, claimReturnAddressSchema, claimStatusSchema, claimTypeSchema, consentActionSchema, consentKindSchema, consentSourceSchema, consentStateSchema, consentUpdateRequestSchema, createCheckoutRequestSchema, createClaimRequestSchema, createClaimResultSchema, createCustomerInquiryRequestSchema, createInquiryRequestSchema, createInquiryResultSchema, createReviewRequestSchema, createReviewResultSchema, createStorefrontClient, createStorefrontSession, customerInquiryCategorySchema, customerInquirySchema, deliveryQuoteRequestSchema, deliveryQuoteSchema, deliveryTrackingSchema, easyPayProviderResponseSchema, easyPayProviderSchema, guestInfoSchema, idpAgreementsSchema, idpAuthorizeRequestSchema, idpAuthorizeResponseSchema, idpTokenRequestSchema, linkIdentityRequestSchema, loginRequestSchema, memberAddressRequestSchema, memberAddressSchema, memberConsentsSchema, memberIdentitiesSchema, memberSchema, myClaimSchema, myOrderItemSchema, myOrderSchema, orderItemStatusSchema, orderShippingAddressSchema, pageInfoSchema, pageSchema, paymentFailureCategorySchema, paymentMessageSchema, paymentMethodSchema, paymentOptionKey, paymentOptionListSchema, paymentOptionSchema, paymentStartSchema, paymentStatusSchema, pgProviderSchema, productCardSchema, productDetailSchema, productFacetsSchema, productPageSchema, productSortSchema, publicInquirySchema, publicReviewSchema, purchaseDecisionResultSchema, remoteAreaSchema, residentNumberLike, retryPaymentRequestSchema, reviewPageSchema, reviewSummarySchema, shippingAddressInputSchema, signupRequestSchema, socialProviderSchema, startPaymentRequestSchema, storefrontStoreSchema, tokenPairSchema, trackingStageResponseSchema, updateCartItemRequestSchema, updateProfileRequestSchema, updateReviewRequestSchema, updateReviewResultSchema, wishlistAddResultSchema, withdrawRequestSchema, withdrawalBlockedDetailsSchema, writableReviewSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as ANALYTICS_VISITOR_HEADER, c as analyticsClientEventSchema, i as ANALYTICS_VISITOR_COOKIE, l as analyticsIdSchema, n as ANALYTICS_SESSION_COOKIE, o as analyticsBatchSchema, r as ANALYTICS_SESSION_HEADER, s as analyticsClientEventNameSchema, t as ANALYTICS_MAX_BATCH_BYTES, u as analyticsServerEventNameSchema } from "./analytics-CgD70OqH.mjs";
|
|
2
2
|
import { t as analyticsIdsFromCookie } from "./analytics-ids-COElZiI3.mjs";
|
|
3
|
-
import { $ as
|
|
4
|
-
import {
|
|
3
|
+
import { $ as updateCartItemRequestSchema, A as consentSourceSchema, B as categoryNodeSchema, C as createInquiryResultSchema, D as customerInquirySchema, E as customerInquiryCategorySchema, F as claimReturnAddressSchema, G as productSortSchema, H as productDetailSchema, I as claimTypeSchema, J as pageInfoSchema, K as claimStatusSchema, L as createClaimRequestSchema, M as consentUpdateRequestSchema, N as memberConsentsSchema, O as consentActionSchema, P as claimReasonSchema, Q as cartSchema, R as createClaimResultSchema, S as createInquiryRequestSchema, T as createCustomerInquiryRequestSchema, U as productFacetsSchema, V as productCardSchema, W as productPageSchema, X as addCartItemRequestSchema, Y as pageSchema, Z as cartItemSchema, _ as memberAddressRequestSchema, a as publicReviewSchema, at as linkIdentityRequestSchema, b as updateProfileRequestSchema, c as updateReviewRequestSchema, ct as signupRequestSchema, d as deliveryTrackingSchema, dt as withdrawRequestSchema, et as anonymousSessionSchema, f as myOrderItemSchema, ft as withdrawalBlockedDetailsSchema, g as trackingStageResponseSchema, gt as unwrapData, h as purchaseDecisionResultSchema, ht as toApiError, i as createReviewResultSchema, it as idpTokenRequestSchema, j as consentStateSchema, k as consentKindSchema, l as updateReviewResultSchema, lt as socialProviderSchema, m as orderShippingAddressSchema, mt as buildQuery, n as storefrontStoreSchema, nt as idpAuthorizeRequestSchema, o as reviewPageSchema, ot as loginRequestSchema, p as myOrderSchema, pt as ApiError, q as orderItemStatusSchema, r as createReviewRequestSchema, rt as idpAuthorizeResponseSchema, s as reviewSummarySchema, st as memberIdentitiesSchema, t as createStorefrontClient, tt as idpAgreementsSchema, u as writableReviewSchema, ut as tokenPairSchema, v as memberAddressSchema, w as publicInquirySchema, x as wishlistAddResultSchema, y as memberSchema, z as myClaimSchema } from "./client-CHfCafer.mjs";
|
|
4
|
+
import { A as startPaymentRequestSchema, C as paymentStartSchema, D as residentNumberLike, E as remoteAreaSchema, O as retryPaymentRequestSchema, S as paymentOptionSchema, T as pgProviderSchema, _ as paymentFailureCategorySchema, a as cashReceiptAvailable, b as paymentOptionKey, c as cashReceiptTypeSchema, d as createCheckoutRequestSchema, f as deliveryQuoteRequestSchema, g as guestInfoSchema, h as easyPayProviderSchema, i as availablePaymentOptionSchema, k as shippingAddressInputSchema, l as checkoutDeliverySchema, m as easyPayProviderResponseSchema, n as PAYMENT_RESULT_VALUES, o as cashReceiptIdentityTypeOf, p as deliveryQuoteSchema, r as PAYMENT_STATUS_VALUES, s as cashReceiptRequestSchema, t as CASH_RECEIPT_METHODS, u as checkoutSessionSchema, v as paymentMessageSchema, w as paymentStatusSchema, x as paymentOptionListSchema, y as paymentMethodSchema } from "./checkout-CHpxo2Ap.mjs";
|
|
5
5
|
//#region src/session.ts
|
|
6
6
|
/** 세션 키 상수 — SDK가 소유한다. store-sdk와 겹치지 않는 별도 네임스페이스. */
|
|
7
7
|
const STOREFRONT_SESSION_KEYS = {
|
|
@@ -125,4 +125,4 @@ function createStorefrontSession(options) {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
//#endregion
|
|
128
|
-
export { ANALYTICS_MAX_BATCH_BYTES, ANALYTICS_SESSION_COOKIE, ANALYTICS_SESSION_HEADER, ANALYTICS_VISITOR_COOKIE, ANALYTICS_VISITOR_HEADER, ApiError, PAYMENT_RESULT_VALUES, PAYMENT_STATUS_VALUES, STOREFRONT_SESSION_KEYS, addCartItemRequestSchema, analyticsBatchSchema, analyticsClientEventNameSchema, analyticsClientEventSchema, analyticsIdSchema, analyticsIdsFromCookie, analyticsServerEventNameSchema, anonymousSessionSchema, availablePaymentOptionSchema, buildQuery, cartItemSchema, cartSchema, categoryNodeSchema, checkoutSessionSchema, claimReasonSchema, claimStatusSchema, claimTypeSchema, createCheckoutRequestSchema, createClaimRequestSchema, createClaimResultSchema, createCustomerInquiryRequestSchema, createInquiryRequestSchema, createInquiryResultSchema, createReviewRequestSchema, createReviewResultSchema, createStorefrontClient, createStorefrontSession, customerInquiryCategorySchema, customerInquirySchema, deliveryTrackingSchema, easyPayProviderResponseSchema, easyPayProviderSchema, guestInfoSchema, idpAuthorizeRequestSchema, idpAuthorizeResponseSchema, idpTokenRequestSchema, linkIdentityRequestSchema, loginRequestSchema, memberAddressRequestSchema, memberAddressSchema, memberIdentitiesSchema, memberSchema, myClaimSchema, myOrderItemSchema, myOrderSchema, orderItemStatusSchema, orderShippingAddressSchema, pageInfoSchema, pageSchema, paymentFailureCategorySchema, paymentMessageSchema, paymentMethodSchema, paymentOptionKey, paymentOptionListSchema, paymentOptionSchema, paymentStartSchema, paymentStatusSchema, pgProviderSchema, productCardSchema, productDetailSchema, productFacetsSchema, productPageSchema, productSortSchema, publicInquirySchema, publicReviewSchema, purchaseDecisionResultSchema, retryPaymentRequestSchema, reviewPageSchema, reviewSummarySchema, shippingAddressInputSchema, signupRequestSchema, socialProviderSchema, startPaymentRequestSchema, storefrontStoreSchema, tokenPairSchema, updateCartItemRequestSchema, updateProfileRequestSchema, updateReviewRequestSchema, updateReviewResultSchema, wishlistAddResultSchema, withdrawRequestSchema, withdrawalBlockedDetailsSchema, writableReviewSchema };
|
|
128
|
+
export { ANALYTICS_MAX_BATCH_BYTES, ANALYTICS_SESSION_COOKIE, ANALYTICS_SESSION_HEADER, ANALYTICS_VISITOR_COOKIE, ANALYTICS_VISITOR_HEADER, ApiError, CASH_RECEIPT_METHODS, PAYMENT_RESULT_VALUES, PAYMENT_STATUS_VALUES, STOREFRONT_SESSION_KEYS, addCartItemRequestSchema, analyticsBatchSchema, analyticsClientEventNameSchema, analyticsClientEventSchema, analyticsIdSchema, analyticsIdsFromCookie, analyticsServerEventNameSchema, anonymousSessionSchema, availablePaymentOptionSchema, buildQuery, cartItemSchema, cartSchema, cashReceiptAvailable, cashReceiptIdentityTypeOf, cashReceiptRequestSchema, cashReceiptTypeSchema, categoryNodeSchema, checkoutDeliverySchema, checkoutSessionSchema, claimReasonSchema, claimReturnAddressSchema, claimStatusSchema, claimTypeSchema, consentActionSchema, consentKindSchema, consentSourceSchema, consentStateSchema, consentUpdateRequestSchema, createCheckoutRequestSchema, createClaimRequestSchema, createClaimResultSchema, createCustomerInquiryRequestSchema, createInquiryRequestSchema, createInquiryResultSchema, createReviewRequestSchema, createReviewResultSchema, createStorefrontClient, createStorefrontSession, customerInquiryCategorySchema, customerInquirySchema, deliveryQuoteRequestSchema, deliveryQuoteSchema, deliveryTrackingSchema, easyPayProviderResponseSchema, easyPayProviderSchema, guestInfoSchema, idpAgreementsSchema, idpAuthorizeRequestSchema, idpAuthorizeResponseSchema, idpTokenRequestSchema, linkIdentityRequestSchema, loginRequestSchema, memberAddressRequestSchema, memberAddressSchema, memberConsentsSchema, memberIdentitiesSchema, memberSchema, myClaimSchema, myOrderItemSchema, myOrderSchema, orderItemStatusSchema, orderShippingAddressSchema, pageInfoSchema, pageSchema, paymentFailureCategorySchema, paymentMessageSchema, paymentMethodSchema, paymentOptionKey, paymentOptionListSchema, paymentOptionSchema, paymentStartSchema, paymentStatusSchema, pgProviderSchema, productCardSchema, productDetailSchema, productFacetsSchema, productPageSchema, productSortSchema, publicInquirySchema, publicReviewSchema, purchaseDecisionResultSchema, remoteAreaSchema, residentNumberLike, retryPaymentRequestSchema, reviewPageSchema, reviewSummarySchema, shippingAddressInputSchema, signupRequestSchema, socialProviderSchema, startPaymentRequestSchema, storefrontStoreSchema, tokenPairSchema, trackingStageResponseSchema, updateCartItemRequestSchema, updateProfileRequestSchema, updateReviewRequestSchema, updateReviewResultSchema, wishlistAddResultSchema, withdrawRequestSchema, withdrawalBlockedDetailsSchema, writableReviewSchema };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Jt as CashReceiptRequest, dn as PaymentStart, fn as PaymentStatus, gn as ShippingAddressInput, j as createStorefrontClient, nn as GuestInfo, un as PaymentOption } from "../index-OqvbJ6Xi.mjs";
|
|
2
2
|
//#region src/payments/index.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* 스토어프론트 결제 — 브라우저 전용(`@sayren/storefront-sdk/payments`).
|
|
@@ -109,6 +109,8 @@ export interface StartOptions {
|
|
|
109
109
|
option: PaymentOption;
|
|
110
110
|
shippingAddress: ShippingAddressInput;
|
|
111
111
|
guest?: GuestInfo;
|
|
112
|
+
/** 현금영수증 신청 — 계좌이체·가상계좌 옵션에서만 보낸다 */
|
|
113
|
+
cashReceipt?: CashReceiptRequest;
|
|
112
114
|
returnUrl?: string;
|
|
113
115
|
mode?: PaymentMode;
|
|
114
116
|
/** 클릭 시점에 {@link Payments.prepareWindow}로 미리 연 창. 폼 검증이 비동기라 클릭 태스크를 넘길 때 쓴다 */
|
|
@@ -118,6 +120,8 @@ export interface RetryOptions {
|
|
|
118
120
|
option: PaymentOption;
|
|
119
121
|
/** 생략하면 결제 시작 때의 복귀 주소를 쓴다 */
|
|
120
122
|
returnUrl?: string;
|
|
123
|
+
/** 현금영수증 신청을 바꾼다. 생략하면 결제 시작 때의 신청을 그대로 둔다 */
|
|
124
|
+
cashReceipt?: CashReceiptRequest;
|
|
121
125
|
mode?: PaymentMode;
|
|
122
126
|
/** 클릭 시점에 {@link Payments.prepareWindow}로 미리 연 창 */
|
|
123
127
|
window?: PreparedPaymentWindow;
|
package/dist/payments/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as paymentMessageSchema } from "../checkout-CHpxo2Ap.mjs";
|
|
2
2
|
//#region src/payments/index.ts
|
|
3
3
|
/** 복귀 주소에 결제 서비스가 붙이는 쿼리 */
|
|
4
4
|
const RETURN_PAYMENT_ID = "sayrenPaymentId";
|
|
@@ -288,6 +288,7 @@ function createPayments(options) {
|
|
|
288
288
|
option: startOptions.option,
|
|
289
289
|
shippingAddress: startOptions.shippingAddress,
|
|
290
290
|
guest: startOptions.guest,
|
|
291
|
+
...startOptions.cashReceipt ? { cashReceipt: startOptions.cashReceipt } : {},
|
|
291
292
|
returnUrl
|
|
292
293
|
}));
|
|
293
294
|
},
|
|
@@ -297,7 +298,8 @@ function createPayments(options) {
|
|
|
297
298
|
warnReturnOrigin(returnUrl, prepared.mode);
|
|
298
299
|
return startWith(prepared, () => client.payments.retry(paymentId, {
|
|
299
300
|
option: retryOptions.option,
|
|
300
|
-
returnUrl
|
|
301
|
+
returnUrl,
|
|
302
|
+
...retryOptions.cashReceipt ? { cashReceipt: retryOptions.cashReceipt } : {}
|
|
301
303
|
}));
|
|
302
304
|
},
|
|
303
305
|
getStatus: (paymentId) => client.payments.getStatus(paymentId),
|
package/package.json
CHANGED
package/src/auth/index.ts
CHANGED
|
@@ -120,21 +120,36 @@ export function createStorefrontAuth(options: StorefrontAuthOptions) {
|
|
|
120
120
|
/**
|
|
121
121
|
* 소셜 로그인 시작 — PKCE(S256)와 state를 만들고 공급자 로그인 주소를 받는다. 반환한 `state`·`codeVerifier`를
|
|
122
122
|
* 서버 세션에 보관하고 구매자를 `url`로 보낸다. 로그인을 마치면 `redirectUri`로 `?code=&state=`가 붙어 돌아온다.
|
|
123
|
-
* `redirectUri`는 스토어프론트 도메인 목록 안이어야
|
|
123
|
+
* `redirectUri`는 스토어프론트 도메인 목록 안이어야 한다.
|
|
124
|
+
*
|
|
125
|
+
* 가입 화면에서 받은 약관 동의는 `agreements`로 함께 보낸다. **이 로그인으로 가입이 되는 경우에만** 이력에
|
|
126
|
+
* 남고(기존 회원의 로그인이면 무시한다), 보내지 않으면 가입은 되지만 필수 동의 이력이 없어
|
|
127
|
+
* `GET /me`의 `reconsentRequired`가 true다(첫 진입에서 `updateConsents()`로 받는다)
|
|
124
128
|
*/
|
|
125
|
-
async idp(
|
|
129
|
+
async idp(
|
|
130
|
+
provider: SocialProvider,
|
|
131
|
+
options: {
|
|
132
|
+
redirectUri: string;
|
|
133
|
+
agreements?: { terms: true; privacy: true; marketing?: boolean };
|
|
134
|
+
},
|
|
135
|
+
): Promise<IdpStart> {
|
|
126
136
|
const state = randomToken(24);
|
|
127
137
|
const codeVerifier = randomToken(32);
|
|
128
138
|
const { url } = await client().auth.idpAuthorize(provider, {
|
|
129
139
|
redirectUri: options.redirectUri,
|
|
130
140
|
codeChallenge: await s256(codeVerifier),
|
|
131
141
|
state,
|
|
142
|
+
agreements: options.agreements && {
|
|
143
|
+
terms: true,
|
|
144
|
+
privacy: true,
|
|
145
|
+
marketing: options.agreements.marketing ?? false,
|
|
146
|
+
},
|
|
132
147
|
});
|
|
133
148
|
return { url, state, codeVerifier };
|
|
134
149
|
},
|
|
135
150
|
/**
|
|
136
151
|
* 소셜 로그인 마무리 — 돌아온 `code`를 구매자 토큰으로 바꾼다. state가 다르거나 구매자가 취소했으면
|
|
137
|
-
* `IdpCallbackError`. code는 1회용이고 1분 안에 바꿔야
|
|
152
|
+
* `IdpCallbackError`. code는 1회용이고 1분 안에 바꿔야 한다. 약관 동의는 `idp()`에서 받는다
|
|
138
153
|
*/
|
|
139
154
|
idpCallback(input: IdpCallbackInput & { error?: string | null }): Promise<TokenPair> {
|
|
140
155
|
if (input.error) return Promise.reject(new IdpCallbackError(input.error));
|
package/src/client.ts
CHANGED
|
@@ -37,6 +37,9 @@ import {
|
|
|
37
37
|
type CreateCheckoutRequest,
|
|
38
38
|
checkoutSessionSchema,
|
|
39
39
|
createCheckoutRequestSchema,
|
|
40
|
+
type DeliveryQuoteRequest,
|
|
41
|
+
deliveryQuoteRequestSchema,
|
|
42
|
+
deliveryQuoteSchema,
|
|
40
43
|
paymentStartSchema,
|
|
41
44
|
paymentStatusSchema,
|
|
42
45
|
type RetryPaymentRequest,
|
|
@@ -56,6 +59,11 @@ import {
|
|
|
56
59
|
type PageParams,
|
|
57
60
|
pageSchema,
|
|
58
61
|
} from "./schemas/common";
|
|
62
|
+
import {
|
|
63
|
+
type ConsentUpdateRequest,
|
|
64
|
+
consentUpdateRequestSchema,
|
|
65
|
+
memberConsentsSchema,
|
|
66
|
+
} from "./schemas/consent";
|
|
59
67
|
import {
|
|
60
68
|
type CreateCustomerInquiryRequest,
|
|
61
69
|
type CustomerInquiryCategory,
|
|
@@ -271,6 +279,19 @@ export function createStorefrontClient(options: StorefrontClientOptions) {
|
|
|
271
279
|
http.request("POST", "/checkout", checkoutSessionSchema, {
|
|
272
280
|
body: createCheckoutRequestSchema.parse(body),
|
|
273
281
|
}),
|
|
282
|
+
/**
|
|
283
|
+
* `POST /checkout/{checkoutId}/delivery-quote` — 배송비 미리보기. 배송지 우편번호로 배송비를 다시 계산한다.
|
|
284
|
+
*
|
|
285
|
+
* 주문서를 만들 때는 배송지를 모르므로 제주·도서산간 추가 배송비가 빠져 있다. 구매자가 배송지를 입력하거나
|
|
286
|
+
* 고칠 때 이 메서드로 금액을 갱신하면 결제 직전에 금액이 바뀌는 일을 피할 수 있다. 주문서를 바꾸지 않는
|
|
287
|
+
* 읽기 계산이고, **최종 금액은 결제 시작 응답의 `amounts`다.**
|
|
288
|
+
*
|
|
289
|
+
* 에러(`ApiError.code`): 404 `CHECKOUT_NOT_FOUND`, 409 `CHECKOUT_EXPIRED`, 409 `ALREADY_PAID`
|
|
290
|
+
*/
|
|
291
|
+
quoteDelivery: (checkoutId: string, body: DeliveryQuoteRequest) =>
|
|
292
|
+
http.request("POST", path`/checkout/${checkoutId}/delivery-quote`, deliveryQuoteSchema, {
|
|
293
|
+
body: deliveryQuoteRequestSchema.parse(body),
|
|
294
|
+
}),
|
|
274
295
|
/**
|
|
275
296
|
* `POST /checkout/{checkoutId}/payment` — 결제 시작. 배송지와 결제 옵션(`paymentOptions` 항목 또는 직접 쓴 옵션)으로
|
|
276
297
|
* 결제 세션·첫 시도를 만들고 결제 서비스 주소(`payUrl`)를 돌려준다. 그 주소를 열어 결제를 진행하는 것은
|
|
@@ -335,6 +356,13 @@ export function createStorefrontClient(options: StorefrontClientOptions) {
|
|
|
335
356
|
me: () => http.request("GET", "/me", memberSchema),
|
|
336
357
|
updateMe: (body: UpdateProfileRequest) =>
|
|
337
358
|
http.requestVoid("PATCH", "/me", { body: updateProfileRequestSchema.parse(body) }),
|
|
359
|
+
/** 약관·개인정보·마케팅 동의의 현재 상태와 재동의 필요 여부 */
|
|
360
|
+
consents: () => http.request("GET", "/me/consents", memberConsentsSchema),
|
|
361
|
+
/** 재동의·마케팅 동의 변경 — 바꾼 뒤의 상태를 돌려준다 */
|
|
362
|
+
updateConsents: (body: ConsentUpdateRequest) =>
|
|
363
|
+
http.request("POST", "/me/consents", memberConsentsSchema, {
|
|
364
|
+
body: consentUpdateRequestSchema.parse(body),
|
|
365
|
+
}),
|
|
338
366
|
listAddresses: () => http.request("GET", "/me/addresses", z.array(memberAddressSchema)),
|
|
339
367
|
createAddress: (body: MemberAddressRequest) =>
|
|
340
368
|
http.requestVoid("POST", "/me/addresses", { body: memberAddressRequestSchema.parse(body) }),
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./schemas/catalog";
|
|
|
10
10
|
export * from "./schemas/checkout";
|
|
11
11
|
export * from "./schemas/claim";
|
|
12
12
|
export * from "./schemas/common";
|
|
13
|
+
export * from "./schemas/consent";
|
|
13
14
|
export * from "./schemas/customer-inquiry";
|
|
14
15
|
export * from "./schemas/inquiry";
|
|
15
16
|
export * from "./schemas/member";
|
package/src/payments/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { createStorefrontClient } from "../client";
|
|
2
2
|
import {
|
|
3
|
+
type CashReceiptRequest,
|
|
3
4
|
type GuestInfo,
|
|
4
5
|
type PaymentOption,
|
|
5
6
|
type PaymentStart,
|
|
@@ -236,6 +237,8 @@ export interface StartOptions {
|
|
|
236
237
|
option: PaymentOption;
|
|
237
238
|
shippingAddress: ShippingAddressInput;
|
|
238
239
|
guest?: GuestInfo;
|
|
240
|
+
/** 현금영수증 신청 — 계좌이체·가상계좌 옵션에서만 보낸다 */
|
|
241
|
+
cashReceipt?: CashReceiptRequest;
|
|
239
242
|
returnUrl?: string;
|
|
240
243
|
mode?: PaymentMode;
|
|
241
244
|
/** 클릭 시점에 {@link Payments.prepareWindow}로 미리 연 창. 폼 검증이 비동기라 클릭 태스크를 넘길 때 쓴다 */
|
|
@@ -246,6 +249,8 @@ export interface RetryOptions {
|
|
|
246
249
|
option: PaymentOption;
|
|
247
250
|
/** 생략하면 결제 시작 때의 복귀 주소를 쓴다 */
|
|
248
251
|
returnUrl?: string;
|
|
252
|
+
/** 현금영수증 신청을 바꾼다. 생략하면 결제 시작 때의 신청을 그대로 둔다 */
|
|
253
|
+
cashReceipt?: CashReceiptRequest;
|
|
249
254
|
mode?: PaymentMode;
|
|
250
255
|
/** 클릭 시점에 {@link Payments.prepareWindow}로 미리 연 창 */
|
|
251
256
|
window?: PreparedPaymentWindow;
|
|
@@ -521,6 +526,7 @@ export function createPayments(options: PaymentsOptions): Payments {
|
|
|
521
526
|
option: startOptions.option,
|
|
522
527
|
shippingAddress: startOptions.shippingAddress,
|
|
523
528
|
guest: startOptions.guest,
|
|
529
|
+
...(startOptions.cashReceipt ? { cashReceipt: startOptions.cashReceipt } : {}),
|
|
524
530
|
returnUrl,
|
|
525
531
|
}),
|
|
526
532
|
);
|
|
@@ -531,7 +537,11 @@ export function createPayments(options: PaymentsOptions): Payments {
|
|
|
531
537
|
const returnUrl = retryOptions.returnUrl ?? options.returnUrl;
|
|
532
538
|
warnReturnOrigin(returnUrl, prepared.mode);
|
|
533
539
|
return startWith(prepared, () =>
|
|
534
|
-
client.payments.retry(paymentId, {
|
|
540
|
+
client.payments.retry(paymentId, {
|
|
541
|
+
option: retryOptions.option,
|
|
542
|
+
returnUrl,
|
|
543
|
+
...(retryOptions.cashReceipt ? { cashReceipt: retryOptions.cashReceipt } : {}),
|
|
544
|
+
}),
|
|
535
545
|
);
|
|
536
546
|
},
|
|
537
547
|
|
package/src/schemas/auth.ts
CHANGED
|
@@ -86,6 +86,20 @@ export type WithdrawalBlockedDetails = z.infer<typeof withdrawalBlockedDetailsSc
|
|
|
86
86
|
export const socialProviderSchema = z.enum(["kakao", "naver", "google"]);
|
|
87
87
|
export type SocialProvider = z.infer<typeof socialProviderSchema>;
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* 소셜 가입 화면에서 받은 필수·선택 동의 — 공급자로 보내기 전에 함께 보낸다.
|
|
91
|
+
*
|
|
92
|
+
* **이 흐름으로 회원이 처음 만들어질 때만 쓴다.** 이미 있는 회원의 로그인이면 무시한다(동의는 늘어나지 않는다).
|
|
93
|
+
* 보내지 않으면 필수 동의 이력이 남지 않아 `GET /me`의 `reconsentRequired`가 true가 되고,
|
|
94
|
+
* 스토어프론트가 첫 진입에서 `POST /me/consents`로 받는다(가입 자체는 거부하지 않는다).
|
|
95
|
+
*/
|
|
96
|
+
export const idpAgreementsSchema = z.object({
|
|
97
|
+
terms: z.literal(true),
|
|
98
|
+
privacy: z.literal(true),
|
|
99
|
+
marketing: z.boolean().default(false),
|
|
100
|
+
});
|
|
101
|
+
export type IdpAgreements = z.infer<typeof idpAgreementsSchema>;
|
|
102
|
+
|
|
89
103
|
/** `POST /auth/idp/{provider}/authorize` 본문 — PKCE(S256)와 state는 SDK가 만든다 */
|
|
90
104
|
export const idpAuthorizeRequestSchema = z.object({
|
|
91
105
|
/** 로그인을 마치고 돌아올 스토어프론트 주소. 스토어프론트 도메인 목록 안이어야 한다 */
|
|
@@ -94,6 +108,8 @@ export const idpAuthorizeRequestSchema = z.object({
|
|
|
94
108
|
codeChallenge: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
95
109
|
/** 스토어프론트가 만든 값 — 돌아올 때 그대로 붙어 온다. 세션에 저장해 두고 비교한다 */
|
|
96
110
|
state: z.string().min(16).max(128),
|
|
111
|
+
/** 가입이 되는 경우 남길 동의. 기존 회원 로그인이면 무시한다 */
|
|
112
|
+
agreements: idpAgreementsSchema.optional(),
|
|
97
113
|
});
|
|
98
114
|
export type IdpAuthorizeRequest = z.infer<typeof idpAuthorizeRequestSchema>;
|
|
99
115
|
|
package/src/schemas/checkout.ts
CHANGED
|
@@ -17,6 +17,44 @@ export const createCheckoutRequestSchema = z
|
|
|
17
17
|
|
|
18
18
|
export type CreateCheckoutRequest = z.infer<typeof createCheckoutRequestSchema>;
|
|
19
19
|
|
|
20
|
+
/** 지역 추가 배송비 구분 — 우편번호로 판정한다 */
|
|
21
|
+
export const remoteAreaSchema = z.enum(["NONE", "JEJU", "ISOLATED"]);
|
|
22
|
+
|
|
23
|
+
export type RemoteArea = z.infer<typeof remoteAreaSchema>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 배송비 내역 (이슈 #29) — 배송비를 **몇 번, 왜** 부과했는지다.
|
|
27
|
+
*
|
|
28
|
+
* 배송비는 **배송 묶음**마다 붙는다. 같은 출고지 + 같은 배송 정책인 상품은 한 묶음이고 한 번만 낸다.
|
|
29
|
+
* 제주·도서산간 추가 배송비는 묶음마다 더하고, 무료배송이어도 붙는다.
|
|
30
|
+
*
|
|
31
|
+
* 주문서를 만들 때는 배송지를 모르므로 `zipCode`가 null이고 `remoteSurcharge`가 0이다.
|
|
32
|
+
* 배송지를 입력하면 `POST /storefront/v1/checkout/{checkoutId}/delivery-quote`로 다시 받고,
|
|
33
|
+
* **결제 시작이 보낸 배송지로 최종 확정한다** — 그래서 주문서 조회 금액과 실제 결제 금액이 다를 수 있다.
|
|
34
|
+
*/
|
|
35
|
+
export const checkoutDeliverySchema = z.object({
|
|
36
|
+
baseFee: z.number().int().describe("기본 배송비 합계. 묶음마다 부과한 금액의 합이다"),
|
|
37
|
+
remoteSurcharge: z
|
|
38
|
+
.number()
|
|
39
|
+
.int()
|
|
40
|
+
.describe("제주·도서산간 추가 배송비 합계. 묶음마다 붙는다. 배송지를 모르면 0"),
|
|
41
|
+
remoteArea: remoteAreaSchema.describe("배송지 지역 구분. 배송지를 모르면 NONE"),
|
|
42
|
+
remoteAreaLabel: z
|
|
43
|
+
.string()
|
|
44
|
+
.nullable()
|
|
45
|
+
.describe("지역 안내 이름(예: 제주특별자치도). 추가 배송비 지역이 아니면 null"),
|
|
46
|
+
bundleCount: z.number().int().describe("배송 묶음 수 — 배송비를 부과한 횟수다"),
|
|
47
|
+
freeByThreshold: z
|
|
48
|
+
.boolean()
|
|
49
|
+
.describe("스토어 전체 무료배송 기준액을 넘겨 기본 배송비를 면제했는가"),
|
|
50
|
+
zipCode: z
|
|
51
|
+
.string()
|
|
52
|
+
.nullable()
|
|
53
|
+
.describe("이 금액에 반영한 배송지 우편번호. null이면 배송지 미반영(추가 배송비 0)이다"),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export type CheckoutDelivery = z.infer<typeof checkoutDeliverySchema>;
|
|
57
|
+
|
|
20
58
|
export const checkoutSessionSchema = z.object({
|
|
21
59
|
checkoutId: z.string(),
|
|
22
60
|
items: z.array(
|
|
@@ -36,6 +74,9 @@ export const checkoutSessionSchema = z.object({
|
|
|
36
74
|
deliveryFee: z.number().int(),
|
|
37
75
|
totalAmount: z.number().int(),
|
|
38
76
|
}),
|
|
77
|
+
delivery: checkoutDeliverySchema.describe(
|
|
78
|
+
"배송비 내역. 배송지를 입력하면 금액이 바뀔 수 있다 — 최종 금액은 결제 시작 응답의 `amounts`다",
|
|
79
|
+
),
|
|
39
80
|
expiresAt: z.string(),
|
|
40
81
|
paymentOptions: z
|
|
41
82
|
.lazy(() => paymentOptionListSchema)
|
|
@@ -51,6 +92,28 @@ export const checkoutSessionSchema = z.object({
|
|
|
51
92
|
|
|
52
93
|
export type CheckoutSession = z.infer<typeof checkoutSessionSchema>;
|
|
53
94
|
|
|
95
|
+
/**
|
|
96
|
+
* 배송비 미리보기 요청 — 배송지 우편번호로 배송비를 다시 계산한다. 주문서를 바꾸지 않는다(읽기 계산이다).
|
|
97
|
+
*
|
|
98
|
+
* 구매자가 배송지를 입력하거나 고칠 때 부르면 제주·도서산간 추가 배송비가 반영된 금액을 미리 보여 줄 수 있다.
|
|
99
|
+
*/
|
|
100
|
+
export const deliveryQuoteRequestSchema = z.object({
|
|
101
|
+
zipCode: z
|
|
102
|
+
.string()
|
|
103
|
+
.regex(/^[0-9]{5}$/, "우편번호 5자리를 입력해 주세요")
|
|
104
|
+
.describe("배송지 우편번호 5자리"),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export type DeliveryQuoteRequest = z.infer<typeof deliveryQuoteRequestSchema>;
|
|
108
|
+
|
|
109
|
+
/** 배송비 미리보기 응답 — 이 배송지로 결제하면 나갈 금액이다 */
|
|
110
|
+
export const deliveryQuoteSchema = z.object({
|
|
111
|
+
amounts: checkoutSessionSchema.shape.amounts.describe("이 배송지 기준 금액"),
|
|
112
|
+
delivery: checkoutDeliverySchema,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export type DeliveryQuoteResult = z.infer<typeof deliveryQuoteSchema>;
|
|
116
|
+
|
|
54
117
|
export const paymentMethodSchema = z.enum([
|
|
55
118
|
"CARD",
|
|
56
119
|
"BANK_TRANSFER",
|
|
@@ -147,6 +210,122 @@ export const guestInfoSchema = z.object({
|
|
|
147
210
|
|
|
148
211
|
export type GuestInfo = z.infer<typeof guestInfoSchema>;
|
|
149
212
|
|
|
213
|
+
/** 현금영수증을 신청할 수 있는 결제수단 — 계좌이체·가상계좌 */
|
|
214
|
+
export const CASH_RECEIPT_METHODS = ["BANK_TRANSFER", "VIRTUAL_ACCOUNT"] as const;
|
|
215
|
+
|
|
216
|
+
/** 이 결제수단으로 현금영수증을 신청할 수 있는가 */
|
|
217
|
+
export function cashReceiptAvailable(method: string): boolean {
|
|
218
|
+
return (CASH_RECEIPT_METHODS as readonly string[]).includes(method);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** 현금영수증 용도 — `INCOME_DEDUCTION` 소득공제(개인) · `EXPENSE_PROOF` 지출증빙(사업자) */
|
|
222
|
+
export const cashReceiptTypeSchema = z.enum(["INCOME_DEDUCTION", "EXPENSE_PROOF"]);
|
|
223
|
+
export type CashReceiptType = z.infer<typeof cashReceiptTypeSchema>;
|
|
224
|
+
|
|
225
|
+
/** 현금영수증 식별 번호 종류 — 휴대폰 번호 · 현금영수증카드 번호 · 사업자등록번호 */
|
|
226
|
+
export type CashReceiptIdentityType = "PHONE" | "CARD" | "BUSINESS";
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 주민등록번호·외국인등록번호 형식인가 — 현금영수증 식별 번호로는 받지 않는다.
|
|
230
|
+
*
|
|
231
|
+
* 현금영수증카드 번호의 아래 끝(13자리)이 주민등록번호 길이와 겹친다. 개인 식별 번호는 최소로 받는다는 원칙이라
|
|
232
|
+
* 주민등록번호로 읽히는 값은 카드 번호 자리로도 받지 않는다.
|
|
233
|
+
*
|
|
234
|
+
* **13자리 숫자 전부를 막지 않는다.** 13자리 현금영수증카드를 쓰는 구매자가 신청할 수 없게 되기 때문이다.
|
|
235
|
+
* 대신 주민등록번호 형식 — 생년월일 6자리(월 01~12, 일 01~31) + 성별·세기 코드(1~8, 5~8은 외국인등록번호) — 으로
|
|
236
|
+
* 판정해 오탐을 줄인다(13자리 숫자 중 이 형식에 걸리는 비율은 약 3%다).
|
|
237
|
+
*
|
|
238
|
+
* 검증번호(뒤 1자리 mod 11)까지는 보지 않는다. 한 자리 오타가 난 주민등록번호도 생년월일을 담고 있어 막아야 하고,
|
|
239
|
+
* 2020년 10월 이후 발급된 외국인등록번호에는 검증번호 규칙이 없다.
|
|
240
|
+
*
|
|
241
|
+
* `cashReceiptIdentityTypeOf`와 같이 하이픈·공백은 빼고 판정한다.
|
|
242
|
+
*/
|
|
243
|
+
export function residentNumberLike(identityNumber: string): boolean {
|
|
244
|
+
const digits = identityNumber.replace(/[\s-]/g, "");
|
|
245
|
+
if (!/^[0-9]{13}$/.test(digits)) return false;
|
|
246
|
+
const month = Number(digits.slice(2, 4));
|
|
247
|
+
const day = Number(digits.slice(4, 6));
|
|
248
|
+
const genderCode = Number(digits[6]);
|
|
249
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= 31 && genderCode >= 1 && genderCode <= 8;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 식별 번호 → 종류. 하이픈·공백은 빼고 판정한다. 용도에 맞지 않는 번호면 null이다.
|
|
254
|
+
* - 소득공제: 휴대폰 번호(01로 시작하는 10~11자리) 또는 현금영수증카드 번호(13~19자리)
|
|
255
|
+
* - 지출증빙: 사업자등록번호(10자리) 또는 현금영수증카드 번호(13~19자리)
|
|
256
|
+
*
|
|
257
|
+
* 자릿수 근거. PG 문서는 식별 번호의 최대 길이만 정하고 종류별 자릿수는 정하지 않는다
|
|
258
|
+
* (토스페이먼츠 `customerIdentityNumber` "최대 길이는 30자", 소득공제는 휴대폰 번호·현금영수증카드 번호,
|
|
259
|
+
* 지출증빙은 사업자등록번호: https://docs.tosspayments.com/common/apis/cash-receipt /
|
|
260
|
+
* 포트원 V2는 종류만 PHONE·CARD·BUSINESS로 나눈다: https://developers.portone.io/api/rest-v2/payment.cashReceipt).
|
|
261
|
+
* 그래서 자릿수는 국세청이 정하는 발급수단 규격을 따른다 — 홈택스 소비자 발급수단 등록의 카드 번호는
|
|
262
|
+
* 13~19자리 숫자이고(https://thisthatbase.com/cash-receipts-card-registration/ 가 옮긴 홈택스 안내,
|
|
263
|
+
* 원본은 https://www.hometax.go.kr/ 소비자 발급수단 관리), 사업자등록번호는 10자리, 휴대폰 번호는 01X + 7~8자리다.
|
|
264
|
+
* 국세청 자진발급 번호(010-000-1234)도 휴대폰 형식으로 통과한다.
|
|
265
|
+
*/
|
|
266
|
+
export function cashReceiptIdentityTypeOf(
|
|
267
|
+
type: CashReceiptType,
|
|
268
|
+
identityNumber: string,
|
|
269
|
+
): CashReceiptIdentityType | null {
|
|
270
|
+
const digits = identityNumber.replace(/[\s-]/g, "");
|
|
271
|
+
if (!/^[0-9]+$/.test(digits)) return null;
|
|
272
|
+
if (residentNumberLike(digits)) return null;
|
|
273
|
+
if (/^[0-9]{13,19}$/.test(digits)) return "CARD";
|
|
274
|
+
if (type === "INCOME_DEDUCTION") return /^01[016789][0-9]{7,8}$/.test(digits) ? "PHONE" : null;
|
|
275
|
+
return /^[0-9]{10}$/.test(digits) ? "BUSINESS" : null;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 현금영수증 신청 — 계좌이체·가상계좌 결제에서만 보낼 수 있다. 결제가 승인되면 sayren이 결제한 PG로 발급하고,
|
|
280
|
+
* 환불하면 그만큼 취소한다. 식별 번호는 암호화해 저장하고 응답에는 가린 값만 나간다.
|
|
281
|
+
*/
|
|
282
|
+
export const cashReceiptRequestSchema = z
|
|
283
|
+
.object({
|
|
284
|
+
type: cashReceiptTypeSchema.describe(
|
|
285
|
+
"용도. `INCOME_DEDUCTION` 소득공제(개인) · `EXPENSE_PROOF` 지출증빙(사업자)",
|
|
286
|
+
),
|
|
287
|
+
identityNumber: z
|
|
288
|
+
.string()
|
|
289
|
+
.max(30)
|
|
290
|
+
.describe(
|
|
291
|
+
"식별 번호. 소득공제는 휴대폰 번호(01X + 7~8자리) 또는 현금영수증카드 번호(13~19자리), 지출증빙은 " +
|
|
292
|
+
"사업자등록번호(10자리) 또는 현금영수증카드 번호(13~19자리). 하이픈은 빼고 읽는다. " +
|
|
293
|
+
"주민등록번호는 받지 않는다(`RESIDENT_NUMBER_NOT_ALLOWED`)",
|
|
294
|
+
),
|
|
295
|
+
})
|
|
296
|
+
.superRefine((value, ctx) => {
|
|
297
|
+
// 주민등록번호는 단순 형식 오류와 가른다 — 구매자에게 다른 번호를 입력하라고 안내해야 하고,
|
|
298
|
+
// 셀러·개발자가 필드 오류 코드로 이 경로를 집계할 수 있어야 한다.
|
|
299
|
+
// 필드 오류 코드는 메시지 끝의 `(CODE)`에서 나온다(api `zod-validation.pipe.ts`의 `extractCode`).
|
|
300
|
+
if (residentNumberLike(value.identityNumber)) {
|
|
301
|
+
ctx.addIssue({
|
|
302
|
+
code: "custom",
|
|
303
|
+
path: ["identityNumber"],
|
|
304
|
+
message:
|
|
305
|
+
"주민등록번호는 현금영수증 식별 번호로 쓸 수 없어요. " +
|
|
306
|
+
"휴대폰 번호 또는 현금영수증카드 번호를 입력해주세요 (RESIDENT_NUMBER_NOT_ALLOWED)",
|
|
307
|
+
});
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (!cashReceiptIdentityTypeOf(value.type, value.identityNumber)) {
|
|
311
|
+
ctx.addIssue({
|
|
312
|
+
code: "custom",
|
|
313
|
+
path: ["identityNumber"],
|
|
314
|
+
message:
|
|
315
|
+
value.type === "INCOME_DEDUCTION"
|
|
316
|
+
? "휴대폰 번호 또는 현금영수증카드 번호를 입력해주세요"
|
|
317
|
+
: "사업자등록번호(10자리) 또는 현금영수증카드 번호를 입력해주세요",
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
export type CashReceiptRequest = z.infer<typeof cashReceiptRequestSchema>;
|
|
322
|
+
|
|
323
|
+
const cashReceiptField = cashReceiptRequestSchema
|
|
324
|
+
.optional()
|
|
325
|
+
.describe(
|
|
326
|
+
"현금영수증 신청. 계좌이체·가상계좌 옵션에서만 보낼 수 있다(그 밖의 옵션이면 400 `CASH_RECEIPT_NOT_AVAILABLE`). 결제가 승인되면 발급한다",
|
|
327
|
+
);
|
|
328
|
+
|
|
150
329
|
/**
|
|
151
330
|
* 결제 시작 — 배송지를 확정하고 고른 결제 옵션으로 결제 시도를 연다. 응답의 `payUrl`(결제 서비스)을 팝업(`mode=popup`)이나
|
|
152
331
|
* 전체 페이지로 열면 결제 서비스가 PG 결제창을 띄우고 승인까지 한다. 리다이렉트 결제가 끝나면 구매자는 `returnUrl`로 돌아온다.
|
|
@@ -162,14 +341,20 @@ export const startPaymentRequestSchema = z.object({
|
|
|
162
341
|
),
|
|
163
342
|
shippingAddress: shippingAddressInputSchema,
|
|
164
343
|
guest: guestInfoSchema.optional(),
|
|
344
|
+
cashReceipt: cashReceiptField,
|
|
165
345
|
});
|
|
166
346
|
|
|
167
347
|
export type StartPaymentRequest = z.infer<typeof startPaymentRequestSchema>;
|
|
168
348
|
|
|
169
|
-
/**
|
|
349
|
+
/**
|
|
350
|
+
* 같은 결제에서 다른 결제 옵션으로 다시 시도. `returnUrl`을 생략하면 결제 시작 때의 복귀 주소를 쓴다.
|
|
351
|
+
* `cashReceipt`를 보내면 현금영수증 신청을 이 값으로 바꾸고, 생략하면 결제 시작 때의 신청을 그대로 둔다
|
|
352
|
+
* (승인된 결제수단이 계좌이체·가상계좌가 아니면 발급하지 않는다)
|
|
353
|
+
*/
|
|
170
354
|
export const retryPaymentRequestSchema = z.object({
|
|
171
355
|
option: paymentOptionSchema,
|
|
172
356
|
returnUrl: startPaymentRequestSchema.shape.returnUrl.optional(),
|
|
357
|
+
cashReceipt: cashReceiptField,
|
|
173
358
|
});
|
|
174
359
|
|
|
175
360
|
export type RetryPaymentRequest = z.infer<typeof retryPaymentRequestSchema>;
|
|
@@ -189,6 +374,12 @@ export const paymentStartSchema = z.object({
|
|
|
189
374
|
.describe(
|
|
190
375
|
"테스트 결제(샌드박스) 여부. true면 실제로 돈이 나가지 않는다 — 결제 화면에 테스트 결제 안내를 표시한다",
|
|
191
376
|
),
|
|
377
|
+
amounts: checkoutSessionSchema.shape.amounts.describe(
|
|
378
|
+
"**확정 결제 금액** — 보낸 배송지로 배송비를 다시 계산한 값이다. 주문서 조회 시점의 `amounts`와 다를 수 있다(제주·도서산간 추가 배송비)",
|
|
379
|
+
),
|
|
380
|
+
delivery: checkoutDeliverySchema.describe(
|
|
381
|
+
"확정 배송비 내역. `zipCode`는 보낸 배송지의 우편번호다",
|
|
382
|
+
),
|
|
192
383
|
});
|
|
193
384
|
|
|
194
385
|
export type PaymentStart = z.infer<typeof paymentStartSchema>;
|