@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
@@ -1,32 +1,14 @@
1
- /**
2
- * Determines if checkout page is required based on payment amounts
3
- */
4
- /**
5
- * Determines if checkout page is required based on payment amounts.
6
- *
7
- * Skip checkout when:
8
- * - Free booking: payNow = 0 AND payLater = 0
9
- * - Offline payment: payNow = 0
10
- *
11
- * Force checkout when:
12
- * - Service has cancellation fee policy
13
- *
14
- * @param checkout - The checkout response from createCheckout
15
- * @param service - The service being booked
16
- * @returns true if checkout page is required, false if can skip to order
17
- */
18
- export function isCheckoutRequired(checkout, service) {
19
- // Force checkout for cancellation fee policy
20
- const hasCancellationFee = service.bookingPolicy?.cancellationFeePolicy?.enabled;
21
- if (hasCancellationFee) {
1
+ export function isCheckoutRequired(cart, summary, service) {
2
+ if (service.bookingPolicy?.cancellationFeePolicy?.enabled) {
22
3
  return true;
23
4
  }
24
- const payNowAmount = Number(checkout.payNow?.total?.amount ?? 0);
25
- const payLaterAmount = Number(checkout.payLater?.total?.amount ?? 0);
26
- // Free or price plan: both amounts are 0
27
- const isFreeOrPricePlan = payNowAmount === 0 && payLaterAmount === 0;
28
- // Offline payment: payNow is 0
29
- const isOfflinePayment = payNowAmount === 0;
30
- // Skip checkout if free/price plan OR offline payment
31
- return !(isFreeOrPricePlan || isOfflinePayment);
5
+ const total = Number(summary.priceSummary?.total?.amount ?? 0);
6
+ if (total === 0) {
7
+ return false;
8
+ }
9
+ const paymentOption = cart.lineItems?.[0]?.paymentConfig?.paymentOption;
10
+ if (paymentOption === 'FULL_PAYMENT_OFFLINE') {
11
+ return false;
12
+ }
13
+ return true;
32
14
  }
@@ -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';
@@ -7,7 +7,7 @@ export { BookingService, BookingServiceDefinition, } from './booking/booking.js'
7
7
  export { TimeSlotListService, TimeSlotListServiceDefinition, TimeSlotService, TimeSlotServiceDefinition, ViewMode, loadTimeSlotListConfig, } from './time-slot-list/index.js';
8
8
  export { ServiceListService, ServiceListServiceDefinition, loadServiceListServiceInitialData, } 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, } from './booking/book-action/index.js';
10
+ export { executeBookAction, canBook, buildBookingRequest, buildCartRequest, } from './booking/book-action/index.js';
11
11
  export { BookingFormService, BookingFormServiceDefinition, } from './booking-form/booking-form.js';
12
12
  export { PaymentService, PaymentServiceDefinition, loadPaymentConfig, } from './payment/payment.js';
13
13
  export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, getLocationById, } from './location-list/location-list.js';
@@ -4,7 +4,7 @@
4
4
  * Supports two modes: SSR (config with pre-fetched data) and lazy loading (reactive)
5
5
  */
6
6
  import { type PaymentServiceConfig, type PaymentServiceInternalConfig, type PricingServiceSelection } from './payment.def.js';
7
- export { PaymentServiceDefinition, type PaymentServiceConfig, type PaymentDetails, type LineItemAdditionalInfo, type PricingServiceSelection, } from './payment.def.js';
7
+ export { PaymentServiceDefinition, type PaymentServiceConfig, type PaymentDetails, type LineItemAdditionalInfo, type PricingServiceSelection, type ServicePaymentOptions, } from './payment.def.js';
8
8
  export type { PaymentServiceAPI, PaymentServiceInternalConfig, } from './payment.def.js';
9
9
  export declare const PaymentService: import("@wix/services-definitions").ServiceFactory<string & {
10
10
  __api: import("./payment.def.js").PaymentServiceAPI;
@@ -5,6 +5,18 @@
5
5
  import type { Signal } from '@wix/services-definitions/core-services/signals';
6
6
  import type { CalculateTotalsResponse } from '@wix/auto_sdk_ecom_totals-calculator';
7
7
  import type { Service } from '@wix/auto_sdk_bookings_services';
8
+ /**
9
+ * Service payment options derived from service.payment.options.
10
+ * Describes which payment methods the service supports.
11
+ */
12
+ export interface ServicePaymentOptions {
13
+ /** Customer can pay online at booking time */
14
+ isOnline: boolean;
15
+ /** Customer can pay in person (on arrival) */
16
+ isInPerson: boolean;
17
+ /** A deposit is required at booking time */
18
+ isDeposit: boolean;
19
+ }
8
20
  /**
9
21
  * Payment option for line items
10
22
  */
@@ -44,6 +56,8 @@ export interface PricingServiceSelection {
44
56
  export interface PaymentServiceConfig {
45
57
  /** Pre-calculated payment details for SSR (no API call) */
46
58
  paymentDetails?: PaymentDetails;
59
+ /** Service payment options for SSR (derived from service.payment.options) */
60
+ serviceOptions?: ServicePaymentOptions;
47
61
  }
48
62
  /**
49
63
  * Internal config used by Core component to pass lazy loading data
@@ -59,6 +73,7 @@ export interface PaymentServiceAPI {
59
73
  paymentDetailsSignal: Signal<PaymentDetails | null>;
60
74
  isLoadingSignal: Signal<boolean>;
61
75
  errorSignal: Signal<string | null>;
76
+ serviceOptionsSignal: Signal<ServicePaymentOptions>;
62
77
  }
63
78
  export declare const PaymentServiceDefinition: string & {
64
79
  __api: PaymentServiceAPI;
@@ -15,6 +15,35 @@ import { BOOKING_APP_ID } from '../constants.js';
15
15
  // ============================================================================
16
16
  // Helper Functions
17
17
  // ============================================================================
18
+ const DEFAULT_SERVICE_OPTIONS = {
19
+ isOnline: false,
20
+ isInPerson: false,
21
+ isDeposit: false,
22
+ };
23
+ /**
24
+ * Derives static service payment options from the first service's configuration.
25
+ *
26
+ * Note on `isDeposit`: this reflects whether the service is *configured* with a
27
+ * deposit (i.e. `payment.fixed.deposit.value > 0`), consistent with how
28
+ * `buildLineItem` determines `hasDeposit`. Only `FIXED` rate type is checked;
29
+ * `VARIED` pricing is not currently supported for deposit detection here.
30
+ *
31
+ * This is distinct from the runtime `isDeposit` flag in `CorePayment.Data`, which
32
+ * is computed dynamically from the ecom API result (`payNow.amount < total.amount`).
33
+ * Use `Payment.ServiceOptions` to determine *which scenario to render* (static config),
34
+ * and `Payment.PayNow`/`Payment.PayLater` for the *actual split amounts* (runtime).
35
+ */
36
+ function deriveServiceOptions(pricingServiceSelections) {
37
+ const service = pricingServiceSelections[0]?.service;
38
+ const options = service?.payment?.options;
39
+ const depositValue = service?.payment?.fixed?.deposit?.value;
40
+ const hasDeposit = !!depositValue && Number(depositValue) > 0;
41
+ return {
42
+ isOnline: !!options?.online,
43
+ isInPerson: !!options?.inPerson,
44
+ isDeposit: hasDeposit,
45
+ };
46
+ }
18
47
  function getAdditionalInfo(service, lineItemId) {
19
48
  const payment = service.payment;
20
49
  const customPrice = payment?.rateType === RateType.CUSTOM && payment.custom?.description
@@ -92,6 +121,7 @@ export const PaymentService = implementService.withConfig()(PaymentServiceDefini
92
121
  const paymentDetailsSignal = signalsService.signal(config.paymentDetails || null);
93
122
  const isLoadingSignal = signalsService.signal(false);
94
123
  const errorSignal = signalsService.signal(null);
124
+ const serviceOptionsSignal = signalsService.signal(config.serviceOptions || DEFAULT_SERVICE_OPTIONS);
95
125
  // Internal calculate function
96
126
  const calculate = async (pricingServiceSelections, totalParticipants) => {
97
127
  if (!pricingServiceSelections.length) {
@@ -117,10 +147,18 @@ export const PaymentService = implementService.withConfig()(PaymentServiceDefini
117
147
  };
118
148
  // Mode 1: SSR - paymentDetails already set in signal initialization
119
149
  if (config.paymentDetails) {
120
- // No-op - data is pre-fetched
150
+ if (!config.serviceOptions &&
151
+ process.env['NODE_ENV'] !== 'production') {
152
+ console.warn('[PaymentService] SSR mode: `serviceOptions` was not provided in config. ' +
153
+ 'Payment.ServiceOptions will return all-false defaults. ' +
154
+ 'Use `loadPaymentConfig` to automatically derive serviceOptions, ' +
155
+ 'or pass `serviceOptions` explicitly in `paymentServiceConfig`.');
156
+ }
157
+ // serviceOptionsSignal already initialized from config.serviceOptions (or DEFAULT_SERVICE_OPTIONS)
121
158
  }
122
159
  // Mode 2: Lazy loading - pricingServiceSelections provided via internal config
123
160
  else if (config.pricingServiceSelections?.length) {
161
+ serviceOptionsSignal.set(deriveServiceOptions(config.pricingServiceSelections));
124
162
  void calculate(config.pricingServiceSelections, config.totalParticipants ?? 1);
125
163
  }
126
164
  // Mode 3: Reactive - observe BookingService signals (client-side only)
@@ -142,6 +180,9 @@ export const PaymentService = implementService.withConfig()(PaymentServiceDefini
142
180
  service: selection.service,
143
181
  lineItemId: selection.instanceId,
144
182
  }));
183
+ if (pricingServiceSelections.length) {
184
+ serviceOptionsSignal.set(deriveServiceOptions(pricingServiceSelections));
185
+ }
145
186
  void calculate(pricingServiceSelections, numParticipants);
146
187
  });
147
188
  }
@@ -149,6 +190,7 @@ export const PaymentService = implementService.withConfig()(PaymentServiceDefini
149
190
  paymentDetailsSignal,
150
191
  isLoadingSignal,
151
192
  errorSignal,
193
+ serviceOptionsSignal,
152
194
  };
153
195
  });
154
196
  /**
@@ -164,13 +206,19 @@ export async function loadPaymentConfig(params) {
164
206
  if (!pricingServiceSelections.length) {
165
207
  return {
166
208
  type: 'success',
167
- config: { paymentDetails: undefined },
209
+ config: {
210
+ paymentDetails: undefined,
211
+ serviceOptions: DEFAULT_SERVICE_OPTIONS,
212
+ },
168
213
  };
169
214
  }
170
215
  const paymentDetails = await calculatePaymentDetails(pricingServiceSelections, totalParticipants);
171
216
  return {
172
217
  type: 'success',
173
- config: { paymentDetails },
218
+ config: {
219
+ paymentDetails,
220
+ serviceOptions: deriveServiceOptions(pricingServiceSelections),
221
+ },
174
222
  };
175
223
  }
176
224
  catch (error) {
@@ -1,7 +1,7 @@
1
1
  export interface NavigationInfo {
2
2
  postFlowUrl: string;
3
3
  }
4
- export declare function navigateToCheckout({ checkoutId, navigationInfo, }: {
5
- checkoutId: string;
4
+ export declare function navigateToCheckout({ cartId, navigationInfo, }: {
5
+ cartId: string;
6
6
  navigationInfo: NavigationInfo;
7
7
  }): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { redirects } from '@wix/redirects';
2
- export async function navigateToCheckout({ checkoutId, navigationInfo, }) {
2
+ export async function navigateToCheckout({ cartId, navigationInfo, }) {
3
3
  const { redirectSession } = await redirects.createRedirectSession({
4
- ecomCheckout: { checkoutId },
4
+ ecomCheckout: { checkoutId: cartId },
5
5
  callbacks: {
6
6
  postFlowUrl: navigationInfo.postFlowUrl,
7
7
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-bookings",
3
- "version": "0.0.117",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@wix/auto_sdk_bookings_bookings": "^1.0.103",
38
38
  "@wix/auto_sdk_bookings_event-time-slots": "^1.0.64",
39
- "@wix/auto_sdk_ecom_checkout": "^1.0.104",
39
+ "@wix/auto_sdk_ecom_cart-v-2": "^1.0.86",
40
40
  "@wix/forms": "^1.0.384",
41
41
  "@wix/headless-media": "0.0.25",
42
42
  "@wix/headless-utils": "0.0.12",
@@ -73,5 +73,5 @@
73
73
  "groupId": "com.wixpress.headless-components"
74
74
  }
75
75
  },
76
- "falconPackageHash": "f3af7c27f3ef8bd8bdc06d522c39551763e5bf65fd9fe6891ba25425"
76
+ "falconPackageHash": "c937e3d58e53147f0712bea70a6759a841fd018967a90028599b0895"
77
77
  }
@@ -1,40 +0,0 @@
1
- /**
2
- * Create Checkout API
3
- * Wrapper for the Wix eCommerce createCheckout SDK function
4
- */
5
- import { type CreateCheckoutRequest, type Checkout } from '@wix/auto_sdk_ecom_checkout';
6
- /**
7
- * Response from createCheckout API
8
- */
9
- export interface CreateCheckoutResponse {
10
- /** The created checkout */
11
- checkout?: Checkout;
12
- }
13
- /**
14
- * Creates a checkout session with the specified request data
15
- *
16
- * @param request - The checkout request data including line items and checkout info
17
- * @returns Promise resolving to the created checkout response
18
- *
19
- * @example
20
- * ```typescript
21
- * const response = await createCheckout({
22
- * channelType: ChannelType.WEB,
23
- * lineItems: [
24
- * {
25
- * quantity: 1,
26
- * catalogReference: {
27
- * catalogItemId: bookingId,
28
- * appId: BOOKINGS_APP_DEF_ID,
29
- * },
30
- * },
31
- * ],
32
- * checkoutInfo: {
33
- * businessLocationId,
34
- * billingInfo: { ... },
35
- * },
36
- * });
37
- * ```
38
- */
39
- export declare function createCheckout(request: CreateCheckoutRequest): Promise<CreateCheckoutResponse>;
40
- export { ChannelType, type CreateCheckoutRequest, } from '@wix/auto_sdk_ecom_checkout';
@@ -1,42 +0,0 @@
1
- "use strict";
2
- /**
3
- * Create Checkout API
4
- * Wrapper for the Wix eCommerce createCheckout SDK function
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ChannelType = void 0;
8
- exports.createCheckout = createCheckout;
9
- const auto_sdk_ecom_checkout_1 = require("@wix/auto_sdk_ecom_checkout");
10
- /**
11
- * Creates a checkout session with the specified request data
12
- *
13
- * @param request - The checkout request data including line items and checkout info
14
- * @returns Promise resolving to the created checkout response
15
- *
16
- * @example
17
- * ```typescript
18
- * const response = await createCheckout({
19
- * channelType: ChannelType.WEB,
20
- * lineItems: [
21
- * {
22
- * quantity: 1,
23
- * catalogReference: {
24
- * catalogItemId: bookingId,
25
- * appId: BOOKINGS_APP_DEF_ID,
26
- * },
27
- * },
28
- * ],
29
- * checkoutInfo: {
30
- * businessLocationId,
31
- * billingInfo: { ... },
32
- * },
33
- * });
34
- * ```
35
- */
36
- async function createCheckout(request) {
37
- const checkout = await (0, auto_sdk_ecom_checkout_1.createCheckout)(request);
38
- return { checkout };
39
- }
40
- // Re-export types and constants that consumers may need
41
- var auto_sdk_ecom_checkout_2 = require("@wix/auto_sdk_ecom_checkout");
42
- Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return auto_sdk_ecom_checkout_2.ChannelType; } });
@@ -1,20 +0,0 @@
1
- /**
2
- * Create Order API
3
- * Wrapper for the Wix eCommerce createOrder SDK function
4
- */
5
- import { type CreateOrderOptions, type CreateOrderResponse } from '@wix/auto_sdk_ecom_checkout';
6
- /**
7
- * Creates an order from a checkout session
8
- *
9
- * @param checkoutId - The checkout session ID
10
- * @param options - Optional additional order creation options
11
- * @returns Promise resolving to the created order response
12
- *
13
- * @example
14
- * ```typescript
15
- * const response = await createOrder(checkoutId);
16
- * const orderId = response.orderId;
17
- * ```
18
- */
19
- export declare function createOrder(checkoutId: string, options?: CreateOrderOptions): Promise<CreateOrderResponse>;
20
- export type { CreateOrderOptions, CreateOrderResponse };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /**
3
- * Create Order API
4
- * Wrapper for the Wix eCommerce createOrder SDK function
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createOrder = createOrder;
8
- const auto_sdk_ecom_checkout_1 = require("@wix/auto_sdk_ecom_checkout");
9
- /**
10
- * Creates an order from a checkout session
11
- *
12
- * @param checkoutId - The checkout session ID
13
- * @param options - Optional additional order creation options
14
- * @returns Promise resolving to the created order response
15
- *
16
- * @example
17
- * ```typescript
18
- * const response = await createOrder(checkoutId);
19
- * const orderId = response.orderId;
20
- * ```
21
- */
22
- async function createOrder(checkoutId, options) {
23
- return (0, auto_sdk_ecom_checkout_1.createOrder)(checkoutId, options);
24
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Builds the createCheckout request
3
- */
4
- import { type CreateCheckoutRequest } from '../../../api/create-checkout/index.js';
5
- import type { ContactDetails } from '../../../api/create-booking/index.js';
6
- /**
7
- * Parameters for building checkout request
8
- */
9
- export interface BuildCheckoutParams {
10
- bookingId: string;
11
- contactDetails?: ContactDetails;
12
- businessLocationId?: string;
13
- /** Optional app ID override for the catalog reference. Defaults to BOOKING_APP_ID. */
14
- appId?: string;
15
- }
16
- /**
17
- * Builds a checkout request from the booking ID and contact details
18
- *
19
- * Contact details come from the booking response and are used to populate:
20
- * - billingInfo.contactDetails (firstName, lastName, phone)
21
- * - billingInfo.address (from fullAddress if available)
22
- * - shippingInfo.shippingDestination.contactDetails
23
- * - buyerInfo (email, contactId)
24
- *
25
- * @param params - The checkout parameters
26
- * @returns CreateCheckoutRequest ready to be sent to the API
27
- */
28
- export declare function buildCheckoutRequest(params: BuildCheckoutParams): CreateCheckoutRequest;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- /**
3
- * Builds the createCheckout request
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildCheckoutRequest = buildCheckoutRequest;
7
- const index_js_1 = require("../../../api/create-checkout/index.js");
8
- const constants_js_1 = require("../../constants.js");
9
- /**
10
- * Builds a checkout request from the booking ID and contact details
11
- *
12
- * Contact details come from the booking response and are used to populate:
13
- * - billingInfo.contactDetails (firstName, lastName, phone)
14
- * - billingInfo.address (from fullAddress if available)
15
- * - shippingInfo.shippingDestination.contactDetails
16
- * - buyerInfo (email, contactId)
17
- *
18
- * @param params - The checkout parameters
19
- * @returns CreateCheckoutRequest ready to be sent to the API
20
- */
21
- function buildCheckoutRequest(params) {
22
- const { bookingId, contactDetails, businessLocationId, appId } = params;
23
- // Build checkoutInfo incrementally for readability
24
- const checkoutInfo = {};
25
- // businessLocationId for multi-location support
26
- if (businessLocationId) {
27
- checkoutInfo.businessLocationId = businessLocationId;
28
- }
29
- // Billing info and shipping info from contact details
30
- if (contactDetails) {
31
- checkoutInfo.billingInfo = {
32
- contactDetails,
33
- ...(contactDetails.fullAddress?.country
34
- ? { address: { ...contactDetails.fullAddress } }
35
- : {}),
36
- };
37
- checkoutInfo.shippingInfo = {
38
- shippingDestination: {
39
- contactDetails,
40
- },
41
- };
42
- }
43
- // Buyer info with email and contactId
44
- if (contactDetails?.email) {
45
- checkoutInfo.buyerInfo = {
46
- email: contactDetails.email,
47
- ...(contactDetails.contactId
48
- ? { contactId: contactDetails.contactId }
49
- : {}),
50
- };
51
- }
52
- return {
53
- channelType: index_js_1.ChannelType.WEB,
54
- lineItems: [
55
- {
56
- quantity: 1,
57
- catalogReference: {
58
- catalogItemId: bookingId,
59
- appId: appId ?? constants_js_1.BOOKING_APP_ID,
60
- },
61
- },
62
- ],
63
- checkoutInfo,
64
- };
65
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * Create Checkout API
3
- * Wrapper for the Wix eCommerce createCheckout SDK function
4
- */
5
- import { type CreateCheckoutRequest, type Checkout } from '@wix/auto_sdk_ecom_checkout';
6
- /**
7
- * Response from createCheckout API
8
- */
9
- export interface CreateCheckoutResponse {
10
- /** The created checkout */
11
- checkout?: Checkout;
12
- }
13
- /**
14
- * Creates a checkout session with the specified request data
15
- *
16
- * @param request - The checkout request data including line items and checkout info
17
- * @returns Promise resolving to the created checkout response
18
- *
19
- * @example
20
- * ```typescript
21
- * const response = await createCheckout({
22
- * channelType: ChannelType.WEB,
23
- * lineItems: [
24
- * {
25
- * quantity: 1,
26
- * catalogReference: {
27
- * catalogItemId: bookingId,
28
- * appId: BOOKINGS_APP_DEF_ID,
29
- * },
30
- * },
31
- * ],
32
- * checkoutInfo: {
33
- * businessLocationId,
34
- * billingInfo: { ... },
35
- * },
36
- * });
37
- * ```
38
- */
39
- export declare function createCheckout(request: CreateCheckoutRequest): Promise<CreateCheckoutResponse>;
40
- export { ChannelType, type CreateCheckoutRequest, } from '@wix/auto_sdk_ecom_checkout';
@@ -1,37 +0,0 @@
1
- /**
2
- * Create Checkout API
3
- * Wrapper for the Wix eCommerce createCheckout SDK function
4
- */
5
- import { createCheckout as createCheckoutSdk, } from '@wix/auto_sdk_ecom_checkout';
6
- /**
7
- * Creates a checkout session with the specified request data
8
- *
9
- * @param request - The checkout request data including line items and checkout info
10
- * @returns Promise resolving to the created checkout response
11
- *
12
- * @example
13
- * ```typescript
14
- * const response = await createCheckout({
15
- * channelType: ChannelType.WEB,
16
- * lineItems: [
17
- * {
18
- * quantity: 1,
19
- * catalogReference: {
20
- * catalogItemId: bookingId,
21
- * appId: BOOKINGS_APP_DEF_ID,
22
- * },
23
- * },
24
- * ],
25
- * checkoutInfo: {
26
- * businessLocationId,
27
- * billingInfo: { ... },
28
- * },
29
- * });
30
- * ```
31
- */
32
- export async function createCheckout(request) {
33
- const checkout = await createCheckoutSdk(request);
34
- return { checkout };
35
- }
36
- // Re-export types and constants that consumers may need
37
- export { ChannelType, } from '@wix/auto_sdk_ecom_checkout';
@@ -1,20 +0,0 @@
1
- /**
2
- * Create Order API
3
- * Wrapper for the Wix eCommerce createOrder SDK function
4
- */
5
- import { type CreateOrderOptions, type CreateOrderResponse } from '@wix/auto_sdk_ecom_checkout';
6
- /**
7
- * Creates an order from a checkout session
8
- *
9
- * @param checkoutId - The checkout session ID
10
- * @param options - Optional additional order creation options
11
- * @returns Promise resolving to the created order response
12
- *
13
- * @example
14
- * ```typescript
15
- * const response = await createOrder(checkoutId);
16
- * const orderId = response.orderId;
17
- * ```
18
- */
19
- export declare function createOrder(checkoutId: string, options?: CreateOrderOptions): Promise<CreateOrderResponse>;
20
- export type { CreateOrderOptions, CreateOrderResponse };
@@ -1,21 +0,0 @@
1
- /**
2
- * Create Order API
3
- * Wrapper for the Wix eCommerce createOrder SDK function
4
- */
5
- import { createOrder as createOrderSdk, } from '@wix/auto_sdk_ecom_checkout';
6
- /**
7
- * Creates an order from a checkout session
8
- *
9
- * @param checkoutId - The checkout session ID
10
- * @param options - Optional additional order creation options
11
- * @returns Promise resolving to the created order response
12
- *
13
- * @example
14
- * ```typescript
15
- * const response = await createOrder(checkoutId);
16
- * const orderId = response.orderId;
17
- * ```
18
- */
19
- export async function createOrder(checkoutId, options) {
20
- return createOrderSdk(checkoutId, options);
21
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Builds the createCheckout request
3
- */
4
- import { type CreateCheckoutRequest } from '../../../api/create-checkout/index.js';
5
- import type { ContactDetails } from '../../../api/create-booking/index.js';
6
- /**
7
- * Parameters for building checkout request
8
- */
9
- export interface BuildCheckoutParams {
10
- bookingId: string;
11
- contactDetails?: ContactDetails;
12
- businessLocationId?: string;
13
- /** Optional app ID override for the catalog reference. Defaults to BOOKING_APP_ID. */
14
- appId?: string;
15
- }
16
- /**
17
- * Builds a checkout request from the booking ID and contact details
18
- *
19
- * Contact details come from the booking response and are used to populate:
20
- * - billingInfo.contactDetails (firstName, lastName, phone)
21
- * - billingInfo.address (from fullAddress if available)
22
- * - shippingInfo.shippingDestination.contactDetails
23
- * - buyerInfo (email, contactId)
24
- *
25
- * @param params - The checkout parameters
26
- * @returns CreateCheckoutRequest ready to be sent to the API
27
- */
28
- export declare function buildCheckoutRequest(params: BuildCheckoutParams): CreateCheckoutRequest;