@wix/headless-bookings 0.0.117 → 1.0.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.
Files changed (75) hide show
  1. package/cjs/dist/api/calculate-cart/index.d.ts +3 -0
  2. package/cjs/dist/api/calculate-cart/index.js +7 -0
  3. package/cjs/dist/api/create-cart/index.d.ts +3 -0
  4. package/cjs/dist/api/create-cart/index.js +10 -0
  5. package/cjs/dist/api/index.d.ts +3 -9
  6. package/cjs/dist/api/index.js +12 -17
  7. package/cjs/dist/api/place-order/index.d.ts +3 -0
  8. package/cjs/dist/api/place-order/index.js +7 -0
  9. package/cjs/dist/react/booking/Book.js +1 -1
  10. package/cjs/dist/react/core/booking/Book.d.ts +1 -1
  11. package/cjs/dist/react/core/booking/Book.js +1 -1
  12. package/cjs/dist/react/core/payment/Payment.d.ts +14 -1
  13. package/cjs/dist/react/core/payment/Payment.js +12 -0
  14. package/cjs/dist/react/payment/Payment.d.ts +37 -1
  15. package/cjs/dist/react/payment/Payment.js +32 -1
  16. package/cjs/dist/services/booking/book-action/bookAction.d.ts +0 -22
  17. package/cjs/dist/services/booking/book-action/bookAction.js +20 -39
  18. package/cjs/dist/services/booking/book-action/buildCartRequest.d.ts +10 -0
  19. package/cjs/dist/services/booking/book-action/buildCartRequest.js +37 -0
  20. package/cjs/dist/services/booking/book-action/index.d.ts +1 -1
  21. package/cjs/dist/services/booking/book-action/index.js +3 -3
  22. package/cjs/dist/services/booking/book-action/isCheckoutRequired.d.ts +3 -19
  23. package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +11 -29
  24. package/cjs/dist/services/booking/book-action/types.d.ts +1 -1
  25. package/cjs/dist/services/index.d.ts +2 -2
  26. package/cjs/dist/services/index.js +2 -2
  27. package/cjs/dist/services/payment/payment.d.ts +1 -1
  28. package/cjs/dist/services/payment/payment.def.d.ts +15 -0
  29. package/cjs/dist/services/payment/payment.js +51 -3
  30. package/cjs/dist/utils/navigation.d.ts +2 -2
  31. package/cjs/dist/utils/navigation.js +2 -2
  32. package/dist/api/calculate-cart/index.d.ts +3 -0
  33. package/dist/api/calculate-cart/index.js +4 -0
  34. package/dist/api/create-cart/index.d.ts +3 -0
  35. package/dist/api/create-cart/index.js +5 -0
  36. package/dist/api/index.d.ts +3 -9
  37. package/dist/api/index.js +3 -9
  38. package/dist/api/place-order/index.d.ts +3 -0
  39. package/dist/api/place-order/index.js +4 -0
  40. package/dist/react/booking/Book.js +1 -1
  41. package/dist/react/core/booking/Book.d.ts +1 -1
  42. package/dist/react/core/booking/Book.js +1 -1
  43. package/dist/react/core/payment/Payment.d.ts +14 -1
  44. package/dist/react/core/payment/Payment.js +11 -0
  45. package/dist/react/payment/Payment.d.ts +37 -1
  46. package/dist/react/payment/Payment.js +31 -0
  47. package/dist/services/booking/book-action/bookAction.d.ts +0 -22
  48. package/dist/services/booking/book-action/bookAction.js +20 -39
  49. package/dist/services/booking/book-action/buildCartRequest.d.ts +10 -0
  50. package/dist/services/booking/book-action/buildCartRequest.js +34 -0
  51. package/dist/services/booking/book-action/index.d.ts +1 -1
  52. package/dist/services/booking/book-action/index.js +1 -1
  53. package/dist/services/booking/book-action/isCheckoutRequired.d.ts +3 -19
  54. package/dist/services/booking/book-action/isCheckoutRequired.js +11 -29
  55. package/dist/services/booking/book-action/types.d.ts +1 -1
  56. package/dist/services/index.d.ts +2 -2
  57. package/dist/services/index.js +1 -1
  58. package/dist/services/payment/payment.d.ts +1 -1
  59. package/dist/services/payment/payment.def.d.ts +15 -0
  60. package/dist/services/payment/payment.js +51 -3
  61. package/dist/utils/navigation.d.ts +2 -2
  62. package/dist/utils/navigation.js +2 -2
  63. package/package.json +3 -3
  64. package/cjs/dist/api/create-checkout/index.d.ts +0 -40
  65. package/cjs/dist/api/create-checkout/index.js +0 -42
  66. package/cjs/dist/api/create-order/index.d.ts +0 -20
  67. package/cjs/dist/api/create-order/index.js +0 -24
  68. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.d.ts +0 -28
  69. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +0 -65
  70. package/dist/api/create-checkout/index.d.ts +0 -40
  71. package/dist/api/create-checkout/index.js +0 -37
  72. package/dist/api/create-order/index.d.ts +0 -20
  73. package/dist/api/create-order/index.js +0 -21
  74. package/dist/services/booking/book-action/buildCheckoutRequest.d.ts +0 -28
  75. package/dist/services/booking/book-action/buildCheckoutRequest.js +0 -62
@@ -0,0 +1,3 @@
1
+ import { type CalculateCartOptions, type CalculateCartResponse } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export declare function calculateCart(cartId: string, options?: CalculateCartOptions): Promise<CalculateCartResponse>;
3
+ export type { CalculateCartResponse, CartSummary, } from '@wix/auto_sdk_ecom_cart-v-2';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateCart = calculateCart;
4
+ const auto_sdk_ecom_cart_v_2_1 = require("@wix/auto_sdk_ecom_cart-v-2");
5
+ async function calculateCart(cartId, options) {
6
+ return (0, auto_sdk_ecom_cart_v_2_1.calculateCart)(cartId, options);
7
+ }
@@ -0,0 +1,3 @@
1
+ import { type CreateCartOptions, type Cart } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export declare function createCart(options?: CreateCartOptions): Promise<Cart>;
3
+ export { ChannelType, type CreateCartOptions, type Cart, } from '@wix/auto_sdk_ecom_cart-v-2';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChannelType = void 0;
4
+ exports.createCart = createCart;
5
+ const auto_sdk_ecom_cart_v_2_1 = require("@wix/auto_sdk_ecom_cart-v-2");
6
+ async function createCart(options) {
7
+ return (0, auto_sdk_ecom_cart_v_2_1.createCart)(options);
8
+ }
9
+ var auto_sdk_ecom_cart_v_2_2 = require("@wix/auto_sdk_ecom_cart-v-2");
10
+ Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return auto_sdk_ecom_cart_v_2_2.ChannelType; } });
@@ -7,14 +7,8 @@
7
7
  export { getServiceById, getServiceBySlug, queryServices, convertPlatformFilterToApiFilter, type PagingMetadata, type QueryServicesRequest, SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from './query-services/index.js';
8
8
  export { fetchAvailability } from './fetch-availability/index.js';
9
9
  export { createBooking, type CreateBookingOptions, type Booking, type CreateBookingRequest, type CreateBookingResponse, type ParticipantNotification, type ContactDetails, } from './create-booking/index.js';
10
- export { createCheckout, ChannelType, type CreateCheckoutRequest, type CreateCheckoutResponse, } from './create-checkout/index.js';
11
- export { createOrder, type CreateOrderOptions, type CreateOrderResponse, } from './create-order/index.js';
10
+ export { createCart, ChannelType, type CreateCartOptions, type Cart, } from './create-cart/index.js';
11
+ export { calculateCart, type CalculateCartResponse, type CartSummary, } from './calculate-cart/index.js';
12
+ export { placeOrder, type PlaceOrderOptions, type PlaceOrderResponse, } from './place-order/index.js';
12
13
  export { queryLocations, getLocationById, type QueryLocationsResult, type LocationData, } from './query-locations/index.js';
13
14
  export { queryCategories, type QueryCategoriesResult, type Category, } from './query-categories/index.js';
14
- /**
15
- * PagingMetadata includes:
16
- * - limit: Number of items per page
17
- * - offset: Number of items to skip
18
- * - count: Number of items returned in the current page
19
- * - hasNext: Whether there are more services available to load
20
- */
@@ -6,7 +6,7 @@
6
6
  * @module API
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.queryCategories = exports.getLocationById = exports.queryLocations = exports.createOrder = exports.ChannelType = exports.createCheckout = exports.createBooking = exports.fetchAvailability = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.convertPlatformFilterToApiFilter = exports.queryServices = exports.getServiceBySlug = exports.getServiceById = void 0;
9
+ exports.queryCategories = exports.getLocationById = exports.queryLocations = exports.placeOrder = exports.calculateCart = exports.ChannelType = exports.createCart = exports.createBooking = exports.fetchAvailability = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.convertPlatformFilterToApiFilter = exports.queryServices = exports.getServiceBySlug = exports.getServiceById = void 0;
10
10
  var index_js_1 = require("./query-services/index.js");
11
11
  Object.defineProperty(exports, "getServiceById", { enumerable: true, get: function () { return index_js_1.getServiceById; } });
12
12
  Object.defineProperty(exports, "getServiceBySlug", { enumerable: true, get: function () { return index_js_1.getServiceBySlug; } });
@@ -18,20 +18,15 @@ var index_js_2 = require("./fetch-availability/index.js");
18
18
  Object.defineProperty(exports, "fetchAvailability", { enumerable: true, get: function () { return index_js_2.fetchAvailability; } });
19
19
  var index_js_3 = require("./create-booking/index.js");
20
20
  Object.defineProperty(exports, "createBooking", { enumerable: true, get: function () { return index_js_3.createBooking; } });
21
- var index_js_4 = require("./create-checkout/index.js");
22
- Object.defineProperty(exports, "createCheckout", { enumerable: true, get: function () { return index_js_4.createCheckout; } });
21
+ var index_js_4 = require("./create-cart/index.js");
22
+ Object.defineProperty(exports, "createCart", { enumerable: true, get: function () { return index_js_4.createCart; } });
23
23
  Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return index_js_4.ChannelType; } });
24
- var index_js_5 = require("./create-order/index.js");
25
- Object.defineProperty(exports, "createOrder", { enumerable: true, get: function () { return index_js_5.createOrder; } });
26
- var index_js_6 = require("./query-locations/index.js");
27
- Object.defineProperty(exports, "queryLocations", { enumerable: true, get: function () { return index_js_6.queryLocations; } });
28
- Object.defineProperty(exports, "getLocationById", { enumerable: true, get: function () { return index_js_6.getLocationById; } });
29
- var index_js_7 = require("./query-categories/index.js");
30
- Object.defineProperty(exports, "queryCategories", { enumerable: true, get: function () { return index_js_7.queryCategories; } });
31
- /**
32
- * PagingMetadata includes:
33
- * - limit: Number of items per page
34
- * - offset: Number of items to skip
35
- * - count: Number of items returned in the current page
36
- * - hasNext: Whether there are more services available to load
37
- */
24
+ var index_js_5 = require("./calculate-cart/index.js");
25
+ Object.defineProperty(exports, "calculateCart", { enumerable: true, get: function () { return index_js_5.calculateCart; } });
26
+ var index_js_6 = require("./place-order/index.js");
27
+ Object.defineProperty(exports, "placeOrder", { enumerable: true, get: function () { return index_js_6.placeOrder; } });
28
+ var index_js_7 = require("./query-locations/index.js");
29
+ Object.defineProperty(exports, "queryLocations", { enumerable: true, get: function () { return index_js_7.queryLocations; } });
30
+ Object.defineProperty(exports, "getLocationById", { enumerable: true, get: function () { return index_js_7.getLocationById; } });
31
+ var index_js_8 = require("./query-categories/index.js");
32
+ Object.defineProperty(exports, "queryCategories", { enumerable: true, get: function () { return index_js_8.queryCategories; } });
@@ -0,0 +1,3 @@
1
+ import { type PlaceOrderOptions, type PlaceOrderResponse } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export declare function placeOrder(cartId: string, options?: PlaceOrderOptions): Promise<PlaceOrderResponse>;
3
+ export type { PlaceOrderOptions, PlaceOrderResponse, } from '@wix/auto_sdk_ecom_cart-v-2';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.placeOrder = placeOrder;
4
+ const auto_sdk_ecom_cart_v_2_1 = require("@wix/auto_sdk_ecom_cart-v-2");
5
+ async function placeOrder(cartId, options) {
6
+ return (0, auto_sdk_ecom_cart_v_2_1.placeOrder)(cartId, options);
7
+ }
@@ -99,7 +99,7 @@ exports.Book = react_1.default.forwardRef((props, ref) => {
99
99
  return ((0, jsx_runtime_1.jsx)(CoreBook.Book, { onCheckout: (result) => {
100
100
  // Create navigateToCheckout with checkoutId captured
101
101
  const navigateToCheckout = (options) => (0, navigation_js_1.navigateToCheckout)({
102
- checkoutId: result.checkoutId,
102
+ cartId: result.cartId,
103
103
  navigationInfo: { postFlowUrl: options.postFlowUrl },
104
104
  });
105
105
  // Return user's callback result so core can await it
@@ -24,7 +24,7 @@ export interface BookProps {
24
24
  * Return a Promise to keep loading state active until it resolves.
25
25
  */
26
26
  onCheckout?: (result: {
27
- checkoutId: string;
27
+ cartId: string;
28
28
  }) => void | Promise<unknown>;
29
29
  /**
30
30
  * Called when booking completes without requiring checkout.
@@ -52,7 +52,7 @@ function Book(props) {
52
52
  try {
53
53
  const result = await bookingService.actions.book();
54
54
  if (result.type === types_js_1.BookResultType.CheckoutRequired) {
55
- await onCheckout?.({ checkoutId: result.checkoutId });
55
+ await onCheckout?.({ cartId: result.cartId });
56
56
  }
57
57
  else {
58
58
  await onComplete?.({ orderId: result.orderId });
@@ -4,7 +4,7 @@
4
4
  * Note: Currently supports single service only
5
5
  */
6
6
  import React from 'react';
7
- import { type PaymentServiceConfig, type PricingServiceSelection } from '../../../services/payment/payment.js';
7
+ import { type PaymentServiceConfig, type PricingServiceSelection, type ServicePaymentOptions } from '../../../services/payment/payment.js';
8
8
  import type { MoneyData } from '@wix/headless-components/react';
9
9
  /**
10
10
  * Props for Payment.Root component
@@ -164,6 +164,19 @@ export interface LineItemProviderProps {
164
164
  * ```
165
165
  */
166
166
  export declare function LineItemProvider(props: LineItemProviderProps): React.ReactNode;
167
+ /**
168
+ * Props for ServiceOptions render prop component
169
+ */
170
+ export interface ServiceOptionsProps {
171
+ children: (options: ServicePaymentOptions) => React.ReactNode;
172
+ }
173
+ /**
174
+ * Core component that exposes service payment options via render props.
175
+ * Reads isOnline, isInPerson, isDeposit from the payment service signal.
176
+ *
177
+ * @component
178
+ */
179
+ export declare function ServiceOptions(props: ServiceOptionsProps): React.ReactNode;
167
180
  /**
168
181
  * Props for LineItemInfo render prop component
169
182
  */
@@ -8,6 +8,7 @@ exports.Data = Data;
8
8
  exports.LineItems = LineItems;
9
9
  exports.useLineItemContext = useLineItemContext;
10
10
  exports.LineItemProvider = LineItemProvider;
11
+ exports.ServiceOptions = ServiceOptions;
11
12
  exports.LineItemInfo = LineItemInfo;
12
13
  const jsx_runtime_1 = require("react/jsx-runtime");
13
14
  /**
@@ -199,6 +200,17 @@ function LineItemProvider(props) {
199
200
  };
200
201
  return ((0, jsx_runtime_1.jsx)(LineItemContext.Provider, { value: contextValue, children: children }));
201
202
  }
203
+ /**
204
+ * Core component that exposes service payment options via render props.
205
+ * Reads isOnline, isInPerson, isDeposit from the payment service signal.
206
+ *
207
+ * @component
208
+ */
209
+ function ServiceOptions(props) {
210
+ const paymentService = (0, services_manager_react_1.useService)(payment_js_1.PaymentServiceDefinition);
211
+ const serviceOptions = paymentService.serviceOptionsSignal.get();
212
+ return props.children(serviceOptions);
213
+ }
202
214
  /**
203
215
  * Core component that provides access to line item info via render props.
204
216
  * Must be used within LineItemProvider.
@@ -5,7 +5,7 @@
5
5
  import React from 'react';
6
6
  import { AsChildChildren } from '@wix/headless-utils/react';
7
7
  import { MoneyData } from '@wix/headless-components/react';
8
- import type { PaymentServiceConfig, PricingServiceSelection } from '../../services/payment/payment.js';
8
+ import type { PaymentServiceConfig, PricingServiceSelection, ServicePaymentOptions } from '../../services/payment/payment.js';
9
9
  export declare const TestIds: {
10
10
  readonly paymentRoot: "payment-root";
11
11
  readonly paymentSubtotal: "payment-subtotal";
@@ -19,6 +19,7 @@ export declare const TestIds: {
19
19
  readonly paymentLineItemTotal: "payment-line-item-total";
20
20
  readonly paymentLineItemSubtotal: "payment-line-item-subtotal";
21
21
  readonly paymentLineItemDeposit: "payment-line-item-deposit";
22
+ readonly paymentServiceOptions: "payment-service-options";
22
23
  };
23
24
  /**
24
25
  * Props for Payment.Root component
@@ -194,6 +195,41 @@ export interface PayLaterProps extends Omit<React.HTMLAttributes<HTMLElement>, '
194
195
  * ```
195
196
  */
196
197
  export declare const PayLater: React.ForwardRefExoticComponent<PayLaterProps & React.RefAttributes<HTMLElement>>;
198
+ /**
199
+ * Props for Payment.ServiceOptions component
200
+ */
201
+ export interface ServiceOptionsProps {
202
+ asChild?: boolean;
203
+ /** Render prop receiving service payment options. This component renders no
204
+ * visible DOM element by default — it is a flags-only data component. */
205
+ children?: AsChildChildren<ServicePaymentOptions>;
206
+ }
207
+ /**
208
+ * Exposes service payment options via render props.
209
+ * Use this to determine which payment scenario to render without reading the service entity directly.
210
+ *
211
+ * Payment scenarios:
212
+ * - `isOnline=true, isInPerson=false, isDeposit=false` → Pay now only (Due now = total)
213
+ * - `isOnline=true, isInPerson=false, isDeposit=true` → Pay now + security deposit
214
+ * - `isOnline=true, isInPerson=true` → Radio: Pay Online / Pay on Arrival
215
+ * - `isOnline=false, isInPerson=true` → Pay on arrival only
216
+ *
217
+ * @component
218
+ * Note: This component renders no visible DOM element. It is a flags-only data
219
+ * component — use `asChild` with a render function to consume the flags.
220
+ * For the actual split amounts (deposit / pay-later), use `Payment.PayNow` and
221
+ * `Payment.PayLater`.
222
+ *
223
+ * @example
224
+ * ```tsx
225
+ * <Payment.ServiceOptions asChild>
226
+ * {({ isOnline, isInPerson, isDeposit }) => (
227
+ * // render the correct payment scenario
228
+ * )}
229
+ * </Payment.ServiceOptions>
230
+ * ```
231
+ */
232
+ export declare const ServiceOptions: React.ForwardRefExoticComponent<ServiceOptionsProps & React.RefAttributes<HTMLElement>>;
197
233
  /**
198
234
  * Props for Payment.LineItems component (Container Level)
199
235
  */
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.LineItemDeposit = exports.LineItemSubtotal = exports.LineItemTotal = exports.LineItemRepeater = exports.LineItemsList = exports.LineItems = exports.PayLater = exports.PayNow = exports.Total = exports.Tax = exports.Subtotal = exports.Root = exports.TestIds = void 0;
39
+ exports.LineItemDeposit = exports.LineItemSubtotal = exports.LineItemTotal = exports.LineItemRepeater = exports.LineItemsList = exports.LineItems = exports.ServiceOptions = exports.PayLater = exports.PayNow = exports.Total = exports.Tax = exports.Subtotal = exports.Root = exports.TestIds = void 0;
40
40
  const jsx_runtime_1 = require("react/jsx-runtime");
41
41
  /**
42
42
  * Payment - High-level component for displaying payment information
@@ -59,6 +59,7 @@ exports.TestIds = {
59
59
  paymentLineItemTotal: 'payment-line-item-total',
60
60
  paymentLineItemSubtotal: 'payment-line-item-subtotal',
61
61
  paymentLineItemDeposit: 'payment-line-item-deposit',
62
+ paymentServiceOptions: 'payment-service-options',
62
63
  };
63
64
  /**
64
65
  * Root component that provides payment context to the entire app.
@@ -200,6 +201,36 @@ exports.PayLater = react_1.default.forwardRef((props, ref) => {
200
201
  return ((0, jsx_runtime_1.jsx)(CorePayment.Data, { children: ({ payLater, isDeposit }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { payLater, isDeposit }, "data-testid": exports.TestIds.paymentPayLater, "data-has-deposit": isDeposit, children: isDeposit && payLater && payLater.amount > 0 && ((0, jsx_runtime_1.jsx)(react_3.Money, { money: payLater })) })) }));
201
202
  });
202
203
  exports.PayLater.displayName = 'Payment.PayLater';
204
+ /**
205
+ * Exposes service payment options via render props.
206
+ * Use this to determine which payment scenario to render without reading the service entity directly.
207
+ *
208
+ * Payment scenarios:
209
+ * - `isOnline=true, isInPerson=false, isDeposit=false` → Pay now only (Due now = total)
210
+ * - `isOnline=true, isInPerson=false, isDeposit=true` → Pay now + security deposit
211
+ * - `isOnline=true, isInPerson=true` → Radio: Pay Online / Pay on Arrival
212
+ * - `isOnline=false, isInPerson=true` → Pay on arrival only
213
+ *
214
+ * @component
215
+ * Note: This component renders no visible DOM element. It is a flags-only data
216
+ * component — use `asChild` with a render function to consume the flags.
217
+ * For the actual split amounts (deposit / pay-later), use `Payment.PayNow` and
218
+ * `Payment.PayLater`.
219
+ *
220
+ * @example
221
+ * ```tsx
222
+ * <Payment.ServiceOptions asChild>
223
+ * {({ isOnline, isInPerson, isDeposit }) => (
224
+ * // render the correct payment scenario
225
+ * )}
226
+ * </Payment.ServiceOptions>
227
+ * ```
228
+ */
229
+ exports.ServiceOptions = react_1.default.forwardRef((props, ref) => {
230
+ const { asChild, children } = props;
231
+ return ((0, jsx_runtime_1.jsx)(CorePayment.ServiceOptions, { children: ({ isOnline, isInPerson, isDeposit }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, customElement: children, customElementProps: { isOnline, isInPerson, isDeposit }, "data-testid": exports.TestIds.paymentServiceOptions, "data-is-online": isOnline, "data-is-in-person": isInPerson, "data-is-deposit": isDeposit, children: null })) }));
232
+ });
233
+ exports.ServiceOptions.displayName = 'Payment.ServiceOptions';
203
234
  /**
204
235
  * Container component for line items.
205
236
  * Follows the 3-level List/Options/Repeater pattern.
@@ -1,24 +1,2 @@
1
- /**
2
- * Book Action - Orchestrates the booking flow
3
- *
4
- * 1. Validates booking data with canBook()
5
- * 2. Creates a booking via createBooking() from API layer
6
- * 3. Creates a checkout via createCheckout() from API layer
7
- * 4. Determines if checkout is required or can be skipped
8
- * 5. Returns appropriate result for navigation
9
- */
10
1
  import { type BookActionParams, type BookResult } from './types.js';
11
- /**
12
- * Executes the complete booking flow:
13
- * 1. Validates that all required data is present
14
- * 2. Creates a booking with the selected service, time slot, and form data
15
- * 3. Creates a checkout session for payment (includes contact details from booking)
16
- * 4. Determines if checkout page is required or can be skipped
17
- * 5. If checkout can be skipped (free/offline), creates order directly
18
- * 6. Returns appropriate result for navigation
19
- *
20
- * @param params - The booking action parameters
21
- * @returns BookResult with either checkoutId or orderId
22
- * @throws Error if validation fails, or booking/checkout/order creation fails
23
- */
24
2
  export declare function executeBookAction(params: BookActionParams): Promise<BookResult>;
@@ -1,38 +1,16 @@
1
1
  "use strict";
2
- /**
3
- * Book Action - Orchestrates the booking flow
4
- *
5
- * 1. Validates booking data with canBook()
6
- * 2. Creates a booking via createBooking() from API layer
7
- * 3. Creates a checkout via createCheckout() from API layer
8
- * 4. Determines if checkout is required or can be skipped
9
- * 5. Returns appropriate result for navigation
10
- */
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.executeBookAction = executeBookAction;
13
4
  const index_js_1 = require("../../../api/create-booking/index.js");
14
- const index_js_2 = require("../../../api/create-checkout/index.js");
15
- const index_js_3 = require("../../../api/create-order/index.js");
5
+ const index_js_2 = require("../../../api/create-cart/index.js");
6
+ const index_js_3 = require("../../../api/calculate-cart/index.js");
7
+ const index_js_4 = require("../../../api/place-order/index.js");
16
8
  const buildBookingRequest_js_1 = require("./buildBookingRequest.js");
17
- const buildCheckoutRequest_js_1 = require("./buildCheckoutRequest.js");
9
+ const buildCartRequest_js_1 = require("./buildCartRequest.js");
18
10
  const canBook_js_1 = require("./canBook.js");
19
11
  const isCheckoutRequired_js_1 = require("./isCheckoutRequired.js");
20
12
  const types_js_1 = require("./types.js");
21
- /**
22
- * Executes the complete booking flow:
23
- * 1. Validates that all required data is present
24
- * 2. Creates a booking with the selected service, time slot, and form data
25
- * 3. Creates a checkout session for payment (includes contact details from booking)
26
- * 4. Determines if checkout page is required or can be skipped
27
- * 5. If checkout can be skipped (free/offline), creates order directly
28
- * 6. Returns appropriate result for navigation
29
- *
30
- * @param params - The booking action parameters
31
- * @returns BookResult with either checkoutId or orderId
32
- * @throws Error if validation fails, or booking/checkout/order creation fails
33
- */
34
13
  async function executeBookAction(params) {
35
- // Step 0: Validate
36
14
  if (!(0, canBook_js_1.canBook)({
37
15
  serviceSelections: params.serviceSelections,
38
16
  formSubmission: params.formSubmission,
@@ -51,34 +29,37 @@ async function executeBookAction(params) {
51
29
  if (!bookingId) {
52
30
  throw new Error('Failed to create booking');
53
31
  }
54
- // Step 2: Create checkout
55
- // businessLocationId: prefer timeSlot.location, fallback to global location
32
+ // Step 2: Create cart
56
33
  const firstSelection = params.serviceSelections[0];
57
34
  if (!firstSelection) {
58
35
  throw new Error('No service selection found');
59
36
  }
60
37
  const businessLocationId = firstSelection.timeSlot?.location?._id ?? undefined;
61
- const checkoutRequest = (0, buildCheckoutRequest_js_1.buildCheckoutRequest)({
38
+ const cartRequest = (0, buildCartRequest_js_1.buildCartRequest)({
62
39
  bookingId,
63
40
  contactDetails,
64
41
  businessLocationId,
65
42
  appId: params.appId,
66
43
  });
67
- const checkoutResponse = await (0, index_js_2.createCheckout)(checkoutRequest);
68
- const checkout = checkoutResponse.checkout;
69
- if (!checkout?._id) {
70
- throw new Error('Failed to create checkout');
44
+ const cart = await (0, index_js_2.createCart)(cartRequest);
45
+ if (!cart._id) {
46
+ throw new Error('Failed to create cart');
71
47
  }
72
- // Step 3: Determine if checkout is required or can be skipped
48
+ // Step 3: Calculate cart to get totals (not stored on Cart V2 entity)
49
+ const { cart: calculatedCart, summary } = await (0, index_js_3.calculateCart)(cart._id);
50
+ if (!calculatedCart || !summary) {
51
+ throw new Error('Failed to calculate cart');
52
+ }
53
+ // Step 4: Determine if checkout is required or can be skipped
73
54
  const service = firstSelection.service;
74
- if ((0, isCheckoutRequired_js_1.isCheckoutRequired)(checkout, service)) {
75
- return { type: types_js_1.BookResultType.CheckoutRequired, checkoutId: checkout._id };
55
+ if ((0, isCheckoutRequired_js_1.isCheckoutRequired)(calculatedCart, summary, service)) {
56
+ return { type: types_js_1.BookResultType.CheckoutRequired, cartId: cart._id };
76
57
  }
77
- // Step 4: Skip checkout - create order directly
78
- const orderResponse = await (0, index_js_3.createOrder)(checkout._id);
58
+ // Step 5: Skip checkout — place order directly
59
+ const orderResponse = await (0, index_js_4.placeOrder)(cart._id);
79
60
  const orderId = orderResponse.orderId;
80
61
  if (!orderId) {
81
- throw new Error('Failed to create order');
62
+ throw new Error('Failed to place order');
82
63
  }
83
64
  return { type: types_js_1.BookResultType.CheckoutSkipped, orderId };
84
65
  }
@@ -0,0 +1,10 @@
1
+ import { type CreateCartOptions } from '../../../api/create-cart/index.js';
2
+ import type { ContactDetails } from '../../../api/create-booking/index.js';
3
+ export interface BuildCartParams {
4
+ bookingId: string;
5
+ contactDetails?: ContactDetails;
6
+ businessLocationId?: string;
7
+ /** Optional app ID override for the catalog reference. Defaults to BOOKING_APP_ID. */
8
+ appId?: string;
9
+ }
10
+ export declare function buildCartRequest(params: BuildCartParams): CreateCartOptions;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCartRequest = buildCartRequest;
4
+ const index_js_1 = require("../../../api/create-cart/index.js");
5
+ const constants_js_1 = require("../../constants.js");
6
+ function buildCartRequest(params) {
7
+ const { bookingId, contactDetails, businessLocationId, appId } = params;
8
+ const cart = {
9
+ source: { channelType: index_js_1.ChannelType.WEB },
10
+ };
11
+ if (businessLocationId) {
12
+ cart.businessInfo = { locationId: businessLocationId };
13
+ }
14
+ if (contactDetails) {
15
+ cart.customerInfo = {
16
+ ...(contactDetails.email ? { email: contactDetails.email } : {}),
17
+ };
18
+ if (contactDetails.fullAddress?.country) {
19
+ cart.deliveryInfo = { address: { ...contactDetails.fullAddress } };
20
+ cart.paymentInfo = {
21
+ billingAddress: { ...contactDetails.fullAddress },
22
+ };
23
+ }
24
+ }
25
+ return {
26
+ catalogItems: [
27
+ {
28
+ quantity: 1,
29
+ catalogReference: {
30
+ catalogItemId: bookingId,
31
+ appId: appId ?? constants_js_1.BOOKING_APP_ID,
32
+ },
33
+ },
34
+ ],
35
+ cart,
36
+ };
37
+ }
@@ -4,6 +4,6 @@
4
4
  export { executeBookAction } from './bookAction.js';
5
5
  export { canBook, type CanBookParams } from './canBook.js';
6
6
  export { buildBookingRequest } from './buildBookingRequest.js';
7
- export { buildCheckoutRequest, type BuildCheckoutParams, } from './buildCheckoutRequest.js';
7
+ export { buildCartRequest, type BuildCartParams } from './buildCartRequest.js';
8
8
  export { isCheckoutRequired } from './isCheckoutRequired.js';
9
9
  export { BookResultType, type BookProps, type BookResult, type BookingError, type BookActionParams, type BookChildProps, } from './types.js';
@@ -3,15 +3,15 @@
3
3
  * Book Action - Exports
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BookResultType = exports.isCheckoutRequired = exports.buildCheckoutRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = void 0;
6
+ exports.BookResultType = exports.isCheckoutRequired = exports.buildCartRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = void 0;
7
7
  var bookAction_js_1 = require("./bookAction.js");
8
8
  Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: function () { return bookAction_js_1.executeBookAction; } });
9
9
  var canBook_js_1 = require("./canBook.js");
10
10
  Object.defineProperty(exports, "canBook", { enumerable: true, get: function () { return canBook_js_1.canBook; } });
11
11
  var buildBookingRequest_js_1 = require("./buildBookingRequest.js");
12
12
  Object.defineProperty(exports, "buildBookingRequest", { enumerable: true, get: function () { return buildBookingRequest_js_1.buildBookingRequest; } });
13
- var buildCheckoutRequest_js_1 = require("./buildCheckoutRequest.js");
14
- Object.defineProperty(exports, "buildCheckoutRequest", { enumerable: true, get: function () { return buildCheckoutRequest_js_1.buildCheckoutRequest; } });
13
+ var buildCartRequest_js_1 = require("./buildCartRequest.js");
14
+ Object.defineProperty(exports, "buildCartRequest", { enumerable: true, get: function () { return buildCartRequest_js_1.buildCartRequest; } });
15
15
  var isCheckoutRequired_js_1 = require("./isCheckoutRequired.js");
16
16
  Object.defineProperty(exports, "isCheckoutRequired", { enumerable: true, get: function () { return isCheckoutRequired_js_1.isCheckoutRequired; } });
17
17
  var types_js_1 = require("./types.js");
@@ -1,20 +1,4 @@
1
- /**
2
- * Determines if checkout page is required based on payment amounts
3
- */
4
- import type { Checkout } from '@wix/auto_sdk_ecom_checkout';
1
+ import type { Cart } from '../../../api/create-cart/index.js';
2
+ import type { CartSummary } from '../../../api/calculate-cart/index.js';
5
3
  import type { Service } from '@wix/auto_sdk_bookings_services';
6
- /**
7
- * Determines if checkout page is required based on payment amounts.
8
- *
9
- * Skip checkout when:
10
- * - Free booking: payNow = 0 AND payLater = 0
11
- * - Offline payment: payNow = 0
12
- *
13
- * Force checkout when:
14
- * - Service has cancellation fee policy
15
- *
16
- * @param checkout - The checkout response from createCheckout
17
- * @param service - The service being booked
18
- * @returns true if checkout page is required, false if can skip to order
19
- */
20
- export declare function isCheckoutRequired(checkout: Checkout, service: Service): boolean;
4
+ export declare function isCheckoutRequired(cart: Cart, summary: CartSummary, service: Service): boolean;
@@ -1,35 +1,17 @@
1
1
  "use strict";
2
- /**
3
- * Determines if checkout page is required based on payment amounts
4
- */
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.isCheckoutRequired = isCheckoutRequired;
7
- /**
8
- * Determines if checkout page is required based on payment amounts.
9
- *
10
- * Skip checkout when:
11
- * - Free booking: payNow = 0 AND payLater = 0
12
- * - Offline payment: payNow = 0
13
- *
14
- * Force checkout when:
15
- * - Service has cancellation fee policy
16
- *
17
- * @param checkout - The checkout response from createCheckout
18
- * @param service - The service being booked
19
- * @returns true if checkout page is required, false if can skip to order
20
- */
21
- function isCheckoutRequired(checkout, service) {
22
- // Force checkout for cancellation fee policy
23
- const hasCancellationFee = service.bookingPolicy?.cancellationFeePolicy?.enabled;
24
- if (hasCancellationFee) {
4
+ function isCheckoutRequired(cart, summary, service) {
5
+ if (service.bookingPolicy?.cancellationFeePolicy?.enabled) {
25
6
  return true;
26
7
  }
27
- const payNowAmount = Number(checkout.payNow?.total?.amount ?? 0);
28
- const payLaterAmount = Number(checkout.payLater?.total?.amount ?? 0);
29
- // Free or price plan: both amounts are 0
30
- const isFreeOrPricePlan = payNowAmount === 0 && payLaterAmount === 0;
31
- // Offline payment: payNow is 0
32
- const isOfflinePayment = payNowAmount === 0;
33
- // Skip checkout if free/price plan OR offline payment
34
- return !(isFreeOrPricePlan || isOfflinePayment);
8
+ const total = Number(summary.priceSummary?.total?.amount ?? 0);
9
+ if (total === 0) {
10
+ return false;
11
+ }
12
+ const paymentOption = cart.lineItems?.[0]?.paymentConfig?.paymentOption;
13
+ if (paymentOption === 'FULL_PAYMENT_OFFLINE') {
14
+ return false;
15
+ }
16
+ return true;
35
17
  }
@@ -16,7 +16,7 @@ export declare enum BookResultType {
16
16
  */
17
17
  export type BookResult = {
18
18
  type: BookResultType.CheckoutRequired;
19
- checkoutId: string;
19
+ cartId: string;
20
20
  } | {
21
21
  type: BookResultType.CheckoutSkipped;
22
22
  orderId: string;
@@ -7,8 +7,8 @@ export { BookingService, BookingServiceDefinition, type BookingServiceConfig, ty
7
7
  export { TimeSlotListService, TimeSlotListServiceDefinition, TimeSlotService, TimeSlotServiceDefinition, ViewMode, loadTimeSlotListConfig, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type TimeSlotServiceAPI, type TimeSlotServiceConfig, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list/index.js';
8
8
  export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
9
9
  export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from '../api/query-services/index.js';
10
- export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCheckoutParams, } from './booking/book-action/index.js';
10
+ export { executeBookAction, canBook, buildBookingRequest, buildCartRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCartParams, } from './booking/book-action/index.js';
11
11
  export { BookingFormService, BookingFormServiceDefinition, type BookingFormServiceAPI, type BookingFormServiceConfig, } from './booking-form/booking-form.js';
12
- export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, loadPaymentConfig, type SuccessPaymentConfigResult, type ErrorPaymentConfigResult, } from './payment/payment.js';
12
+ export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, type ServicePaymentOptions, loadPaymentConfig, type SuccessPaymentConfigResult, type ErrorPaymentConfigResult, } from './payment/payment.js';
13
13
  export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, type LocationListServiceAPI, type LocationListServiceConfig, type LocationListActions, type Location, type LoadLocationListServiceResult, getLocationById, } from './location-list/location-list.js';
14
14
  export { StaffMemberListService, StaffMemberListServiceDefinition, loadStaffMemberListServiceInitialData, staffMemberListServiceBinding, type StaffMemberListServiceAPI, type StaffMemberListServiceConfig, type StaffMemberListActions, type StaffMemberData, type LoadStaffMemberListServiceResult, } from './staff-member-list/staff-member-list.js';
@@ -4,7 +4,7 @@
4
4
  * Main export file for all service definitions and implementations
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.staffMemberListServiceBinding = exports.loadStaffMemberListServiceInitialData = exports.StaffMemberListServiceDefinition = exports.StaffMemberListService = exports.getLocationById = exports.locationListServiceBinding = exports.loadLocationListServiceInitialData = exports.LocationType = exports.LocationListServiceDefinition = exports.LocationListService = exports.loadPaymentConfig = exports.PaymentServiceDefinition = exports.PaymentService = exports.BookingFormServiceDefinition = exports.BookingFormService = exports.buildCheckoutRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.loadServiceListServiceInitialData = exports.ServiceListServiceDefinition = exports.ServiceListService = exports.loadTimeSlotListConfig = exports.ViewMode = exports.TimeSlotServiceDefinition = exports.TimeSlotService = exports.TimeSlotListServiceDefinition = exports.TimeSlotListService = exports.BookingServiceDefinition = exports.BookingService = exports.loadServiceServiceInitialData = exports.ServiceServiceDefinition = exports.ServiceService = void 0;
7
+ exports.staffMemberListServiceBinding = exports.loadStaffMemberListServiceInitialData = exports.StaffMemberListServiceDefinition = exports.StaffMemberListService = exports.getLocationById = exports.locationListServiceBinding = exports.loadLocationListServiceInitialData = exports.LocationType = exports.LocationListServiceDefinition = exports.LocationListService = exports.loadPaymentConfig = exports.PaymentServiceDefinition = exports.PaymentService = exports.BookingFormServiceDefinition = exports.BookingFormService = exports.buildCartRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.loadServiceListServiceInitialData = exports.ServiceListServiceDefinition = exports.ServiceListService = exports.loadTimeSlotListConfig = exports.ViewMode = exports.TimeSlotServiceDefinition = exports.TimeSlotService = exports.TimeSlotListServiceDefinition = exports.TimeSlotListService = exports.BookingServiceDefinition = exports.BookingService = exports.loadServiceServiceInitialData = exports.ServiceServiceDefinition = exports.ServiceService = void 0;
8
8
  var service_js_1 = require("./service/service.js");
9
9
  Object.defineProperty(exports, "ServiceService", { enumerable: true, get: function () { return service_js_1.ServiceService; } });
10
10
  Object.defineProperty(exports, "ServiceServiceDefinition", { enumerable: true, get: function () { return service_js_1.ServiceServiceDefinition; } });
@@ -30,7 +30,7 @@ var index_js_3 = require("./booking/book-action/index.js");
30
30
  Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: function () { return index_js_3.executeBookAction; } });
31
31
  Object.defineProperty(exports, "canBook", { enumerable: true, get: function () { return index_js_3.canBook; } });
32
32
  Object.defineProperty(exports, "buildBookingRequest", { enumerable: true, get: function () { return index_js_3.buildBookingRequest; } });
33
- Object.defineProperty(exports, "buildCheckoutRequest", { enumerable: true, get: function () { return index_js_3.buildCheckoutRequest; } });
33
+ Object.defineProperty(exports, "buildCartRequest", { enumerable: true, get: function () { return index_js_3.buildCartRequest; } });
34
34
  var booking_form_js_1 = require("./booking-form/booking-form.js");
35
35
  Object.defineProperty(exports, "BookingFormService", { enumerable: true, get: function () { return booking_form_js_1.BookingFormService; } });
36
36
  Object.defineProperty(exports, "BookingFormServiceDefinition", { enumerable: true, get: function () { return booking_form_js_1.BookingFormServiceDefinition; } });