@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,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
|
-
}
|