@cimplify/sdk 0.7.14 → 0.8.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/dist/advanced.d.mts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +53 -35
- package/dist/advanced.mjs +53 -35
- package/dist/{client-Dkinq9Oz.d.ts → client-BJFeYCB2.d.ts} +19 -3
- package/dist/{client-CVqmSTNq.d.mts → client-bq-xxzM7.d.mts} +19 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +53 -35
- package/dist/index.mjs +53 -35
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +75 -129
- package/dist/react.mjs +75 -129
- package/package.json +1 -1
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,
|
|
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-BJFeYCB2.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,9 @@ 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",
|
|
2614
|
+
REQUEST_SUBMIT: "request_submit"
|
|
2612
2615
|
};
|
|
2613
2616
|
var EVENT_TYPES = {
|
|
2614
2617
|
READY: "ready",
|
|
@@ -2617,7 +2620,9 @@ var EVENT_TYPES = {
|
|
|
2617
2620
|
ERROR: "error",
|
|
2618
2621
|
CHANGE: "change",
|
|
2619
2622
|
BLUR: "blur",
|
|
2620
|
-
FOCUS: "focus"
|
|
2623
|
+
FOCUS: "focus",
|
|
2624
|
+
ORDER_TYPE_CHANGED: "order_type_changed",
|
|
2625
|
+
REQUEST_SUBMIT: "request_submit"
|
|
2621
2626
|
};
|
|
2622
2627
|
|
|
2623
2628
|
// src/elements.ts
|
|
@@ -2766,40 +2771,43 @@ var CimplifyElements = class {
|
|
|
2766
2771
|
false
|
|
2767
2772
|
);
|
|
2768
2773
|
}
|
|
2769
|
-
const
|
|
2770
|
-
if (!
|
|
2771
|
-
console.debug("[cimplify:checkout] BLOCKED: no
|
|
2774
|
+
const checkoutElement = this.elements.get(ELEMENT_TYPES.CHECKOUT) || this.elements.get(ELEMENT_TYPES.PAYMENT);
|
|
2775
|
+
if (!checkoutElement) {
|
|
2776
|
+
console.debug("[cimplify:checkout] BLOCKED: no checkout element");
|
|
2772
2777
|
return toCheckoutError(
|
|
2773
2778
|
"NO_PAYMENT_ELEMENT",
|
|
2774
|
-
"
|
|
2779
|
+
"Checkout element must be mounted before checkout.",
|
|
2775
2780
|
false
|
|
2776
2781
|
);
|
|
2777
2782
|
}
|
|
2778
|
-
if (!
|
|
2779
|
-
console.debug("[cimplify:checkout] BLOCKED:
|
|
2783
|
+
if (!checkoutElement.isMounted()) {
|
|
2784
|
+
console.debug("[cimplify:checkout] BLOCKED: checkout element not mounted");
|
|
2780
2785
|
return toCheckoutError(
|
|
2781
2786
|
"PAYMENT_NOT_MOUNTED",
|
|
2782
|
-
"
|
|
2787
|
+
"Checkout element must be mounted before checkout.",
|
|
2783
2788
|
false
|
|
2784
2789
|
);
|
|
2785
2790
|
}
|
|
2786
|
-
const
|
|
2787
|
-
if (
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
"
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2791
|
+
const isUnifiedCheckout = this.elements.has(ELEMENT_TYPES.CHECKOUT);
|
|
2792
|
+
if (!isUnifiedCheckout) {
|
|
2793
|
+
const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
|
|
2794
|
+
if (authElement && !this.accessToken) {
|
|
2795
|
+
console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
|
|
2796
|
+
return toCheckoutError(
|
|
2797
|
+
"AUTH_INCOMPLETE",
|
|
2798
|
+
"Authentication must complete before checkout can start.",
|
|
2799
|
+
true
|
|
2800
|
+
);
|
|
2801
|
+
}
|
|
2802
|
+
const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
|
|
2803
|
+
if (addressElement) {
|
|
2804
|
+
console.debug("[cimplify:checkout] getting address data...");
|
|
2805
|
+
await addressElement.getData();
|
|
2806
|
+
console.debug("[cimplify:checkout] address data resolved", this.addressData);
|
|
2807
|
+
}
|
|
2808
|
+
await this.hydrateCustomerData();
|
|
2800
2809
|
}
|
|
2801
|
-
|
|
2802
|
-
console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
|
|
2810
|
+
console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId, isUnifiedCheckout });
|
|
2803
2811
|
const processMessage = {
|
|
2804
2812
|
type: MESSAGE_TYPES.PROCESS_CHECKOUT,
|
|
2805
2813
|
cart_id: options.cart_id,
|
|
@@ -2810,8 +2818,9 @@ var CimplifyElements = class {
|
|
|
2810
2818
|
tip_amount: options.tip_amount,
|
|
2811
2819
|
pay_currency: options.pay_currency,
|
|
2812
2820
|
enroll_in_link: options.enroll_in_link ?? true,
|
|
2813
|
-
address
|
|
2814
|
-
|
|
2821
|
+
// Unified checkout has its own address/customer state; only pass if available externally
|
|
2822
|
+
address: isUnifiedCheckout ? void 0 : this.addressData ?? void 0,
|
|
2823
|
+
customer: isUnifiedCheckout ? void 0 : this.customerData ? {
|
|
2815
2824
|
name: this.customerData.name,
|
|
2816
2825
|
email: this.customerData.email,
|
|
2817
2826
|
phone: this.customerData.phone
|
|
@@ -2820,7 +2829,7 @@ var CimplifyElements = class {
|
|
|
2820
2829
|
customer_id: this.customerId ?? void 0
|
|
2821
2830
|
};
|
|
2822
2831
|
const timeoutMs = options.timeout_ms ?? 18e4;
|
|
2823
|
-
const paymentWindow =
|
|
2832
|
+
const paymentWindow = checkoutElement.getContentWindow();
|
|
2824
2833
|
this.checkoutInProgress = true;
|
|
2825
2834
|
return new Promise((resolve) => {
|
|
2826
2835
|
let settled = false;
|
|
@@ -2858,7 +2867,7 @@ var CimplifyElements = class {
|
|
|
2858
2867
|
return;
|
|
2859
2868
|
}
|
|
2860
2869
|
if (message.type === MESSAGE_TYPES.LOGOUT_COMPLETE) {
|
|
2861
|
-
|
|
2870
|
+
checkoutElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
|
|
2862
2871
|
settle(
|
|
2863
2872
|
toCheckoutError(
|
|
2864
2873
|
"AUTH_LOST",
|
|
@@ -2889,7 +2898,7 @@ var CimplifyElements = class {
|
|
|
2889
2898
|
window.addEventListener("message", handleCheckoutMessage);
|
|
2890
2899
|
}
|
|
2891
2900
|
abortFn = () => {
|
|
2892
|
-
|
|
2901
|
+
checkoutElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
|
|
2893
2902
|
settle(
|
|
2894
2903
|
toCheckoutError(
|
|
2895
2904
|
"CANCELLED",
|
|
@@ -2899,8 +2908,8 @@ var CimplifyElements = class {
|
|
|
2899
2908
|
);
|
|
2900
2909
|
};
|
|
2901
2910
|
this.activeCheckoutAbort = abortFn;
|
|
2902
|
-
console.debug("[cimplify:checkout] sending process_checkout to
|
|
2903
|
-
|
|
2911
|
+
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 });
|
|
2912
|
+
checkoutElement.sendMessage(processMessage);
|
|
2904
2913
|
console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
|
|
2905
2914
|
});
|
|
2906
2915
|
})();
|
|
@@ -2979,7 +2988,7 @@ var CimplifyElements = class {
|
|
|
2979
2988
|
this.customerData = customer;
|
|
2980
2989
|
this.client.setAccessToken(message.token);
|
|
2981
2990
|
this.elements.forEach((element, type) => {
|
|
2982
|
-
if (type !== ELEMENT_TYPES.AUTH) {
|
|
2991
|
+
if (type !== ELEMENT_TYPES.AUTH && type !== ELEMENT_TYPES.CHECKOUT) {
|
|
2983
2992
|
element.sendMessage({ type: MESSAGE_TYPES.SET_TOKEN, token: message.token });
|
|
2984
2993
|
}
|
|
2985
2994
|
});
|
|
@@ -3169,7 +3178,10 @@ var CimplifyElement = class {
|
|
|
3169
3178
|
publicKey,
|
|
3170
3179
|
demoMode: publicKey.length === 0,
|
|
3171
3180
|
prefillEmail: this.options.prefillEmail,
|
|
3172
|
-
appearance: this.parent.getAppearance()
|
|
3181
|
+
appearance: this.parent.getAppearance(),
|
|
3182
|
+
orderTypes: this.options.orderTypes,
|
|
3183
|
+
defaultOrderType: this.options.defaultOrderType,
|
|
3184
|
+
renderSubmitButton: true
|
|
3173
3185
|
});
|
|
3174
3186
|
const token = this.parent.getAccessToken();
|
|
3175
3187
|
if (token && this.type !== ELEMENT_TYPES.AUTH) {
|
|
@@ -3233,6 +3245,12 @@ var CimplifyElement = class {
|
|
|
3233
3245
|
case MESSAGE_TYPES.CONTACT_PROVIDED:
|
|
3234
3246
|
this.parent._setGuestContact(message.contact, message.contactType);
|
|
3235
3247
|
break;
|
|
3248
|
+
case MESSAGE_TYPES.ORDER_TYPE_CHANGED:
|
|
3249
|
+
this.emit(EVENT_TYPES.ORDER_TYPE_CHANGED, { orderType: message.orderType });
|
|
3250
|
+
break;
|
|
3251
|
+
case MESSAGE_TYPES.REQUEST_SUBMIT:
|
|
3252
|
+
this.emit(EVENT_TYPES.REQUEST_SUBMIT, {});
|
|
3253
|
+
break;
|
|
3236
3254
|
}
|
|
3237
3255
|
}
|
|
3238
3256
|
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,9 @@ 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",
|
|
2612
|
+
REQUEST_SUBMIT: "request_submit"
|
|
2610
2613
|
};
|
|
2611
2614
|
var EVENT_TYPES = {
|
|
2612
2615
|
READY: "ready",
|
|
@@ -2615,7 +2618,9 @@ var EVENT_TYPES = {
|
|
|
2615
2618
|
ERROR: "error",
|
|
2616
2619
|
CHANGE: "change",
|
|
2617
2620
|
BLUR: "blur",
|
|
2618
|
-
FOCUS: "focus"
|
|
2621
|
+
FOCUS: "focus",
|
|
2622
|
+
ORDER_TYPE_CHANGED: "order_type_changed",
|
|
2623
|
+
REQUEST_SUBMIT: "request_submit"
|
|
2619
2624
|
};
|
|
2620
2625
|
|
|
2621
2626
|
// src/elements.ts
|
|
@@ -2764,40 +2769,43 @@ var CimplifyElements = class {
|
|
|
2764
2769
|
false
|
|
2765
2770
|
);
|
|
2766
2771
|
}
|
|
2767
|
-
const
|
|
2768
|
-
if (!
|
|
2769
|
-
console.debug("[cimplify:checkout] BLOCKED: no
|
|
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");
|
|
2770
2775
|
return toCheckoutError(
|
|
2771
2776
|
"NO_PAYMENT_ELEMENT",
|
|
2772
|
-
"
|
|
2777
|
+
"Checkout element must be mounted before checkout.",
|
|
2773
2778
|
false
|
|
2774
2779
|
);
|
|
2775
2780
|
}
|
|
2776
|
-
if (!
|
|
2777
|
-
console.debug("[cimplify:checkout] BLOCKED:
|
|
2781
|
+
if (!checkoutElement.isMounted()) {
|
|
2782
|
+
console.debug("[cimplify:checkout] BLOCKED: checkout element not mounted");
|
|
2778
2783
|
return toCheckoutError(
|
|
2779
2784
|
"PAYMENT_NOT_MOUNTED",
|
|
2780
|
-
"
|
|
2785
|
+
"Checkout element must be mounted before checkout.",
|
|
2781
2786
|
false
|
|
2782
2787
|
);
|
|
2783
2788
|
}
|
|
2784
|
-
const
|
|
2785
|
-
if (
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
"
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
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();
|
|
2798
2807
|
}
|
|
2799
|
-
|
|
2800
|
-
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 });
|
|
2801
2809
|
const processMessage = {
|
|
2802
2810
|
type: MESSAGE_TYPES.PROCESS_CHECKOUT,
|
|
2803
2811
|
cart_id: options.cart_id,
|
|
@@ -2808,8 +2816,9 @@ var CimplifyElements = class {
|
|
|
2808
2816
|
tip_amount: options.tip_amount,
|
|
2809
2817
|
pay_currency: options.pay_currency,
|
|
2810
2818
|
enroll_in_link: options.enroll_in_link ?? true,
|
|
2811
|
-
address
|
|
2812
|
-
|
|
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 ? {
|
|
2813
2822
|
name: this.customerData.name,
|
|
2814
2823
|
email: this.customerData.email,
|
|
2815
2824
|
phone: this.customerData.phone
|
|
@@ -2818,7 +2827,7 @@ var CimplifyElements = class {
|
|
|
2818
2827
|
customer_id: this.customerId ?? void 0
|
|
2819
2828
|
};
|
|
2820
2829
|
const timeoutMs = options.timeout_ms ?? 18e4;
|
|
2821
|
-
const paymentWindow =
|
|
2830
|
+
const paymentWindow = checkoutElement.getContentWindow();
|
|
2822
2831
|
this.checkoutInProgress = true;
|
|
2823
2832
|
return new Promise((resolve) => {
|
|
2824
2833
|
let settled = false;
|
|
@@ -2856,7 +2865,7 @@ var CimplifyElements = class {
|
|
|
2856
2865
|
return;
|
|
2857
2866
|
}
|
|
2858
2867
|
if (message.type === MESSAGE_TYPES.LOGOUT_COMPLETE) {
|
|
2859
|
-
|
|
2868
|
+
checkoutElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
|
|
2860
2869
|
settle(
|
|
2861
2870
|
toCheckoutError(
|
|
2862
2871
|
"AUTH_LOST",
|
|
@@ -2887,7 +2896,7 @@ var CimplifyElements = class {
|
|
|
2887
2896
|
window.addEventListener("message", handleCheckoutMessage);
|
|
2888
2897
|
}
|
|
2889
2898
|
abortFn = () => {
|
|
2890
|
-
|
|
2899
|
+
checkoutElement.sendMessage({ type: MESSAGE_TYPES.ABORT_CHECKOUT });
|
|
2891
2900
|
settle(
|
|
2892
2901
|
toCheckoutError(
|
|
2893
2902
|
"CANCELLED",
|
|
@@ -2897,8 +2906,8 @@ var CimplifyElements = class {
|
|
|
2897
2906
|
);
|
|
2898
2907
|
};
|
|
2899
2908
|
this.activeCheckoutAbort = abortFn;
|
|
2900
|
-
console.debug("[cimplify:checkout] sending process_checkout to
|
|
2901
|
-
|
|
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);
|
|
2902
2911
|
console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
|
|
2903
2912
|
});
|
|
2904
2913
|
})();
|
|
@@ -2977,7 +2986,7 @@ var CimplifyElements = class {
|
|
|
2977
2986
|
this.customerData = customer;
|
|
2978
2987
|
this.client.setAccessToken(message.token);
|
|
2979
2988
|
this.elements.forEach((element, type) => {
|
|
2980
|
-
if (type !== ELEMENT_TYPES.AUTH) {
|
|
2989
|
+
if (type !== ELEMENT_TYPES.AUTH && type !== ELEMENT_TYPES.CHECKOUT) {
|
|
2981
2990
|
element.sendMessage({ type: MESSAGE_TYPES.SET_TOKEN, token: message.token });
|
|
2982
2991
|
}
|
|
2983
2992
|
});
|
|
@@ -3167,7 +3176,10 @@ var CimplifyElement = class {
|
|
|
3167
3176
|
publicKey,
|
|
3168
3177
|
demoMode: publicKey.length === 0,
|
|
3169
3178
|
prefillEmail: this.options.prefillEmail,
|
|
3170
|
-
appearance: this.parent.getAppearance()
|
|
3179
|
+
appearance: this.parent.getAppearance(),
|
|
3180
|
+
orderTypes: this.options.orderTypes,
|
|
3181
|
+
defaultOrderType: this.options.defaultOrderType,
|
|
3182
|
+
renderSubmitButton: true
|
|
3171
3183
|
});
|
|
3172
3184
|
const token = this.parent.getAccessToken();
|
|
3173
3185
|
if (token && this.type !== ELEMENT_TYPES.AUTH) {
|
|
@@ -3231,6 +3243,12 @@ var CimplifyElement = class {
|
|
|
3231
3243
|
case MESSAGE_TYPES.CONTACT_PROVIDED:
|
|
3232
3244
|
this.parent._setGuestContact(message.contact, message.contactType);
|
|
3233
3245
|
break;
|
|
3246
|
+
case MESSAGE_TYPES.ORDER_TYPE_CHANGED:
|
|
3247
|
+
this.emit(EVENT_TYPES.ORDER_TYPE_CHANGED, { orderType: message.orderType });
|
|
3248
|
+
break;
|
|
3249
|
+
case MESSAGE_TYPES.REQUEST_SUBMIT:
|
|
3250
|
+
this.emit(EVENT_TYPES.REQUEST_SUBMIT, {});
|
|
3251
|
+
break;
|
|
3234
3252
|
}
|
|
3235
3253
|
}
|
|
3236
3254
|
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,
|
|
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-bq-xxzM7.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,
|
|
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-BJFeYCB2.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';
|