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