@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.
- 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/react/core/payment/Payment.d.ts +14 -1
- package/cjs/dist/react/core/payment/Payment.js +12 -0
- package/cjs/dist/react/payment/Payment.d.ts +37 -1
- package/cjs/dist/react/payment/Payment.js +32 -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 +2 -2
- package/cjs/dist/services/index.js +2 -2
- package/cjs/dist/services/payment/payment.d.ts +1 -1
- package/cjs/dist/services/payment/payment.def.d.ts +15 -0
- package/cjs/dist/services/payment/payment.js +51 -3
- 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/react/core/payment/Payment.d.ts +14 -1
- package/dist/react/core/payment/Payment.js +11 -0
- package/dist/react/payment/Payment.d.ts +37 -1
- package/dist/react/payment/Payment.js +31 -0
- 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 +2 -2
- package/dist/services/index.js +1 -1
- package/dist/services/payment/payment.d.ts +1 -1
- package/dist/services/payment/payment.def.d.ts +15 -0
- package/dist/services/payment/payment.js +51 -3
- 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,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
|
-
}
|