@wix/headless-bookings 0.0.118 → 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.
- package/cjs/dist/api/calculate-cart/index.d.ts +3 -0
- package/cjs/dist/api/calculate-cart/index.js +7 -0
- package/cjs/dist/api/create-cart/index.d.ts +3 -0
- package/cjs/dist/api/create-cart/index.js +10 -0
- package/cjs/dist/api/index.d.ts +3 -9
- package/cjs/dist/api/index.js +12 -17
- package/cjs/dist/api/place-order/index.d.ts +3 -0
- package/cjs/dist/api/place-order/index.js +7 -0
- package/cjs/dist/react/booking/Book.js +1 -1
- package/cjs/dist/react/core/booking/Book.d.ts +1 -1
- package/cjs/dist/react/core/booking/Book.js +1 -1
- package/cjs/dist/services/booking/book-action/bookAction.d.ts +0 -22
- package/cjs/dist/services/booking/book-action/bookAction.js +20 -39
- package/cjs/dist/services/booking/book-action/buildCartRequest.d.ts +10 -0
- package/cjs/dist/services/booking/book-action/buildCartRequest.js +37 -0
- package/cjs/dist/services/booking/book-action/index.d.ts +1 -1
- package/cjs/dist/services/booking/book-action/index.js +3 -3
- package/cjs/dist/services/booking/book-action/isCheckoutRequired.d.ts +3 -19
- package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +11 -29
- package/cjs/dist/services/booking/book-action/types.d.ts +1 -1
- package/cjs/dist/services/index.d.ts +1 -1
- package/cjs/dist/services/index.js +2 -2
- package/cjs/dist/utils/navigation.d.ts +2 -2
- package/cjs/dist/utils/navigation.js +2 -2
- package/dist/api/calculate-cart/index.d.ts +3 -0
- package/dist/api/calculate-cart/index.js +4 -0
- package/dist/api/create-cart/index.d.ts +3 -0
- package/dist/api/create-cart/index.js +5 -0
- package/dist/api/index.d.ts +3 -9
- package/dist/api/index.js +3 -9
- package/dist/api/place-order/index.d.ts +3 -0
- package/dist/api/place-order/index.js +4 -0
- package/dist/react/booking/Book.js +1 -1
- package/dist/react/core/booking/Book.d.ts +1 -1
- package/dist/react/core/booking/Book.js +1 -1
- package/dist/services/booking/book-action/bookAction.d.ts +0 -22
- package/dist/services/booking/book-action/bookAction.js +20 -39
- package/dist/services/booking/book-action/buildCartRequest.d.ts +10 -0
- package/dist/services/booking/book-action/buildCartRequest.js +34 -0
- package/dist/services/booking/book-action/index.d.ts +1 -1
- package/dist/services/booking/book-action/index.js +1 -1
- package/dist/services/booking/book-action/isCheckoutRequired.d.ts +3 -19
- package/dist/services/booking/book-action/isCheckoutRequired.js +11 -29
- package/dist/services/booking/book-action/types.d.ts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/utils/navigation.d.ts +2 -2
- package/dist/utils/navigation.js +2 -2
- package/package.json +3 -3
- package/cjs/dist/api/create-checkout/index.d.ts +0 -40
- package/cjs/dist/api/create-checkout/index.js +0 -42
- package/cjs/dist/api/create-order/index.d.ts +0 -20
- package/cjs/dist/api/create-order/index.js +0 -24
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.d.ts +0 -28
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +0 -65
- package/dist/api/create-checkout/index.d.ts +0 -40
- package/dist/api/create-checkout/index.js +0 -37
- package/dist/api/create-order/index.d.ts +0 -20
- package/dist/api/create-order/index.js +0 -21
- package/dist/services/booking/book-action/buildCheckoutRequest.d.ts +0 -28
- package/dist/services/booking/book-action/buildCheckoutRequest.js +0 -62
|
@@ -1,35 +1,13 @@
|
|
|
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 { createBooking } from '../../../api/create-booking/index.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
2
|
+
import { createCart } from '../../../api/create-cart/index.js';
|
|
3
|
+
import { calculateCart } from '../../../api/calculate-cart/index.js';
|
|
4
|
+
import { placeOrder } from '../../../api/place-order/index.js';
|
|
13
5
|
import { buildBookingRequest } from './buildBookingRequest.js';
|
|
14
|
-
import {
|
|
6
|
+
import { buildCartRequest } from './buildCartRequest.js';
|
|
15
7
|
import { canBook } from './canBook.js';
|
|
16
8
|
import { isCheckoutRequired } from './isCheckoutRequired.js';
|
|
17
9
|
import { BookResultType, } from './types.js';
|
|
18
|
-
/**
|
|
19
|
-
* Executes the complete booking flow:
|
|
20
|
-
* 1. Validates that all required data is present
|
|
21
|
-
* 2. Creates a booking with the selected service, time slot, and form data
|
|
22
|
-
* 3. Creates a checkout session for payment (includes contact details from booking)
|
|
23
|
-
* 4. Determines if checkout page is required or can be skipped
|
|
24
|
-
* 5. If checkout can be skipped (free/offline), creates order directly
|
|
25
|
-
* 6. Returns appropriate result for navigation
|
|
26
|
-
*
|
|
27
|
-
* @param params - The booking action parameters
|
|
28
|
-
* @returns BookResult with either checkoutId or orderId
|
|
29
|
-
* @throws Error if validation fails, or booking/checkout/order creation fails
|
|
30
|
-
*/
|
|
31
10
|
export async function executeBookAction(params) {
|
|
32
|
-
// Step 0: Validate
|
|
33
11
|
if (!canBook({
|
|
34
12
|
serviceSelections: params.serviceSelections,
|
|
35
13
|
formSubmission: params.formSubmission,
|
|
@@ -48,34 +26,37 @@ export async function executeBookAction(params) {
|
|
|
48
26
|
if (!bookingId) {
|
|
49
27
|
throw new Error('Failed to create booking');
|
|
50
28
|
}
|
|
51
|
-
// Step 2: Create
|
|
52
|
-
// businessLocationId: prefer timeSlot.location, fallback to global location
|
|
29
|
+
// Step 2: Create cart
|
|
53
30
|
const firstSelection = params.serviceSelections[0];
|
|
54
31
|
if (!firstSelection) {
|
|
55
32
|
throw new Error('No service selection found');
|
|
56
33
|
}
|
|
57
34
|
const businessLocationId = firstSelection.timeSlot?.location?._id ?? undefined;
|
|
58
|
-
const
|
|
35
|
+
const cartRequest = buildCartRequest({
|
|
59
36
|
bookingId,
|
|
60
37
|
contactDetails,
|
|
61
38
|
businessLocationId,
|
|
62
39
|
appId: params.appId,
|
|
63
40
|
});
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
throw new Error('Failed to create checkout');
|
|
41
|
+
const cart = await createCart(cartRequest);
|
|
42
|
+
if (!cart._id) {
|
|
43
|
+
throw new Error('Failed to create cart');
|
|
68
44
|
}
|
|
69
|
-
// Step 3:
|
|
45
|
+
// Step 3: Calculate cart to get totals (not stored on Cart V2 entity)
|
|
46
|
+
const { cart: calculatedCart, summary } = await calculateCart(cart._id);
|
|
47
|
+
if (!calculatedCart || !summary) {
|
|
48
|
+
throw new Error('Failed to calculate cart');
|
|
49
|
+
}
|
|
50
|
+
// Step 4: Determine if checkout is required or can be skipped
|
|
70
51
|
const service = firstSelection.service;
|
|
71
|
-
if (isCheckoutRequired(
|
|
72
|
-
return { type: BookResultType.CheckoutRequired,
|
|
52
|
+
if (isCheckoutRequired(calculatedCart, summary, service)) {
|
|
53
|
+
return { type: BookResultType.CheckoutRequired, cartId: cart._id };
|
|
73
54
|
}
|
|
74
|
-
// Step
|
|
75
|
-
const orderResponse = await
|
|
55
|
+
// Step 5: Skip checkout — place order directly
|
|
56
|
+
const orderResponse = await placeOrder(cart._id);
|
|
76
57
|
const orderId = orderResponse.orderId;
|
|
77
58
|
if (!orderId) {
|
|
78
|
-
throw new Error('Failed to
|
|
59
|
+
throw new Error('Failed to place order');
|
|
79
60
|
}
|
|
80
61
|
return { type: BookResultType.CheckoutSkipped, orderId };
|
|
81
62
|
}
|
|
@@ -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,34 @@
|
|
|
1
|
+
import { ChannelType, } from '../../../api/create-cart/index.js';
|
|
2
|
+
import { BOOKING_APP_ID } from '../../constants.js';
|
|
3
|
+
export function buildCartRequest(params) {
|
|
4
|
+
const { bookingId, contactDetails, businessLocationId, appId } = params;
|
|
5
|
+
const cart = {
|
|
6
|
+
source: { channelType: ChannelType.WEB },
|
|
7
|
+
};
|
|
8
|
+
if (businessLocationId) {
|
|
9
|
+
cart.businessInfo = { locationId: businessLocationId };
|
|
10
|
+
}
|
|
11
|
+
if (contactDetails) {
|
|
12
|
+
cart.customerInfo = {
|
|
13
|
+
...(contactDetails.email ? { email: contactDetails.email } : {}),
|
|
14
|
+
};
|
|
15
|
+
if (contactDetails.fullAddress?.country) {
|
|
16
|
+
cart.deliveryInfo = { address: { ...contactDetails.fullAddress } };
|
|
17
|
+
cart.paymentInfo = {
|
|
18
|
+
billingAddress: { ...contactDetails.fullAddress },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
catalogItems: [
|
|
24
|
+
{
|
|
25
|
+
quantity: 1,
|
|
26
|
+
catalogReference: {
|
|
27
|
+
catalogItemId: bookingId,
|
|
28
|
+
appId: appId ?? BOOKING_APP_ID,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
cart,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -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 {
|
|
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';
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
export { executeBookAction } from './bookAction.js';
|
|
5
5
|
export { canBook } from './canBook.js';
|
|
6
6
|
export { buildBookingRequest } from './buildBookingRequest.js';
|
|
7
|
-
export {
|
|
7
|
+
export { buildCartRequest } from './buildCartRequest.js';
|
|
8
8
|
export { isCheckoutRequired } from './isCheckoutRequired.js';
|
|
9
9
|
export { BookResultType, } from './types.js';
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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,32 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ 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,
|
|
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
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';
|
package/dist/services/index.js
CHANGED
|
@@ -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,
|
|
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';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface NavigationInfo {
|
|
2
2
|
postFlowUrl: string;
|
|
3
3
|
}
|
|
4
|
-
export declare function navigateToCheckout({
|
|
5
|
-
|
|
4
|
+
export declare function navigateToCheckout({ cartId, navigationInfo, }: {
|
|
5
|
+
cartId: string;
|
|
6
6
|
navigationInfo: NavigationInfo;
|
|
7
7
|
}): Promise<void>;
|
package/dist/utils/navigation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { redirects } from '@wix/redirects';
|
|
2
|
-
export async function navigateToCheckout({
|
|
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
|
|
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/
|
|
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": "
|
|
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
|
-
}
|