@wix/headless-bookings 0.0.118 → 1.0.1
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/__mocks__/booking/booking-mocks.d.ts +1 -1
- package/cjs/dist/__mocks__/services/services-mocks.d.ts +23 -0
- package/cjs/dist/__mocks__/services/services-mocks.js +65 -1
- 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/api/query-services/index.js +2 -2
- 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/react/core/booking/Booking.d.ts +1 -1
- package/cjs/dist/react/core/booking/Booking.js +14 -5
- package/cjs/dist/react/core/location/Location.d.ts +1 -1
- package/cjs/dist/react/core/location/Location.js +5 -5
- package/cjs/dist/react/core/service/Service.d.ts +10 -1
- package/cjs/dist/react/core/service/Service.js +5 -4
- package/cjs/dist/react/service/Service.d.ts +68 -1
- package/cjs/dist/react/service/Service.js +81 -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/booking/booking.d.ts +1 -1
- package/cjs/dist/services/index.d.ts +1 -1
- package/cjs/dist/services/index.js +2 -2
- package/cjs/dist/services/location-list/location-list.def.d.ts +1 -1
- package/cjs/dist/services/location-list/location-list.def.js +1 -1
- package/cjs/dist/services/location-list/location-list.js +7 -7
- package/cjs/dist/utils/navigation.d.ts +2 -2
- package/cjs/dist/utils/navigation.js +2 -2
- package/dist/__mocks__/booking/booking-mocks.d.ts +1 -1
- package/dist/__mocks__/services/services-mocks.d.ts +23 -0
- package/dist/__mocks__/services/services-mocks.js +64 -0
- 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/api/query-services/index.js +1 -1
- 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/react/core/booking/Booking.d.ts +1 -1
- package/dist/react/core/booking/Booking.js +14 -5
- package/dist/react/core/location/Location.d.ts +1 -1
- package/dist/react/core/location/Location.js +1 -1
- package/dist/react/core/service/Service.d.ts +10 -1
- package/dist/react/core/service/Service.js +5 -4
- package/dist/react/service/Service.d.ts +68 -1
- package/dist/react/service/Service.js +81 -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/booking/booking.d.ts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/location-list/location-list.def.d.ts +1 -1
- package/dist/services/location-list/location-list.def.js +1 -1
- package/dist/services/location-list/location-list.js +1 -1
- package/dist/utils/navigation.d.ts +2 -2
- package/dist/utils/navigation.js +2 -2
- package/package.json +5 -4
- 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
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": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -34,9 +34,10 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@wix/auto_sdk_bookings_bookings": "^1.0.
|
|
37
|
+
"@wix/auto_sdk_bookings_bookings": "^1.0.183",
|
|
38
38
|
"@wix/auto_sdk_bookings_event-time-slots": "^1.0.64",
|
|
39
|
-
"@wix/
|
|
39
|
+
"@wix/auto_sdk_bookings_services": "^1.0.226",
|
|
40
|
+
"@wix/auto_sdk_ecom_cart-v-2": "^1.0.86",
|
|
40
41
|
"@wix/forms": "^1.0.384",
|
|
41
42
|
"@wix/headless-media": "0.0.25",
|
|
42
43
|
"@wix/headless-utils": "0.0.12",
|
|
@@ -73,5 +74,5 @@
|
|
|
73
74
|
"groupId": "com.wixpress.headless-components"
|
|
74
75
|
}
|
|
75
76
|
},
|
|
76
|
-
"falconPackageHash": "
|
|
77
|
+
"falconPackageHash": "c5f3384150eba7e23d903366ac5a1fc164fc30f5172f6fc4bc2d61d8"
|
|
77
78
|
}
|
|
@@ -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;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds the createCheckout request
|
|
3
|
-
*/
|
|
4
|
-
import { ChannelType, } from '../../../api/create-checkout/index.js';
|
|
5
|
-
import { BOOKING_APP_ID } from '../../constants.js';
|
|
6
|
-
/**
|
|
7
|
-
* Builds a checkout request from the booking ID and contact details
|
|
8
|
-
*
|
|
9
|
-
* Contact details come from the booking response and are used to populate:
|
|
10
|
-
* - billingInfo.contactDetails (firstName, lastName, phone)
|
|
11
|
-
* - billingInfo.address (from fullAddress if available)
|
|
12
|
-
* - shippingInfo.shippingDestination.contactDetails
|
|
13
|
-
* - buyerInfo (email, contactId)
|
|
14
|
-
*
|
|
15
|
-
* @param params - The checkout parameters
|
|
16
|
-
* @returns CreateCheckoutRequest ready to be sent to the API
|
|
17
|
-
*/
|
|
18
|
-
export function buildCheckoutRequest(params) {
|
|
19
|
-
const { bookingId, contactDetails, businessLocationId, appId } = params;
|
|
20
|
-
// Build checkoutInfo incrementally for readability
|
|
21
|
-
const checkoutInfo = {};
|
|
22
|
-
// businessLocationId for multi-location support
|
|
23
|
-
if (businessLocationId) {
|
|
24
|
-
checkoutInfo.businessLocationId = businessLocationId;
|
|
25
|
-
}
|
|
26
|
-
// Billing info and shipping info from contact details
|
|
27
|
-
if (contactDetails) {
|
|
28
|
-
checkoutInfo.billingInfo = {
|
|
29
|
-
contactDetails,
|
|
30
|
-
...(contactDetails.fullAddress?.country
|
|
31
|
-
? { address: { ...contactDetails.fullAddress } }
|
|
32
|
-
: {}),
|
|
33
|
-
};
|
|
34
|
-
checkoutInfo.shippingInfo = {
|
|
35
|
-
shippingDestination: {
|
|
36
|
-
contactDetails,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
// Buyer info with email and contactId
|
|
41
|
-
if (contactDetails?.email) {
|
|
42
|
-
checkoutInfo.buyerInfo = {
|
|
43
|
-
email: contactDetails.email,
|
|
44
|
-
...(contactDetails.contactId
|
|
45
|
-
? { contactId: contactDetails.contactId }
|
|
46
|
-
: {}),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
channelType: ChannelType.WEB,
|
|
51
|
-
lineItems: [
|
|
52
|
-
{
|
|
53
|
-
quantity: 1,
|
|
54
|
-
catalogReference: {
|
|
55
|
-
catalogItemId: bookingId,
|
|
56
|
-
appId: appId ?? BOOKING_APP_ID,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
checkoutInfo,
|
|
61
|
-
};
|
|
62
|
-
}
|