@cimplify/sdk 0.7.13 → 0.8.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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { aa as AUTHORIZATION_TYPE, af as AUTH_MUTATION, $ as AbortablePromise, cc as AddressData, cE as AddressInfo, aP as AmountToPay, cn as AuthResponse, A as AuthService, m as AuthStatus, cG as AuthenticatedCustomer, cI as AuthenticatedData, c0 as AvailabilityCheck, c1 as AvailabilityResult, bF as AvailableSlot, bI as Booking, bH as BookingStatus, bJ as BookingWithDetails, b7 as BufferTimes, bm as Business, bA as BusinessHours, bl as BusinessPreferences, B as BusinessService, bz as BusinessSettings, bk as BusinessType, bx as BusinessWithLocations, a3 as CHECKOUT_MODE, ag as CHECKOUT_MUTATION, a6 as CHECKOUT_STEP, ac as CONTACT_TYPE, bQ as CancelBookingInput, bR as CancelBookingResult, b1 as CancelOrderInput, b9 as CancellationPolicy, i as CartOperations, b as CatalogueQueries, aC as CatalogueResult, aD as CatalogueSnapshot, bB as CategoryInfo, bN as CheckSlotAvailabilityInput, bO as CheckSlotAvailabilityResult, cq as CheckoutAddressInfo, cs as CheckoutCustomerInfo, N as CheckoutFormData, a$ as CheckoutInput, D as CheckoutMode, j as CheckoutOperations, H as CheckoutOrderType, J as CheckoutPaymentMethod, V as CheckoutResult, j as CheckoutService, Z as CheckoutStatus, _ as CheckoutStatusContext, K as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, t as CimplifyElement, s as CimplifyElements, a2 as ContactType, c8 as CreateAddressInput, ca as CreateMobileMoneyInput, c3 as Customer, c4 as CustomerAddress, bL as CustomerBooking, bK as CustomerBookingServiceItem, c6 as CustomerLinkPreferences, c5 as CustomerMobileMoney, b6 as CustomerServicePreferences, ak as DEFAULT_COUNTRY, aj as DEFAULT_CURRENCY, ab as DEVICE_TYPE, bG as DayAvailability, bg as DepositResult, a1 as DeviceType, v as ELEMENT_TYPES, E as EVENT_TYPES, cD as ElementAppearance, cN as ElementEventHandler, z as ElementEventType, x as ElementOptions, y as ElementType, cJ as ElementsCheckoutData, cK as ElementsCheckoutResult, cH as ElementsCustomerInfo, w as ElementsOptions, ce as EnrollAndLinkOrderInput, ch as EnrollAndLinkOrderResult, cb as EnrollmentData, an as Err, aO as FeeBearerType, F as FetchQuoteInput, aM as FulfillmentLink, aL as FulfillmentStatus, aK as FulfillmentType, cu as FxQuote, ct as FxQuoteRequest, cv as FxRateResponse, q as FxService, bM as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, cM as IframeToParentMessage, I as InventoryService, c2 as InventorySummary, ae as LINK_MUTATION, ad as LINK_QUERY, aQ as LineItem, aH as LineType, c7 as LinkData, cg as LinkEnrollResult, L as LinkService, ci as LinkSession, cf as LinkStatusResult, r as LiteBootstrap, p as LiteService, bp as Location, bj as LocationAppointment, b$ as LocationStock, bn as LocationTaxBehavior, bo as LocationTaxOverrides, bs as LocationTimeProfile, by as LocationWithDetails, M as MESSAGE_TYPES, a9 as MOBILE_MONEY_PROVIDER, cd as MobileMoneyData, cr as MobileMoneyDetails, a0 as MobileMoneyProvider, ai as ORDER_MUTATION, a4 as ORDER_TYPE, cC as ObservabilityHooks, am as Ok, aR as Order, aG as OrderChannel, a_ as OrderFilter, aN as OrderFulfillmentSummary, aU as OrderGroup, aY as OrderGroupDetails, aV as OrderGroupPayment, aT as OrderGroupPaymentState, aX as OrderGroupPaymentSummary, aS as OrderHistory, aI as OrderLineState, aJ as OrderLineStatus, aZ as OrderPaymentEvent, O as OrderQueries, aW as OrderSplitDetail, aE as OrderStatus, n as OtpResult, a5 as PAYMENT_METHOD, ah as PAYMENT_MUTATION, a7 as PAYMENT_STATE, a8 as PICKUP_TIME_TYPE, cL as ParentToIframeMessage, cF as PaymentMethodInfo, aF as PaymentState, cp as PickupTime, co as PickupTimeType, P as PriceQuote, bb as PricingOverrides, Y as ProcessAndResolveOptions, W as ProcessCheckoutOptions, X as ProcessCheckoutResult, bZ as ProductStock, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, b2 as RefundOrderInput, b5 as ReminderMethod, b8 as ReminderSettings, cw as RequestContext, cz as RequestErrorEvent, cl as RequestOtpInput, cx as RequestStartEvent, cy as RequestSuccessEvent, bP as RescheduleBookingInput, bS as RescheduleBookingResult, be as ResourceAssignment, al as Result, cA as RetryEvent, ck as RevokeAllSessionsResult, cj as RevokeSessionResult, bu as Room, bc as SchedulingMetadata, bf as SchedulingResult, o as SchedulingService, S as SearchOptions, bC as Service, bT as ServiceAvailabilityParams, bU as ServiceAvailabilityResult, bv as ServiceCharge, ba as ServiceNotes, bh as ServiceScheduleRequest, b3 as ServiceStatus, cB as SessionChangeEvent, bD as Staff, bd as StaffAssignment, b4 as StaffRole, bi as StaffScheduleItem, bX as Stock, bY as StockLevel, bV as StockOwnershipType, bW as StockStatus, bw as StorefrontBootstrap, bt as Table, T as TableInfo, bq as TimeRange, br as TimeRanges, bE as TimeSlot, c9 as UpdateAddressInput, b0 as UpdateOrderStatusInput, U as UpdateProfileInput, b_ as VariantStock, cm as VerifyOtpInput, aA as combine, aB as combineObject, c as createCimplifyClient, u as createElements, ap as err, au as flatMap, ay as fromPromise, k as generateIdempotencyKey, av as getOrElse, ar as isErr, aq as isOk, at as mapError, as as mapResult, ao as ok, ax as toNullable, az as tryCatch, aw as unwrap } from './client-Dkinq9Oz.js';
1
+ export { aa as AUTHORIZATION_TYPE, af as AUTH_MUTATION, $ as AbortablePromise, cc as AddressData, cF as AddressInfo, aP as AmountToPay, cn as AuthResponse, A as AuthService, m as AuthStatus, cH as AuthenticatedCustomer, cJ as AuthenticatedData, c0 as AvailabilityCheck, c1 as AvailabilityResult, bF as AvailableSlot, bI as Booking, bH as BookingStatus, bJ as BookingWithDetails, b7 as BufferTimes, bm as Business, bA as BusinessHours, bl as BusinessPreferences, B as BusinessService, bz as BusinessSettings, bk as BusinessType, bx as BusinessWithLocations, a3 as CHECKOUT_MODE, ag as CHECKOUT_MUTATION, a6 as CHECKOUT_STEP, ac as CONTACT_TYPE, bQ as CancelBookingInput, bR as CancelBookingResult, b1 as CancelOrderInput, b9 as CancellationPolicy, i as CartOperations, b as CatalogueQueries, aC as CatalogueResult, aD as CatalogueSnapshot, bB as CategoryInfo, bN as CheckSlotAvailabilityInput, bO as CheckSlotAvailabilityResult, cq as CheckoutAddressInfo, cs as CheckoutCustomerInfo, N as CheckoutFormData, a$ as CheckoutInput, D as CheckoutMode, j as CheckoutOperations, H as CheckoutOrderType, J as CheckoutPaymentMethod, V as CheckoutResult, j as CheckoutService, Z as CheckoutStatus, _ as CheckoutStatusContext, K as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, t as CimplifyElement, s as CimplifyElements, a2 as ContactType, c8 as CreateAddressInput, ca as CreateMobileMoneyInput, c3 as Customer, c4 as CustomerAddress, bL as CustomerBooking, bK as CustomerBookingServiceItem, c6 as CustomerLinkPreferences, c5 as CustomerMobileMoney, b6 as CustomerServicePreferences, ak as DEFAULT_COUNTRY, aj as DEFAULT_CURRENCY, ab as DEVICE_TYPE, bG as DayAvailability, bg as DepositResult, a1 as DeviceType, v as ELEMENT_TYPES, E as EVENT_TYPES, cE as ElementAppearance, cO as ElementEventHandler, z as ElementEventType, x as ElementOptions, y as ElementType, cK as ElementsCheckoutData, cL as ElementsCheckoutResult, cI as ElementsCustomerInfo, w as ElementsOptions, ce as EnrollAndLinkOrderInput, ch as EnrollAndLinkOrderResult, cb as EnrollmentData, an as Err, aO as FeeBearerType, F as FetchQuoteInput, aM as FulfillmentLink, aL as FulfillmentStatus, aK as FulfillmentType, cu as FxQuote, ct as FxQuoteRequest, cv as FxRateResponse, q as FxService, bM as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, cN as IframeToParentMessage, I as InventoryService, c2 as InventorySummary, ae as LINK_MUTATION, ad as LINK_QUERY, aQ as LineItem, aH as LineType, c7 as LinkData, cg as LinkEnrollResult, L as LinkService, ci as LinkSession, cf as LinkStatusResult, r as LiteBootstrap, p as LiteService, bp as Location, bj as LocationAppointment, b$ as LocationStock, bn as LocationTaxBehavior, bo as LocationTaxOverrides, bs as LocationTimeProfile, by as LocationWithDetails, M as MESSAGE_TYPES, a9 as MOBILE_MONEY_PROVIDER, cd as MobileMoneyData, cr as MobileMoneyDetails, a0 as MobileMoneyProvider, ai as ORDER_MUTATION, a4 as ORDER_TYPE, cC as ObservabilityHooks, am as Ok, aR as Order, aG as OrderChannel, a_ as OrderFilter, aN as OrderFulfillmentSummary, aU as OrderGroup, aY as OrderGroupDetails, aV as OrderGroupPayment, aT as OrderGroupPaymentState, aX as OrderGroupPaymentSummary, aS as OrderHistory, aI as OrderLineState, aJ as OrderLineStatus, aZ as OrderPaymentEvent, O as OrderQueries, aW as OrderSplitDetail, aE as OrderStatus, cD as OrderType, n as OtpResult, a5 as PAYMENT_METHOD, ah as PAYMENT_MUTATION, a7 as PAYMENT_STATE, a8 as PICKUP_TIME_TYPE, cM as ParentToIframeMessage, cG as PaymentMethodInfo, aF as PaymentState, cp as PickupTime, co as PickupTimeType, P as PriceQuote, bb as PricingOverrides, Y as ProcessAndResolveOptions, W as ProcessCheckoutOptions, X as ProcessCheckoutResult, bZ as ProductStock, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, b2 as RefundOrderInput, b5 as ReminderMethod, b8 as ReminderSettings, cw as RequestContext, cz as RequestErrorEvent, cl as RequestOtpInput, cx as RequestStartEvent, cy as RequestSuccessEvent, bP as RescheduleBookingInput, bS as RescheduleBookingResult, be as ResourceAssignment, al as Result, cA as RetryEvent, ck as RevokeAllSessionsResult, cj as RevokeSessionResult, bu as Room, bc as SchedulingMetadata, bf as SchedulingResult, o as SchedulingService, S as SearchOptions, bC as Service, bT as ServiceAvailabilityParams, bU as ServiceAvailabilityResult, bv as ServiceCharge, ba as ServiceNotes, bh as ServiceScheduleRequest, b3 as ServiceStatus, cB as SessionChangeEvent, bD as Staff, bd as StaffAssignment, b4 as StaffRole, bi as StaffScheduleItem, bX as Stock, bY as StockLevel, bV as StockOwnershipType, bW as StockStatus, bw as StorefrontBootstrap, bt as Table, T as TableInfo, bq as TimeRange, br as TimeRanges, bE as TimeSlot, c9 as UpdateAddressInput, b0 as UpdateOrderStatusInput, U as UpdateProfileInput, b_ as VariantStock, cm as VerifyOtpInput, aA as combine, aB as combineObject, c as createCimplifyClient, u as createElements, ap as err, au as flatMap, ay as fromPromise, k as generateIdempotencyKey, av as getOrElse, ar as isErr, aq as isOk, at as mapError, as as mapResult, ao as ok, ax as toNullable, az as tryCatch, aw as unwrap } from './client-tMD3aBuM.js';
2
2
  export { QueryBuilder, query } from './advanced.js';
3
3
  import { A as ApiError } from './payment-CLIWNMaP.js';
4
4
  export { B as AddOn, at as AddOnDetails, aP as AddOnGroupDetails, G as AddOnOption, aO as AddOnOptionDetails, H as AddOnOptionPrice, F as AddOnWithOptions, aU as AddToCartInput, ai as AdjustmentType, ap as AppliedDiscount, a_ as AuthorizationType, ao as BenefitType, T as Bundle, Y as BundleComponentData, _ as BundleComponentInfo, R as BundlePriceType, W as BundleProduct, ay as BundleSelectionData, aw as BundleSelectionInput, ax as BundleStoredSelection, U as BundleSummary, X as BundleWithDetails, aD as Cart, au as CartAddOn, ag as CartChannel, aE as CartItem, aR as CartItemDetails, af as CartStatus, aW as CartSummary, aF as CartTotals, K as Category, L as CategorySummary, an as ChosenPrice, h as CimplifyError, N as Collection, Q as CollectionProduct, O as CollectionSummary, a4 as ComponentGroup, a5 as ComponentGroupWithComponents, a9 as ComponentPriceBreakdown, a7 as ComponentSelectionInput, a1 as ComponentSourceType, a2 as Composite, a6 as CompositeComponent, aA as CompositePriceBreakdown, a8 as CompositePriceResult, $ as CompositePricingMode, aB as CompositeSelectionData, a7 as CompositeSelectionInput, az as CompositeStoredSelection, a3 as CompositeWithDetails, b as Currency, C as CurrencyCode, p as DepositType, D as DigitalProductType, aq as DiscountBreakdown, ar as DiscountDetails, aI as DisplayAddOn, aJ as DisplayAddOnOption, aG as DisplayCart, aH as DisplayCartItem, g as ERROR_HINTS, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, a0 as GroupPricingBehavior, b2 as InitializePaymentResult, I as InventoryType, aC as LineConfiguration, ac as LocationProductPrice, M as Money, d as Pagination, P as PaginationParams, b1 as Payment, b5 as PaymentErrorDetails, b0 as PaymentMethod, aZ as PaymentMethodType, a$ as PaymentProcessingState, aY as PaymentProvider, b3 as PaymentResponse, aX as PaymentStatus, b4 as PaymentStatusResponse, ab as Price, aj as PriceAdjustment, am as PriceDecisionPath, aa as PriceEntryType, al as PricePathTaxInfo, ah as PriceSource, q as Product, J as ProductAddOn, ad as ProductAvailability, o as ProductRenderHint, ae as ProductTimeProfile, n as ProductType, s as ProductVariant, x as ProductVariantValue, r as ProductWithDetails, S as SalesChannel, as as SelectedAddOnOption, b6 as SubmitAuthorizationInput, ak as TaxPathComponent, aS as UICart, aK as UICartBusiness, aM as UICartCustomer, aL as UICartLocation, aN as UICartPricing, aT as UICartResponse, aV as UpdateCartItemInput, u as VariantAxis, z as VariantAxisSelection, w as VariantAxisValue, v as VariantAxisWithValues, av as VariantDetails, aQ as VariantDetailsDTO, t as VariantDisplayAttribute, y as VariantLocationAvailability, V as VariantStrategy, Z as ZERO, c as currencyCode, k as enrichError, j as getErrorHint, i as isCimplifyError, l as isRetryableError, m as money, a as moneyFromNumber } from './payment-CLIWNMaP.js';
package/dist/index.js CHANGED
@@ -2584,7 +2584,8 @@ var FxService = class {
2584
2584
  var ELEMENT_TYPES = {
2585
2585
  AUTH: "auth",
2586
2586
  ADDRESS: "address",
2587
- PAYMENT: "payment"
2587
+ PAYMENT: "payment",
2588
+ CHECKOUT: "checkout"
2588
2589
  };
2589
2590
  var MESSAGE_TYPES = {
2590
2591
  // Parent → Iframe
@@ -2608,7 +2609,8 @@ var MESSAGE_TYPES = {
2608
2609
  LOGOUT_COMPLETE: "logout_complete",
2609
2610
  CONTACT_PROVIDED: "contact_provided",
2610
2611
  CHECKOUT_STATUS: "checkout_status",
2611
- CHECKOUT_COMPLETE: "checkout_complete"
2612
+ CHECKOUT_COMPLETE: "checkout_complete",
2613
+ ORDER_TYPE_CHANGED: "order_type_changed"
2612
2614
  };
2613
2615
  var EVENT_TYPES = {
2614
2616
  READY: "ready",
@@ -2617,7 +2619,8 @@ var EVENT_TYPES = {
2617
2619
  ERROR: "error",
2618
2620
  CHANGE: "change",
2619
2621
  BLUR: "blur",
2620
- FOCUS: "focus"
2622
+ FOCUS: "focus",
2623
+ ORDER_TYPE_CHANGED: "order_type_changed"
2621
2624
  };
2622
2625
 
2623
2626
  // src/elements.ts
@@ -2766,40 +2769,43 @@ var CimplifyElements = class {
2766
2769
  false
2767
2770
  );
2768
2771
  }
2769
- const paymentElement = this.elements.get(ELEMENT_TYPES.PAYMENT);
2770
- if (!paymentElement) {
2771
- console.debug("[cimplify:checkout] BLOCKED: no payment element");
2772
+ const checkoutElement = this.elements.get(ELEMENT_TYPES.CHECKOUT) || this.elements.get(ELEMENT_TYPES.PAYMENT);
2773
+ if (!checkoutElement) {
2774
+ console.debug("[cimplify:checkout] BLOCKED: no checkout element");
2772
2775
  return toCheckoutError(
2773
2776
  "NO_PAYMENT_ELEMENT",
2774
- "Payment element must be mounted before checkout.",
2777
+ "Checkout element must be mounted before checkout.",
2775
2778
  false
2776
2779
  );
2777
2780
  }
2778
- if (!paymentElement.isMounted()) {
2779
- console.debug("[cimplify:checkout] BLOCKED: payment element not mounted");
2781
+ if (!checkoutElement.isMounted()) {
2782
+ console.debug("[cimplify:checkout] BLOCKED: checkout element not mounted");
2780
2783
  return toCheckoutError(
2781
2784
  "PAYMENT_NOT_MOUNTED",
2782
- "Payment element must be mounted before checkout.",
2785
+ "Checkout element must be mounted before checkout.",
2783
2786
  false
2784
2787
  );
2785
2788
  }
2786
- const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
2787
- if (authElement && !this.accessToken) {
2788
- console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
2789
- return toCheckoutError(
2790
- "AUTH_INCOMPLETE",
2791
- "Authentication must complete before checkout can start.",
2792
- true
2793
- );
2794
- }
2795
- const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
2796
- if (addressElement) {
2797
- console.debug("[cimplify:checkout] getting address data...");
2798
- await addressElement.getData();
2799
- console.debug("[cimplify:checkout] address data resolved", this.addressData);
2789
+ const isUnifiedCheckout = this.elements.has(ELEMENT_TYPES.CHECKOUT);
2790
+ if (!isUnifiedCheckout) {
2791
+ const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
2792
+ if (authElement && !this.accessToken) {
2793
+ console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
2794
+ return toCheckoutError(
2795
+ "AUTH_INCOMPLETE",
2796
+ "Authentication must complete before checkout can start.",
2797
+ true
2798
+ );
2799
+ }
2800
+ const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
2801
+ if (addressElement) {
2802
+ console.debug("[cimplify:checkout] getting address data...");
2803
+ await addressElement.getData();
2804
+ console.debug("[cimplify:checkout] address data resolved", this.addressData);
2805
+ }
2806
+ await this.hydrateCustomerData();
2800
2807
  }
2801
- await this.hydrateCustomerData();
2802
- console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
2808
+ console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId, isUnifiedCheckout });
2803
2809
  const processMessage = {
2804
2810
  type: MESSAGE_TYPES.PROCESS_CHECKOUT,
2805
2811
  cart_id: options.cart_id,
@@ -2810,8 +2816,9 @@ var CimplifyElements = class {
2810
2816
  tip_amount: options.tip_amount,
2811
2817
  pay_currency: options.pay_currency,
2812
2818
  enroll_in_link: options.enroll_in_link ?? true,
2813
- address: this.addressData ?? void 0,
2814
- customer: this.customerData ? {
2819
+ // Unified checkout has its own address/customer state; only pass if available externally
2820
+ address: isUnifiedCheckout ? void 0 : this.addressData ?? void 0,
2821
+ customer: isUnifiedCheckout ? void 0 : this.customerData ? {
2815
2822
  name: this.customerData.name,
2816
2823
  email: this.customerData.email,
2817
2824
  phone: this.customerData.phone
@@ -2820,7 +2827,7 @@ var CimplifyElements = class {
2820
2827
  customer_id: this.customerId ?? void 0
2821
2828
  };
2822
2829
  const timeoutMs = options.timeout_ms ?? 18e4;
2823
- const paymentWindow = paymentElement.getContentWindow();
2830
+ const paymentWindow = checkoutElement.getContentWindow();
2824
2831
  this.checkoutInProgress = true;
2825
2832
  return new Promise((resolve) => {
2826
2833
  let settled = false;
@@ -2858,7 +2865,7 @@ var CimplifyElements = class {
2858
2865
  return;
2859
2866
  }
2860
2867
  if (message.type === MESSAGE_TYPES.LOGOUT_COMPLETE) {
2861
- paymentElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
2868
+ checkoutElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
2862
2869
  settle(
2863
2870
  toCheckoutError(
2864
2871
  "AUTH_LOST",
@@ -2889,7 +2896,7 @@ var CimplifyElements = class {
2889
2896
  window.addEventListener("message", handleCheckoutMessage);
2890
2897
  }
2891
2898
  abortFn = () => {
2892
- paymentElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
2899
+ checkoutElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
2893
2900
  settle(
2894
2901
  toCheckoutError(
2895
2902
  "CANCELLED",
@@ -2899,8 +2906,8 @@ var CimplifyElements = class {
2899
2906
  );
2900
2907
  };
2901
2908
  this.activeCheckoutAbort = abortFn;
2902
- console.debug("[cimplify:checkout] sending process_checkout to payment iframe", { cart_id: processMessage.cart_id, order_type: processMessage.order_type, hasCustomer: !!processMessage.customer, hasAddress: !!processMessage.address });
2903
- paymentElement.sendMessage(processMessage);
2909
+ console.debug("[cimplify:checkout] sending process_checkout to checkout iframe", { cart_id: processMessage.cart_id, order_type: processMessage.order_type, hasCustomer: !!processMessage.customer, hasAddress: !!processMessage.address, isUnifiedCheckout });
2910
+ checkoutElement.sendMessage(processMessage);
2904
2911
  console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
2905
2912
  });
2906
2913
  })();
@@ -2979,7 +2986,7 @@ var CimplifyElements = class {
2979
2986
  this.customerData = customer;
2980
2987
  this.client.setAccessToken(message.token);
2981
2988
  this.elements.forEach((element, type) => {
2982
- if (type !== ELEMENT_TYPES.AUTH) {
2989
+ if (type !== ELEMENT_TYPES.AUTH && type !== ELEMENT_TYPES.CHECKOUT) {
2983
2990
  element.sendMessage({ type: MESSAGE_TYPES.SET_TOKEN, token: message.token });
2984
2991
  }
2985
2992
  });
@@ -3169,7 +3176,9 @@ var CimplifyElement = class {
3169
3176
  publicKey,
3170
3177
  demoMode: publicKey.length === 0,
3171
3178
  prefillEmail: this.options.prefillEmail,
3172
- appearance: this.parent.getAppearance()
3179
+ appearance: this.parent.getAppearance(),
3180
+ orderTypes: this.options.orderTypes,
3181
+ defaultOrderType: this.options.defaultOrderType
3173
3182
  });
3174
3183
  const token = this.parent.getAccessToken();
3175
3184
  if (token && this.type !== ELEMENT_TYPES.AUTH) {
@@ -3233,6 +3242,9 @@ var CimplifyElement = class {
3233
3242
  case MESSAGE_TYPES.CONTACT_PROVIDED:
3234
3243
  this.parent._setGuestContact(message.contact, message.contactType);
3235
3244
  break;
3245
+ case MESSAGE_TYPES.ORDER_TYPE_CHANGED:
3246
+ this.emit(EVENT_TYPES.ORDER_TYPE_CHANGED, { orderType: message.orderType });
3247
+ break;
3236
3248
  }
3237
3249
  }
3238
3250
  emit(event, data) {
package/dist/index.mjs CHANGED
@@ -2582,7 +2582,8 @@ var FxService = class {
2582
2582
  var ELEMENT_TYPES = {
2583
2583
  AUTH: "auth",
2584
2584
  ADDRESS: "address",
2585
- PAYMENT: "payment"
2585
+ PAYMENT: "payment",
2586
+ CHECKOUT: "checkout"
2586
2587
  };
2587
2588
  var MESSAGE_TYPES = {
2588
2589
  // Parent → Iframe
@@ -2606,7 +2607,8 @@ var MESSAGE_TYPES = {
2606
2607
  LOGOUT_COMPLETE: "logout_complete",
2607
2608
  CONTACT_PROVIDED: "contact_provided",
2608
2609
  CHECKOUT_STATUS: "checkout_status",
2609
- CHECKOUT_COMPLETE: "checkout_complete"
2610
+ CHECKOUT_COMPLETE: "checkout_complete",
2611
+ ORDER_TYPE_CHANGED: "order_type_changed"
2610
2612
  };
2611
2613
  var EVENT_TYPES = {
2612
2614
  READY: "ready",
@@ -2615,7 +2617,8 @@ var EVENT_TYPES = {
2615
2617
  ERROR: "error",
2616
2618
  CHANGE: "change",
2617
2619
  BLUR: "blur",
2618
- FOCUS: "focus"
2620
+ FOCUS: "focus",
2621
+ ORDER_TYPE_CHANGED: "order_type_changed"
2619
2622
  };
2620
2623
 
2621
2624
  // src/elements.ts
@@ -2764,40 +2767,43 @@ var CimplifyElements = class {
2764
2767
  false
2765
2768
  );
2766
2769
  }
2767
- const paymentElement = this.elements.get(ELEMENT_TYPES.PAYMENT);
2768
- if (!paymentElement) {
2769
- console.debug("[cimplify:checkout] BLOCKED: no payment element");
2770
+ const checkoutElement = this.elements.get(ELEMENT_TYPES.CHECKOUT) || this.elements.get(ELEMENT_TYPES.PAYMENT);
2771
+ if (!checkoutElement) {
2772
+ console.debug("[cimplify:checkout] BLOCKED: no checkout element");
2770
2773
  return toCheckoutError(
2771
2774
  "NO_PAYMENT_ELEMENT",
2772
- "Payment element must be mounted before checkout.",
2775
+ "Checkout element must be mounted before checkout.",
2773
2776
  false
2774
2777
  );
2775
2778
  }
2776
- if (!paymentElement.isMounted()) {
2777
- console.debug("[cimplify:checkout] BLOCKED: payment element not mounted");
2779
+ if (!checkoutElement.isMounted()) {
2780
+ console.debug("[cimplify:checkout] BLOCKED: checkout element not mounted");
2778
2781
  return toCheckoutError(
2779
2782
  "PAYMENT_NOT_MOUNTED",
2780
- "Payment element must be mounted before checkout.",
2783
+ "Checkout element must be mounted before checkout.",
2781
2784
  false
2782
2785
  );
2783
2786
  }
2784
- const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
2785
- if (authElement && !this.accessToken) {
2786
- console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
2787
- return toCheckoutError(
2788
- "AUTH_INCOMPLETE",
2789
- "Authentication must complete before checkout can start.",
2790
- true
2791
- );
2792
- }
2793
- const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
2794
- if (addressElement) {
2795
- console.debug("[cimplify:checkout] getting address data...");
2796
- await addressElement.getData();
2797
- console.debug("[cimplify:checkout] address data resolved", this.addressData);
2787
+ const isUnifiedCheckout = this.elements.has(ELEMENT_TYPES.CHECKOUT);
2788
+ if (!isUnifiedCheckout) {
2789
+ const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
2790
+ if (authElement && !this.accessToken) {
2791
+ console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
2792
+ return toCheckoutError(
2793
+ "AUTH_INCOMPLETE",
2794
+ "Authentication must complete before checkout can start.",
2795
+ true
2796
+ );
2797
+ }
2798
+ const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
2799
+ if (addressElement) {
2800
+ console.debug("[cimplify:checkout] getting address data...");
2801
+ await addressElement.getData();
2802
+ console.debug("[cimplify:checkout] address data resolved", this.addressData);
2803
+ }
2804
+ await this.hydrateCustomerData();
2798
2805
  }
2799
- await this.hydrateCustomerData();
2800
- console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
2806
+ console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId, isUnifiedCheckout });
2801
2807
  const processMessage = {
2802
2808
  type: MESSAGE_TYPES.PROCESS_CHECKOUT,
2803
2809
  cart_id: options.cart_id,
@@ -2808,8 +2814,9 @@ var CimplifyElements = class {
2808
2814
  tip_amount: options.tip_amount,
2809
2815
  pay_currency: options.pay_currency,
2810
2816
  enroll_in_link: options.enroll_in_link ?? true,
2811
- address: this.addressData ?? void 0,
2812
- customer: this.customerData ? {
2817
+ // Unified checkout has its own address/customer state; only pass if available externally
2818
+ address: isUnifiedCheckout ? void 0 : this.addressData ?? void 0,
2819
+ customer: isUnifiedCheckout ? void 0 : this.customerData ? {
2813
2820
  name: this.customerData.name,
2814
2821
  email: this.customerData.email,
2815
2822
  phone: this.customerData.phone
@@ -2818,7 +2825,7 @@ var CimplifyElements = class {
2818
2825
  customer_id: this.customerId ?? void 0
2819
2826
  };
2820
2827
  const timeoutMs = options.timeout_ms ?? 18e4;
2821
- const paymentWindow = paymentElement.getContentWindow();
2828
+ const paymentWindow = checkoutElement.getContentWindow();
2822
2829
  this.checkoutInProgress = true;
2823
2830
  return new Promise((resolve) => {
2824
2831
  let settled = false;
@@ -2856,7 +2863,7 @@ var CimplifyElements = class {
2856
2863
  return;
2857
2864
  }
2858
2865
  if (message.type === MESSAGE_TYPES.LOGOUT_COMPLETE) {
2859
- paymentElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
2866
+ checkoutElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
2860
2867
  settle(
2861
2868
  toCheckoutError(
2862
2869
  "AUTH_LOST",
@@ -2887,7 +2894,7 @@ var CimplifyElements = class {
2887
2894
  window.addEventListener("message", handleCheckoutMessage);
2888
2895
  }
2889
2896
  abortFn = () => {
2890
- paymentElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
2897
+ checkoutElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
2891
2898
  settle(
2892
2899
  toCheckoutError(
2893
2900
  "CANCELLED",
@@ -2897,8 +2904,8 @@ var CimplifyElements = class {
2897
2904
  );
2898
2905
  };
2899
2906
  this.activeCheckoutAbort = abortFn;
2900
- console.debug("[cimplify:checkout] sending process_checkout to payment iframe", { cart_id: processMessage.cart_id, order_type: processMessage.order_type, hasCustomer: !!processMessage.customer, hasAddress: !!processMessage.address });
2901
- paymentElement.sendMessage(processMessage);
2907
+ console.debug("[cimplify:checkout] sending process_checkout to checkout iframe", { cart_id: processMessage.cart_id, order_type: processMessage.order_type, hasCustomer: !!processMessage.customer, hasAddress: !!processMessage.address, isUnifiedCheckout });
2908
+ checkoutElement.sendMessage(processMessage);
2902
2909
  console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
2903
2910
  });
2904
2911
  })();
@@ -2977,7 +2984,7 @@ var CimplifyElements = class {
2977
2984
  this.customerData = customer;
2978
2985
  this.client.setAccessToken(message.token);
2979
2986
  this.elements.forEach((element, type) => {
2980
- if (type !== ELEMENT_TYPES.AUTH) {
2987
+ if (type !== ELEMENT_TYPES.AUTH && type !== ELEMENT_TYPES.CHECKOUT) {
2981
2988
  element.sendMessage({ type: MESSAGE_TYPES.SET_TOKEN, token: message.token });
2982
2989
  }
2983
2990
  });
@@ -3167,7 +3174,9 @@ var CimplifyElement = class {
3167
3174
  publicKey,
3168
3175
  demoMode: publicKey.length === 0,
3169
3176
  prefillEmail: this.options.prefillEmail,
3170
- appearance: this.parent.getAppearance()
3177
+ appearance: this.parent.getAppearance(),
3178
+ orderTypes: this.options.orderTypes,
3179
+ defaultOrderType: this.options.defaultOrderType
3171
3180
  });
3172
3181
  const token = this.parent.getAccessToken();
3173
3182
  if (token && this.type !== ELEMENT_TYPES.AUTH) {
@@ -3231,6 +3240,9 @@ var CimplifyElement = class {
3231
3240
  case MESSAGE_TYPES.CONTACT_PROVIDED:
3232
3241
  this.parent._setGuestContact(message.contact, message.contactType);
3233
3242
  break;
3243
+ case MESSAGE_TYPES.ORDER_TYPE_CHANGED:
3244
+ this.emit(EVENT_TYPES.ORDER_TYPE_CHANGED, { orderType: message.orderType });
3245
+ break;
3234
3246
  }
3235
3247
  }
3236
3248
  emit(event, data) {
package/dist/react.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CimplifyClient, X as ProcessCheckoutResult, Z as CheckoutStatus, _ as CheckoutStatusContext, bp as Location, bm as Business, aR as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, s as CimplifyElements, w as ElementsOptions, cI as AuthenticatedData, cE as AddressInfo, cF as PaymentMethodInfo, cK as ElementsCheckoutResult, W as ProcessCheckoutOptions } from './client-CVqmSTNq.mjs';
1
+ import { C as CimplifyClient, X as ProcessCheckoutResult, Z as CheckoutStatus, _ as CheckoutStatusContext, bp as Location, bm as Business, aR as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, s as CimplifyElements, w as ElementsOptions, cJ as AuthenticatedData, cF as AddressInfo, cG as PaymentMethodInfo, cL as ElementsCheckoutResult, W as ProcessCheckoutOptions } from './client-I-utsHva.mjs';
2
2
  import React, { ReactNode } from 'react';
3
3
  import { q as Product, d as Pagination, h as CimplifyError, r as ProductWithDetails, K as Category, aw as BundleSelectionInput, a7 as ComponentSelectionInput, N as Collection, X as BundleWithDetails, a3 as CompositeWithDetails, a8 as CompositePriceResult, C as CurrencyCode } from './payment-CLIWNMaP.mjs';
4
4
  import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-t3FBTU8p.mjs';
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CimplifyClient, X as ProcessCheckoutResult, Z as CheckoutStatus, _ as CheckoutStatusContext, bp as Location, bm as Business, aR as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, s as CimplifyElements, w as ElementsOptions, cI as AuthenticatedData, cE as AddressInfo, cF as PaymentMethodInfo, cK as ElementsCheckoutResult, W as ProcessCheckoutOptions } from './client-Dkinq9Oz.js';
1
+ import { C as CimplifyClient, X as ProcessCheckoutResult, Z as CheckoutStatus, _ as CheckoutStatusContext, bp as Location, bm as Business, aR as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, s as CimplifyElements, w as ElementsOptions, cJ as AuthenticatedData, cF as AddressInfo, cG as PaymentMethodInfo, cL as ElementsCheckoutResult, W as ProcessCheckoutOptions } from './client-tMD3aBuM.js';
2
2
  import React, { ReactNode } from 'react';
3
3
  import { q as Product, d as Pagination, h as CimplifyError, r as ProductWithDetails, K as Category, aw as BundleSelectionInput, a7 as ComponentSelectionInput, N as Collection, X as BundleWithDetails, a3 as CompositeWithDetails, a8 as CompositePriceResult, C as CurrencyCode } from './payment-CLIWNMaP.js';
4
4
  import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-t3FBTU8p.js';