@cimplify/sdk 0.7.11 → 0.7.12
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 +28 -1
- package/dist/advanced.mjs +28 -1
- package/dist/{client-Bj4y523g.d.mts → client-CVqmSTNq.d.mts} +2 -0
- package/dist/{client-CUYaKDjB.d.ts → client-Dkinq9Oz.d.ts} +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -1
- package/dist/index.mjs +28 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +88 -14
- package/dist/react.mjs +88 -14
- package/package.json +1 -1
package/dist/advanced.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, t as CimplifyElement, s as CimplifyElements, v as ELEMENT_TYPES, E as EVENT_TYPES, z as ElementEventType, x as ElementOptions, y as ElementType, w as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, o as SchedulingService, S as SearchOptions, u as createElements, k as generateIdempotencyKey } from './client-
|
|
1
|
+
export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, t as CimplifyElement, s as CimplifyElements, v as ELEMENT_TYPES, E as EVENT_TYPES, z as ElementEventType, x as ElementOptions, y as ElementType, w as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, o as SchedulingService, S as SearchOptions, u as createElements, k as generateIdempotencyKey } from './client-CVqmSTNq.mjs';
|
|
2
2
|
import './payment-CLIWNMaP.mjs';
|
|
3
3
|
|
|
4
4
|
type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, t as CimplifyElement, s as CimplifyElements, v as ELEMENT_TYPES, E as EVENT_TYPES, z as ElementEventType, x as ElementOptions, y as ElementType, w as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, o as SchedulingService, S as SearchOptions, u as createElements, k as generateIdempotencyKey } from './client-
|
|
1
|
+
export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, t as CimplifyElement, s as CimplifyElements, v as ELEMENT_TYPES, E as EVENT_TYPES, z as ElementEventType, x as ElementOptions, y as ElementType, w as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, o as SchedulingService, S as SearchOptions, u as createElements, k as generateIdempotencyKey } from './client-Dkinq9Oz.js';
|
|
2
2
|
import './payment-CLIWNMaP.js';
|
|
3
3
|
|
|
4
4
|
type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
|
package/dist/advanced.js
CHANGED
|
@@ -2249,6 +2249,12 @@ var CimplifyElements = class {
|
|
|
2249
2249
|
getElement(type) {
|
|
2250
2250
|
return this.elements.get(type);
|
|
2251
2251
|
}
|
|
2252
|
+
_removeElement(type, instance) {
|
|
2253
|
+
const current = this.elements.get(type);
|
|
2254
|
+
if (current === instance) {
|
|
2255
|
+
this.elements.delete(type);
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2252
2258
|
destroy() {
|
|
2253
2259
|
this.elements.forEach((element) => element.destroy());
|
|
2254
2260
|
this.elements.clear();
|
|
@@ -2287,7 +2293,9 @@ var CimplifyElements = class {
|
|
|
2287
2293
|
processCheckout(options) {
|
|
2288
2294
|
let abortFn = null;
|
|
2289
2295
|
const task = (async () => {
|
|
2296
|
+
console.debug("[cimplify:checkout] processCheckout called", { cart_id: options.cart_id, order_type: options.order_type, location_id: options.location_id });
|
|
2290
2297
|
if (this.checkoutInProgress) {
|
|
2298
|
+
console.debug("[cimplify:checkout] BLOCKED: already processing");
|
|
2291
2299
|
return toCheckoutError(
|
|
2292
2300
|
"ALREADY_PROCESSING",
|
|
2293
2301
|
"Checkout is already in progress.",
|
|
@@ -2295,6 +2303,7 @@ var CimplifyElements = class {
|
|
|
2295
2303
|
);
|
|
2296
2304
|
}
|
|
2297
2305
|
if (!options.cart_id) {
|
|
2306
|
+
console.debug("[cimplify:checkout] BLOCKED: no cart_id");
|
|
2298
2307
|
return toCheckoutError(
|
|
2299
2308
|
"INVALID_CART",
|
|
2300
2309
|
"A valid cart is required before checkout can start.",
|
|
@@ -2302,6 +2311,7 @@ var CimplifyElements = class {
|
|
|
2302
2311
|
);
|
|
2303
2312
|
}
|
|
2304
2313
|
if (!options.order_type) {
|
|
2314
|
+
console.debug("[cimplify:checkout] BLOCKED: no order_type");
|
|
2305
2315
|
return toCheckoutError(
|
|
2306
2316
|
"ORDER_TYPE_REQUIRED",
|
|
2307
2317
|
"Order type is required before checkout can start.",
|
|
@@ -2310,6 +2320,7 @@ var CimplifyElements = class {
|
|
|
2310
2320
|
}
|
|
2311
2321
|
const paymentElement = this.elements.get(ELEMENT_TYPES.PAYMENT);
|
|
2312
2322
|
if (!paymentElement) {
|
|
2323
|
+
console.debug("[cimplify:checkout] BLOCKED: no payment element");
|
|
2313
2324
|
return toCheckoutError(
|
|
2314
2325
|
"NO_PAYMENT_ELEMENT",
|
|
2315
2326
|
"Payment element must be mounted before checkout.",
|
|
@@ -2317,6 +2328,7 @@ var CimplifyElements = class {
|
|
|
2317
2328
|
);
|
|
2318
2329
|
}
|
|
2319
2330
|
if (!paymentElement.isMounted()) {
|
|
2331
|
+
console.debug("[cimplify:checkout] BLOCKED: payment element not mounted");
|
|
2320
2332
|
return toCheckoutError(
|
|
2321
2333
|
"PAYMENT_NOT_MOUNTED",
|
|
2322
2334
|
"Payment element must be mounted before checkout.",
|
|
@@ -2325,6 +2337,7 @@ var CimplifyElements = class {
|
|
|
2325
2337
|
}
|
|
2326
2338
|
const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
|
|
2327
2339
|
if (authElement && !this.accessToken) {
|
|
2340
|
+
console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
|
|
2328
2341
|
return toCheckoutError(
|
|
2329
2342
|
"AUTH_INCOMPLETE",
|
|
2330
2343
|
"Authentication must complete before checkout can start.",
|
|
@@ -2333,9 +2346,12 @@ var CimplifyElements = class {
|
|
|
2333
2346
|
}
|
|
2334
2347
|
const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
|
|
2335
2348
|
if (addressElement) {
|
|
2349
|
+
console.debug("[cimplify:checkout] getting address data...");
|
|
2336
2350
|
await addressElement.getData();
|
|
2351
|
+
console.debug("[cimplify:checkout] address data resolved", this.addressData);
|
|
2337
2352
|
}
|
|
2338
2353
|
await this.hydrateCustomerData();
|
|
2354
|
+
console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
|
|
2339
2355
|
const processMessage = {
|
|
2340
2356
|
type: MESSAGE_TYPES.PROCESS_CHECKOUT,
|
|
2341
2357
|
cart_id: options.cart_id,
|
|
@@ -2412,6 +2428,7 @@ var CimplifyElements = class {
|
|
|
2412
2428
|
return;
|
|
2413
2429
|
}
|
|
2414
2430
|
if (message.type === MESSAGE_TYPES.CHECKOUT_COMPLETE) {
|
|
2431
|
+
console.debug("[cimplify:checkout] received checkout_complete", { success: message.success, error: message.error });
|
|
2415
2432
|
settle({
|
|
2416
2433
|
success: message.success,
|
|
2417
2434
|
order: message.order,
|
|
@@ -2434,7 +2451,9 @@ var CimplifyElements = class {
|
|
|
2434
2451
|
);
|
|
2435
2452
|
};
|
|
2436
2453
|
this.activeCheckoutAbort = abortFn;
|
|
2454
|
+
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 });
|
|
2437
2455
|
paymentElement.sendMessage(processMessage);
|
|
2456
|
+
console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
|
|
2438
2457
|
});
|
|
2439
2458
|
})();
|
|
2440
2459
|
const abortable = task;
|
|
@@ -2575,6 +2594,7 @@ var CimplifyElement = class {
|
|
|
2575
2594
|
this.mounted = false;
|
|
2576
2595
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
2577
2596
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
2597
|
+
this.listening = false;
|
|
2578
2598
|
this.type = type;
|
|
2579
2599
|
this.businessId = businessId;
|
|
2580
2600
|
this.linkUrl = linkUrl;
|
|
@@ -2584,6 +2604,7 @@ var CimplifyElement = class {
|
|
|
2584
2604
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
2585
2605
|
if (typeof window !== "undefined") {
|
|
2586
2606
|
window.addEventListener("message", this.boundHandleMessage);
|
|
2607
|
+
this.listening = true;
|
|
2587
2608
|
}
|
|
2588
2609
|
}
|
|
2589
2610
|
mount(container) {
|
|
@@ -2598,6 +2619,10 @@ var CimplifyElement = class {
|
|
|
2598
2619
|
}
|
|
2599
2620
|
this.container = target;
|
|
2600
2621
|
this.mounted = true;
|
|
2622
|
+
if (!this.listening && typeof window !== "undefined") {
|
|
2623
|
+
window.addEventListener("message", this.boundHandleMessage);
|
|
2624
|
+
this.listening = true;
|
|
2625
|
+
}
|
|
2601
2626
|
void this.createIframe();
|
|
2602
2627
|
}
|
|
2603
2628
|
destroy() {
|
|
@@ -2610,9 +2635,11 @@ var CimplifyElement = class {
|
|
|
2610
2635
|
this.eventHandlers.clear();
|
|
2611
2636
|
this.resolvers.forEach((entry) => clearTimeout(entry.timeoutId));
|
|
2612
2637
|
this.resolvers.clear();
|
|
2613
|
-
if (typeof window !== "undefined") {
|
|
2638
|
+
if (this.listening && typeof window !== "undefined") {
|
|
2614
2639
|
window.removeEventListener("message", this.boundHandleMessage);
|
|
2640
|
+
this.listening = false;
|
|
2615
2641
|
}
|
|
2642
|
+
this.parent._removeElement(this.type, this);
|
|
2616
2643
|
}
|
|
2617
2644
|
on(event, handler) {
|
|
2618
2645
|
if (!this.eventHandlers.has(event)) {
|
package/dist/advanced.mjs
CHANGED
|
@@ -2247,6 +2247,12 @@ var CimplifyElements = class {
|
|
|
2247
2247
|
getElement(type) {
|
|
2248
2248
|
return this.elements.get(type);
|
|
2249
2249
|
}
|
|
2250
|
+
_removeElement(type, instance) {
|
|
2251
|
+
const current = this.elements.get(type);
|
|
2252
|
+
if (current === instance) {
|
|
2253
|
+
this.elements.delete(type);
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2250
2256
|
destroy() {
|
|
2251
2257
|
this.elements.forEach((element) => element.destroy());
|
|
2252
2258
|
this.elements.clear();
|
|
@@ -2285,7 +2291,9 @@ var CimplifyElements = class {
|
|
|
2285
2291
|
processCheckout(options) {
|
|
2286
2292
|
let abortFn = null;
|
|
2287
2293
|
const task = (async () => {
|
|
2294
|
+
console.debug("[cimplify:checkout] processCheckout called", { cart_id: options.cart_id, order_type: options.order_type, location_id: options.location_id });
|
|
2288
2295
|
if (this.checkoutInProgress) {
|
|
2296
|
+
console.debug("[cimplify:checkout] BLOCKED: already processing");
|
|
2289
2297
|
return toCheckoutError(
|
|
2290
2298
|
"ALREADY_PROCESSING",
|
|
2291
2299
|
"Checkout is already in progress.",
|
|
@@ -2293,6 +2301,7 @@ var CimplifyElements = class {
|
|
|
2293
2301
|
);
|
|
2294
2302
|
}
|
|
2295
2303
|
if (!options.cart_id) {
|
|
2304
|
+
console.debug("[cimplify:checkout] BLOCKED: no cart_id");
|
|
2296
2305
|
return toCheckoutError(
|
|
2297
2306
|
"INVALID_CART",
|
|
2298
2307
|
"A valid cart is required before checkout can start.",
|
|
@@ -2300,6 +2309,7 @@ var CimplifyElements = class {
|
|
|
2300
2309
|
);
|
|
2301
2310
|
}
|
|
2302
2311
|
if (!options.order_type) {
|
|
2312
|
+
console.debug("[cimplify:checkout] BLOCKED: no order_type");
|
|
2303
2313
|
return toCheckoutError(
|
|
2304
2314
|
"ORDER_TYPE_REQUIRED",
|
|
2305
2315
|
"Order type is required before checkout can start.",
|
|
@@ -2308,6 +2318,7 @@ var CimplifyElements = class {
|
|
|
2308
2318
|
}
|
|
2309
2319
|
const paymentElement = this.elements.get(ELEMENT_TYPES.PAYMENT);
|
|
2310
2320
|
if (!paymentElement) {
|
|
2321
|
+
console.debug("[cimplify:checkout] BLOCKED: no payment element");
|
|
2311
2322
|
return toCheckoutError(
|
|
2312
2323
|
"NO_PAYMENT_ELEMENT",
|
|
2313
2324
|
"Payment element must be mounted before checkout.",
|
|
@@ -2315,6 +2326,7 @@ var CimplifyElements = class {
|
|
|
2315
2326
|
);
|
|
2316
2327
|
}
|
|
2317
2328
|
if (!paymentElement.isMounted()) {
|
|
2329
|
+
console.debug("[cimplify:checkout] BLOCKED: payment element not mounted");
|
|
2318
2330
|
return toCheckoutError(
|
|
2319
2331
|
"PAYMENT_NOT_MOUNTED",
|
|
2320
2332
|
"Payment element must be mounted before checkout.",
|
|
@@ -2323,6 +2335,7 @@ var CimplifyElements = class {
|
|
|
2323
2335
|
}
|
|
2324
2336
|
const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
|
|
2325
2337
|
if (authElement && !this.accessToken) {
|
|
2338
|
+
console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
|
|
2326
2339
|
return toCheckoutError(
|
|
2327
2340
|
"AUTH_INCOMPLETE",
|
|
2328
2341
|
"Authentication must complete before checkout can start.",
|
|
@@ -2331,9 +2344,12 @@ var CimplifyElements = class {
|
|
|
2331
2344
|
}
|
|
2332
2345
|
const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
|
|
2333
2346
|
if (addressElement) {
|
|
2347
|
+
console.debug("[cimplify:checkout] getting address data...");
|
|
2334
2348
|
await addressElement.getData();
|
|
2349
|
+
console.debug("[cimplify:checkout] address data resolved", this.addressData);
|
|
2335
2350
|
}
|
|
2336
2351
|
await this.hydrateCustomerData();
|
|
2352
|
+
console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
|
|
2337
2353
|
const processMessage = {
|
|
2338
2354
|
type: MESSAGE_TYPES.PROCESS_CHECKOUT,
|
|
2339
2355
|
cart_id: options.cart_id,
|
|
@@ -2410,6 +2426,7 @@ var CimplifyElements = class {
|
|
|
2410
2426
|
return;
|
|
2411
2427
|
}
|
|
2412
2428
|
if (message.type === MESSAGE_TYPES.CHECKOUT_COMPLETE) {
|
|
2429
|
+
console.debug("[cimplify:checkout] received checkout_complete", { success: message.success, error: message.error });
|
|
2413
2430
|
settle({
|
|
2414
2431
|
success: message.success,
|
|
2415
2432
|
order: message.order,
|
|
@@ -2432,7 +2449,9 @@ var CimplifyElements = class {
|
|
|
2432
2449
|
);
|
|
2433
2450
|
};
|
|
2434
2451
|
this.activeCheckoutAbort = abortFn;
|
|
2452
|
+
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 });
|
|
2435
2453
|
paymentElement.sendMessage(processMessage);
|
|
2454
|
+
console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
|
|
2436
2455
|
});
|
|
2437
2456
|
})();
|
|
2438
2457
|
const abortable = task;
|
|
@@ -2573,6 +2592,7 @@ var CimplifyElement = class {
|
|
|
2573
2592
|
this.mounted = false;
|
|
2574
2593
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
2575
2594
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
2595
|
+
this.listening = false;
|
|
2576
2596
|
this.type = type;
|
|
2577
2597
|
this.businessId = businessId;
|
|
2578
2598
|
this.linkUrl = linkUrl;
|
|
@@ -2582,6 +2602,7 @@ var CimplifyElement = class {
|
|
|
2582
2602
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
2583
2603
|
if (typeof window !== "undefined") {
|
|
2584
2604
|
window.addEventListener("message", this.boundHandleMessage);
|
|
2605
|
+
this.listening = true;
|
|
2585
2606
|
}
|
|
2586
2607
|
}
|
|
2587
2608
|
mount(container) {
|
|
@@ -2596,6 +2617,10 @@ var CimplifyElement = class {
|
|
|
2596
2617
|
}
|
|
2597
2618
|
this.container = target;
|
|
2598
2619
|
this.mounted = true;
|
|
2620
|
+
if (!this.listening && typeof window !== "undefined") {
|
|
2621
|
+
window.addEventListener("message", this.boundHandleMessage);
|
|
2622
|
+
this.listening = true;
|
|
2623
|
+
}
|
|
2599
2624
|
void this.createIframe();
|
|
2600
2625
|
}
|
|
2601
2626
|
destroy() {
|
|
@@ -2608,9 +2633,11 @@ var CimplifyElement = class {
|
|
|
2608
2633
|
this.eventHandlers.clear();
|
|
2609
2634
|
this.resolvers.forEach((entry) => clearTimeout(entry.timeoutId));
|
|
2610
2635
|
this.resolvers.clear();
|
|
2611
|
-
if (typeof window !== "undefined") {
|
|
2636
|
+
if (this.listening && typeof window !== "undefined") {
|
|
2612
2637
|
window.removeEventListener("message", this.boundHandleMessage);
|
|
2638
|
+
this.listening = false;
|
|
2613
2639
|
}
|
|
2640
|
+
this.parent._removeElement(this.type, this);
|
|
2614
2641
|
}
|
|
2615
2642
|
on(event, handler) {
|
|
2616
2643
|
if (!this.eventHandlers.has(event)) {
|
|
@@ -2108,6 +2108,7 @@ declare class CimplifyElements {
|
|
|
2108
2108
|
constructor(client: CimplifyClient, businessId?: string, options?: ElementsOptions);
|
|
2109
2109
|
create(type: ElementType, options?: ElementOptions): CimplifyElement;
|
|
2110
2110
|
getElement(type: ElementType): CimplifyElement | undefined;
|
|
2111
|
+
_removeElement(type: ElementType, instance: CimplifyElement): void;
|
|
2111
2112
|
destroy(): void;
|
|
2112
2113
|
submitCheckout(data: ElementsCheckoutData): Promise<ElementsCheckoutResult>;
|
|
2113
2114
|
processCheckout(options: ProcessCheckoutOptions): AbortablePromise<ProcessCheckoutResult>;
|
|
@@ -2136,6 +2137,7 @@ declare class CimplifyElement {
|
|
|
2136
2137
|
private eventHandlers;
|
|
2137
2138
|
private resolvers;
|
|
2138
2139
|
private boundHandleMessage;
|
|
2140
|
+
private listening;
|
|
2139
2141
|
constructor(type: ElementType, businessId: string | null, linkUrl: string, options: ElementOptions, parent: CimplifyElements);
|
|
2140
2142
|
mount(container: string | HTMLElement): void;
|
|
2141
2143
|
destroy(): void;
|
|
@@ -2108,6 +2108,7 @@ declare class CimplifyElements {
|
|
|
2108
2108
|
constructor(client: CimplifyClient, businessId?: string, options?: ElementsOptions);
|
|
2109
2109
|
create(type: ElementType, options?: ElementOptions): CimplifyElement;
|
|
2110
2110
|
getElement(type: ElementType): CimplifyElement | undefined;
|
|
2111
|
+
_removeElement(type: ElementType, instance: CimplifyElement): void;
|
|
2111
2112
|
destroy(): void;
|
|
2112
2113
|
submitCheckout(data: ElementsCheckoutData): Promise<ElementsCheckoutResult>;
|
|
2113
2114
|
processCheckout(options: ProcessCheckoutOptions): AbortablePromise<ProcessCheckoutResult>;
|
|
@@ -2136,6 +2137,7 @@ declare class CimplifyElement {
|
|
|
2136
2137
|
private eventHandlers;
|
|
2137
2138
|
private resolvers;
|
|
2138
2139
|
private boundHandleMessage;
|
|
2140
|
+
private listening;
|
|
2139
2141
|
constructor(type: ElementType, businessId: string | null, linkUrl: string, options: ElementOptions, parent: CimplifyElements);
|
|
2140
2142
|
mount(container: string | HTMLElement): void;
|
|
2141
2143
|
destroy(): void;
|
package/dist/index.d.mts
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-
|
|
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-CVqmSTNq.mjs';
|
|
2
2
|
export { QueryBuilder, query } from './advanced.mjs';
|
|
3
3
|
import { A as ApiError } from './payment-CLIWNMaP.mjs';
|
|
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.mjs';
|
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-
|
|
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';
|
|
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
|
@@ -2697,6 +2697,12 @@ var CimplifyElements = class {
|
|
|
2697
2697
|
getElement(type) {
|
|
2698
2698
|
return this.elements.get(type);
|
|
2699
2699
|
}
|
|
2700
|
+
_removeElement(type, instance) {
|
|
2701
|
+
const current = this.elements.get(type);
|
|
2702
|
+
if (current === instance) {
|
|
2703
|
+
this.elements.delete(type);
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2700
2706
|
destroy() {
|
|
2701
2707
|
this.elements.forEach((element) => element.destroy());
|
|
2702
2708
|
this.elements.clear();
|
|
@@ -2735,7 +2741,9 @@ var CimplifyElements = class {
|
|
|
2735
2741
|
processCheckout(options) {
|
|
2736
2742
|
let abortFn = null;
|
|
2737
2743
|
const task = (async () => {
|
|
2744
|
+
console.debug("[cimplify:checkout] processCheckout called", { cart_id: options.cart_id, order_type: options.order_type, location_id: options.location_id });
|
|
2738
2745
|
if (this.checkoutInProgress) {
|
|
2746
|
+
console.debug("[cimplify:checkout] BLOCKED: already processing");
|
|
2739
2747
|
return toCheckoutError(
|
|
2740
2748
|
"ALREADY_PROCESSING",
|
|
2741
2749
|
"Checkout is already in progress.",
|
|
@@ -2743,6 +2751,7 @@ var CimplifyElements = class {
|
|
|
2743
2751
|
);
|
|
2744
2752
|
}
|
|
2745
2753
|
if (!options.cart_id) {
|
|
2754
|
+
console.debug("[cimplify:checkout] BLOCKED: no cart_id");
|
|
2746
2755
|
return toCheckoutError(
|
|
2747
2756
|
"INVALID_CART",
|
|
2748
2757
|
"A valid cart is required before checkout can start.",
|
|
@@ -2750,6 +2759,7 @@ var CimplifyElements = class {
|
|
|
2750
2759
|
);
|
|
2751
2760
|
}
|
|
2752
2761
|
if (!options.order_type) {
|
|
2762
|
+
console.debug("[cimplify:checkout] BLOCKED: no order_type");
|
|
2753
2763
|
return toCheckoutError(
|
|
2754
2764
|
"ORDER_TYPE_REQUIRED",
|
|
2755
2765
|
"Order type is required before checkout can start.",
|
|
@@ -2758,6 +2768,7 @@ var CimplifyElements = class {
|
|
|
2758
2768
|
}
|
|
2759
2769
|
const paymentElement = this.elements.get(ELEMENT_TYPES.PAYMENT);
|
|
2760
2770
|
if (!paymentElement) {
|
|
2771
|
+
console.debug("[cimplify:checkout] BLOCKED: no payment element");
|
|
2761
2772
|
return toCheckoutError(
|
|
2762
2773
|
"NO_PAYMENT_ELEMENT",
|
|
2763
2774
|
"Payment element must be mounted before checkout.",
|
|
@@ -2765,6 +2776,7 @@ var CimplifyElements = class {
|
|
|
2765
2776
|
);
|
|
2766
2777
|
}
|
|
2767
2778
|
if (!paymentElement.isMounted()) {
|
|
2779
|
+
console.debug("[cimplify:checkout] BLOCKED: payment element not mounted");
|
|
2768
2780
|
return toCheckoutError(
|
|
2769
2781
|
"PAYMENT_NOT_MOUNTED",
|
|
2770
2782
|
"Payment element must be mounted before checkout.",
|
|
@@ -2773,6 +2785,7 @@ var CimplifyElements = class {
|
|
|
2773
2785
|
}
|
|
2774
2786
|
const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
|
|
2775
2787
|
if (authElement && !this.accessToken) {
|
|
2788
|
+
console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
|
|
2776
2789
|
return toCheckoutError(
|
|
2777
2790
|
"AUTH_INCOMPLETE",
|
|
2778
2791
|
"Authentication must complete before checkout can start.",
|
|
@@ -2781,9 +2794,12 @@ var CimplifyElements = class {
|
|
|
2781
2794
|
}
|
|
2782
2795
|
const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
|
|
2783
2796
|
if (addressElement) {
|
|
2797
|
+
console.debug("[cimplify:checkout] getting address data...");
|
|
2784
2798
|
await addressElement.getData();
|
|
2799
|
+
console.debug("[cimplify:checkout] address data resolved", this.addressData);
|
|
2785
2800
|
}
|
|
2786
2801
|
await this.hydrateCustomerData();
|
|
2802
|
+
console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
|
|
2787
2803
|
const processMessage = {
|
|
2788
2804
|
type: MESSAGE_TYPES.PROCESS_CHECKOUT,
|
|
2789
2805
|
cart_id: options.cart_id,
|
|
@@ -2860,6 +2876,7 @@ var CimplifyElements = class {
|
|
|
2860
2876
|
return;
|
|
2861
2877
|
}
|
|
2862
2878
|
if (message.type === MESSAGE_TYPES.CHECKOUT_COMPLETE) {
|
|
2879
|
+
console.debug("[cimplify:checkout] received checkout_complete", { success: message.success, error: message.error });
|
|
2863
2880
|
settle({
|
|
2864
2881
|
success: message.success,
|
|
2865
2882
|
order: message.order,
|
|
@@ -2882,7 +2899,9 @@ var CimplifyElements = class {
|
|
|
2882
2899
|
);
|
|
2883
2900
|
};
|
|
2884
2901
|
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 });
|
|
2885
2903
|
paymentElement.sendMessage(processMessage);
|
|
2904
|
+
console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
|
|
2886
2905
|
});
|
|
2887
2906
|
})();
|
|
2888
2907
|
const abortable = task;
|
|
@@ -3023,6 +3042,7 @@ var CimplifyElement = class {
|
|
|
3023
3042
|
this.mounted = false;
|
|
3024
3043
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
3025
3044
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
3045
|
+
this.listening = false;
|
|
3026
3046
|
this.type = type;
|
|
3027
3047
|
this.businessId = businessId;
|
|
3028
3048
|
this.linkUrl = linkUrl;
|
|
@@ -3032,6 +3052,7 @@ var CimplifyElement = class {
|
|
|
3032
3052
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
3033
3053
|
if (typeof window !== "undefined") {
|
|
3034
3054
|
window.addEventListener("message", this.boundHandleMessage);
|
|
3055
|
+
this.listening = true;
|
|
3035
3056
|
}
|
|
3036
3057
|
}
|
|
3037
3058
|
mount(container) {
|
|
@@ -3046,6 +3067,10 @@ var CimplifyElement = class {
|
|
|
3046
3067
|
}
|
|
3047
3068
|
this.container = target;
|
|
3048
3069
|
this.mounted = true;
|
|
3070
|
+
if (!this.listening && typeof window !== "undefined") {
|
|
3071
|
+
window.addEventListener("message", this.boundHandleMessage);
|
|
3072
|
+
this.listening = true;
|
|
3073
|
+
}
|
|
3049
3074
|
void this.createIframe();
|
|
3050
3075
|
}
|
|
3051
3076
|
destroy() {
|
|
@@ -3058,9 +3083,11 @@ var CimplifyElement = class {
|
|
|
3058
3083
|
this.eventHandlers.clear();
|
|
3059
3084
|
this.resolvers.forEach((entry) => clearTimeout(entry.timeoutId));
|
|
3060
3085
|
this.resolvers.clear();
|
|
3061
|
-
if (typeof window !== "undefined") {
|
|
3086
|
+
if (this.listening && typeof window !== "undefined") {
|
|
3062
3087
|
window.removeEventListener("message", this.boundHandleMessage);
|
|
3088
|
+
this.listening = false;
|
|
3063
3089
|
}
|
|
3090
|
+
this.parent._removeElement(this.type, this);
|
|
3064
3091
|
}
|
|
3065
3092
|
on(event, handler) {
|
|
3066
3093
|
if (!this.eventHandlers.has(event)) {
|
package/dist/index.mjs
CHANGED
|
@@ -2695,6 +2695,12 @@ var CimplifyElements = class {
|
|
|
2695
2695
|
getElement(type) {
|
|
2696
2696
|
return this.elements.get(type);
|
|
2697
2697
|
}
|
|
2698
|
+
_removeElement(type, instance) {
|
|
2699
|
+
const current = this.elements.get(type);
|
|
2700
|
+
if (current === instance) {
|
|
2701
|
+
this.elements.delete(type);
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2698
2704
|
destroy() {
|
|
2699
2705
|
this.elements.forEach((element) => element.destroy());
|
|
2700
2706
|
this.elements.clear();
|
|
@@ -2733,7 +2739,9 @@ var CimplifyElements = class {
|
|
|
2733
2739
|
processCheckout(options) {
|
|
2734
2740
|
let abortFn = null;
|
|
2735
2741
|
const task = (async () => {
|
|
2742
|
+
console.debug("[cimplify:checkout] processCheckout called", { cart_id: options.cart_id, order_type: options.order_type, location_id: options.location_id });
|
|
2736
2743
|
if (this.checkoutInProgress) {
|
|
2744
|
+
console.debug("[cimplify:checkout] BLOCKED: already processing");
|
|
2737
2745
|
return toCheckoutError(
|
|
2738
2746
|
"ALREADY_PROCESSING",
|
|
2739
2747
|
"Checkout is already in progress.",
|
|
@@ -2741,6 +2749,7 @@ var CimplifyElements = class {
|
|
|
2741
2749
|
);
|
|
2742
2750
|
}
|
|
2743
2751
|
if (!options.cart_id) {
|
|
2752
|
+
console.debug("[cimplify:checkout] BLOCKED: no cart_id");
|
|
2744
2753
|
return toCheckoutError(
|
|
2745
2754
|
"INVALID_CART",
|
|
2746
2755
|
"A valid cart is required before checkout can start.",
|
|
@@ -2748,6 +2757,7 @@ var CimplifyElements = class {
|
|
|
2748
2757
|
);
|
|
2749
2758
|
}
|
|
2750
2759
|
if (!options.order_type) {
|
|
2760
|
+
console.debug("[cimplify:checkout] BLOCKED: no order_type");
|
|
2751
2761
|
return toCheckoutError(
|
|
2752
2762
|
"ORDER_TYPE_REQUIRED",
|
|
2753
2763
|
"Order type is required before checkout can start.",
|
|
@@ -2756,6 +2766,7 @@ var CimplifyElements = class {
|
|
|
2756
2766
|
}
|
|
2757
2767
|
const paymentElement = this.elements.get(ELEMENT_TYPES.PAYMENT);
|
|
2758
2768
|
if (!paymentElement) {
|
|
2769
|
+
console.debug("[cimplify:checkout] BLOCKED: no payment element");
|
|
2759
2770
|
return toCheckoutError(
|
|
2760
2771
|
"NO_PAYMENT_ELEMENT",
|
|
2761
2772
|
"Payment element must be mounted before checkout.",
|
|
@@ -2763,6 +2774,7 @@ var CimplifyElements = class {
|
|
|
2763
2774
|
);
|
|
2764
2775
|
}
|
|
2765
2776
|
if (!paymentElement.isMounted()) {
|
|
2777
|
+
console.debug("[cimplify:checkout] BLOCKED: payment element not mounted");
|
|
2766
2778
|
return toCheckoutError(
|
|
2767
2779
|
"PAYMENT_NOT_MOUNTED",
|
|
2768
2780
|
"Payment element must be mounted before checkout.",
|
|
@@ -2771,6 +2783,7 @@ var CimplifyElements = class {
|
|
|
2771
2783
|
}
|
|
2772
2784
|
const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
|
|
2773
2785
|
if (authElement && !this.accessToken) {
|
|
2786
|
+
console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
|
|
2774
2787
|
return toCheckoutError(
|
|
2775
2788
|
"AUTH_INCOMPLETE",
|
|
2776
2789
|
"Authentication must complete before checkout can start.",
|
|
@@ -2779,9 +2792,12 @@ var CimplifyElements = class {
|
|
|
2779
2792
|
}
|
|
2780
2793
|
const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
|
|
2781
2794
|
if (addressElement) {
|
|
2795
|
+
console.debug("[cimplify:checkout] getting address data...");
|
|
2782
2796
|
await addressElement.getData();
|
|
2797
|
+
console.debug("[cimplify:checkout] address data resolved", this.addressData);
|
|
2783
2798
|
}
|
|
2784
2799
|
await this.hydrateCustomerData();
|
|
2800
|
+
console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
|
|
2785
2801
|
const processMessage = {
|
|
2786
2802
|
type: MESSAGE_TYPES.PROCESS_CHECKOUT,
|
|
2787
2803
|
cart_id: options.cart_id,
|
|
@@ -2858,6 +2874,7 @@ var CimplifyElements = class {
|
|
|
2858
2874
|
return;
|
|
2859
2875
|
}
|
|
2860
2876
|
if (message.type === MESSAGE_TYPES.CHECKOUT_COMPLETE) {
|
|
2877
|
+
console.debug("[cimplify:checkout] received checkout_complete", { success: message.success, error: message.error });
|
|
2861
2878
|
settle({
|
|
2862
2879
|
success: message.success,
|
|
2863
2880
|
order: message.order,
|
|
@@ -2880,7 +2897,9 @@ var CimplifyElements = class {
|
|
|
2880
2897
|
);
|
|
2881
2898
|
};
|
|
2882
2899
|
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 });
|
|
2883
2901
|
paymentElement.sendMessage(processMessage);
|
|
2902
|
+
console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
|
|
2884
2903
|
});
|
|
2885
2904
|
})();
|
|
2886
2905
|
const abortable = task;
|
|
@@ -3021,6 +3040,7 @@ var CimplifyElement = class {
|
|
|
3021
3040
|
this.mounted = false;
|
|
3022
3041
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
3023
3042
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
3043
|
+
this.listening = false;
|
|
3024
3044
|
this.type = type;
|
|
3025
3045
|
this.businessId = businessId;
|
|
3026
3046
|
this.linkUrl = linkUrl;
|
|
@@ -3030,6 +3050,7 @@ var CimplifyElement = class {
|
|
|
3030
3050
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
3031
3051
|
if (typeof window !== "undefined") {
|
|
3032
3052
|
window.addEventListener("message", this.boundHandleMessage);
|
|
3053
|
+
this.listening = true;
|
|
3033
3054
|
}
|
|
3034
3055
|
}
|
|
3035
3056
|
mount(container) {
|
|
@@ -3044,6 +3065,10 @@ var CimplifyElement = class {
|
|
|
3044
3065
|
}
|
|
3045
3066
|
this.container = target;
|
|
3046
3067
|
this.mounted = true;
|
|
3068
|
+
if (!this.listening && typeof window !== "undefined") {
|
|
3069
|
+
window.addEventListener("message", this.boundHandleMessage);
|
|
3070
|
+
this.listening = true;
|
|
3071
|
+
}
|
|
3047
3072
|
void this.createIframe();
|
|
3048
3073
|
}
|
|
3049
3074
|
destroy() {
|
|
@@ -3056,9 +3081,11 @@ var CimplifyElement = class {
|
|
|
3056
3081
|
this.eventHandlers.clear();
|
|
3057
3082
|
this.resolvers.forEach((entry) => clearTimeout(entry.timeoutId));
|
|
3058
3083
|
this.resolvers.clear();
|
|
3059
|
-
if (typeof window !== "undefined") {
|
|
3084
|
+
if (this.listening && typeof window !== "undefined") {
|
|
3060
3085
|
window.removeEventListener("message", this.boundHandleMessage);
|
|
3086
|
+
this.listening = false;
|
|
3061
3087
|
}
|
|
3088
|
+
this.parent._removeElement(this.type, this);
|
|
3062
3089
|
}
|
|
3063
3090
|
on(event, handler) {
|
|
3064
3091
|
if (!this.eventHandlers.has(event)) {
|
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-
|
|
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';
|
|
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-
|
|
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';
|
|
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';
|
package/dist/react.js
CHANGED
|
@@ -2969,6 +2969,12 @@ var CimplifyElements = class {
|
|
|
2969
2969
|
getElement(type) {
|
|
2970
2970
|
return this.elements.get(type);
|
|
2971
2971
|
}
|
|
2972
|
+
_removeElement(type, instance) {
|
|
2973
|
+
const current = this.elements.get(type);
|
|
2974
|
+
if (current === instance) {
|
|
2975
|
+
this.elements.delete(type);
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2972
2978
|
destroy() {
|
|
2973
2979
|
this.elements.forEach((element) => element.destroy());
|
|
2974
2980
|
this.elements.clear();
|
|
@@ -3007,7 +3013,9 @@ var CimplifyElements = class {
|
|
|
3007
3013
|
processCheckout(options) {
|
|
3008
3014
|
let abortFn = null;
|
|
3009
3015
|
const task = (async () => {
|
|
3016
|
+
console.debug("[cimplify:checkout] processCheckout called", { cart_id: options.cart_id, order_type: options.order_type, location_id: options.location_id });
|
|
3010
3017
|
if (this.checkoutInProgress) {
|
|
3018
|
+
console.debug("[cimplify:checkout] BLOCKED: already processing");
|
|
3011
3019
|
return toCheckoutError(
|
|
3012
3020
|
"ALREADY_PROCESSING",
|
|
3013
3021
|
"Checkout is already in progress.",
|
|
@@ -3015,6 +3023,7 @@ var CimplifyElements = class {
|
|
|
3015
3023
|
);
|
|
3016
3024
|
}
|
|
3017
3025
|
if (!options.cart_id) {
|
|
3026
|
+
console.debug("[cimplify:checkout] BLOCKED: no cart_id");
|
|
3018
3027
|
return toCheckoutError(
|
|
3019
3028
|
"INVALID_CART",
|
|
3020
3029
|
"A valid cart is required before checkout can start.",
|
|
@@ -3022,6 +3031,7 @@ var CimplifyElements = class {
|
|
|
3022
3031
|
);
|
|
3023
3032
|
}
|
|
3024
3033
|
if (!options.order_type) {
|
|
3034
|
+
console.debug("[cimplify:checkout] BLOCKED: no order_type");
|
|
3025
3035
|
return toCheckoutError(
|
|
3026
3036
|
"ORDER_TYPE_REQUIRED",
|
|
3027
3037
|
"Order type is required before checkout can start.",
|
|
@@ -3030,6 +3040,7 @@ var CimplifyElements = class {
|
|
|
3030
3040
|
}
|
|
3031
3041
|
const paymentElement = this.elements.get(ELEMENT_TYPES.PAYMENT);
|
|
3032
3042
|
if (!paymentElement) {
|
|
3043
|
+
console.debug("[cimplify:checkout] BLOCKED: no payment element");
|
|
3033
3044
|
return toCheckoutError(
|
|
3034
3045
|
"NO_PAYMENT_ELEMENT",
|
|
3035
3046
|
"Payment element must be mounted before checkout.",
|
|
@@ -3037,6 +3048,7 @@ var CimplifyElements = class {
|
|
|
3037
3048
|
);
|
|
3038
3049
|
}
|
|
3039
3050
|
if (!paymentElement.isMounted()) {
|
|
3051
|
+
console.debug("[cimplify:checkout] BLOCKED: payment element not mounted");
|
|
3040
3052
|
return toCheckoutError(
|
|
3041
3053
|
"PAYMENT_NOT_MOUNTED",
|
|
3042
3054
|
"Payment element must be mounted before checkout.",
|
|
@@ -3045,6 +3057,7 @@ var CimplifyElements = class {
|
|
|
3045
3057
|
}
|
|
3046
3058
|
const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
|
|
3047
3059
|
if (authElement && !this.accessToken) {
|
|
3060
|
+
console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
|
|
3048
3061
|
return toCheckoutError(
|
|
3049
3062
|
"AUTH_INCOMPLETE",
|
|
3050
3063
|
"Authentication must complete before checkout can start.",
|
|
@@ -3053,9 +3066,12 @@ var CimplifyElements = class {
|
|
|
3053
3066
|
}
|
|
3054
3067
|
const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
|
|
3055
3068
|
if (addressElement) {
|
|
3069
|
+
console.debug("[cimplify:checkout] getting address data...");
|
|
3056
3070
|
await addressElement.getData();
|
|
3071
|
+
console.debug("[cimplify:checkout] address data resolved", this.addressData);
|
|
3057
3072
|
}
|
|
3058
3073
|
await this.hydrateCustomerData();
|
|
3074
|
+
console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
|
|
3059
3075
|
const processMessage = {
|
|
3060
3076
|
type: MESSAGE_TYPES.PROCESS_CHECKOUT,
|
|
3061
3077
|
cart_id: options.cart_id,
|
|
@@ -3132,6 +3148,7 @@ var CimplifyElements = class {
|
|
|
3132
3148
|
return;
|
|
3133
3149
|
}
|
|
3134
3150
|
if (message.type === MESSAGE_TYPES.CHECKOUT_COMPLETE) {
|
|
3151
|
+
console.debug("[cimplify:checkout] received checkout_complete", { success: message.success, error: message.error });
|
|
3135
3152
|
settle({
|
|
3136
3153
|
success: message.success,
|
|
3137
3154
|
order: message.order,
|
|
@@ -3154,7 +3171,9 @@ var CimplifyElements = class {
|
|
|
3154
3171
|
);
|
|
3155
3172
|
};
|
|
3156
3173
|
this.activeCheckoutAbort = abortFn;
|
|
3174
|
+
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 });
|
|
3157
3175
|
paymentElement.sendMessage(processMessage);
|
|
3176
|
+
console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
|
|
3158
3177
|
});
|
|
3159
3178
|
})();
|
|
3160
3179
|
const abortable = task;
|
|
@@ -3295,6 +3314,7 @@ var CimplifyElement = class {
|
|
|
3295
3314
|
this.mounted = false;
|
|
3296
3315
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
3297
3316
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
3317
|
+
this.listening = false;
|
|
3298
3318
|
this.type = type;
|
|
3299
3319
|
this.businessId = businessId;
|
|
3300
3320
|
this.linkUrl = linkUrl;
|
|
@@ -3304,6 +3324,7 @@ var CimplifyElement = class {
|
|
|
3304
3324
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
3305
3325
|
if (typeof window !== "undefined") {
|
|
3306
3326
|
window.addEventListener("message", this.boundHandleMessage);
|
|
3327
|
+
this.listening = true;
|
|
3307
3328
|
}
|
|
3308
3329
|
}
|
|
3309
3330
|
mount(container) {
|
|
@@ -3318,6 +3339,10 @@ var CimplifyElement = class {
|
|
|
3318
3339
|
}
|
|
3319
3340
|
this.container = target;
|
|
3320
3341
|
this.mounted = true;
|
|
3342
|
+
if (!this.listening && typeof window !== "undefined") {
|
|
3343
|
+
window.addEventListener("message", this.boundHandleMessage);
|
|
3344
|
+
this.listening = true;
|
|
3345
|
+
}
|
|
3321
3346
|
void this.createIframe();
|
|
3322
3347
|
}
|
|
3323
3348
|
destroy() {
|
|
@@ -3330,9 +3355,11 @@ var CimplifyElement = class {
|
|
|
3330
3355
|
this.eventHandlers.clear();
|
|
3331
3356
|
this.resolvers.forEach((entry) => clearTimeout(entry.timeoutId));
|
|
3332
3357
|
this.resolvers.clear();
|
|
3333
|
-
if (typeof window !== "undefined") {
|
|
3358
|
+
if (this.listening && typeof window !== "undefined") {
|
|
3334
3359
|
window.removeEventListener("message", this.boundHandleMessage);
|
|
3360
|
+
this.listening = false;
|
|
3335
3361
|
}
|
|
3362
|
+
this.parent._removeElement(this.type, this);
|
|
3336
3363
|
}
|
|
3337
3364
|
on(event, handler) {
|
|
3338
3365
|
if (!this.eventHandlers.has(event)) {
|
|
@@ -6127,17 +6154,36 @@ function AuthElement({
|
|
|
6127
6154
|
const containerRef = react.useRef(null);
|
|
6128
6155
|
const elementRef = react.useRef(null);
|
|
6129
6156
|
const elements = useElements();
|
|
6157
|
+
const onReadyRef = react.useRef(onReady);
|
|
6158
|
+
const onAuthenticatedRef = react.useRef(onAuthenticated);
|
|
6159
|
+
const onRequiresOtpRef = react.useRef(onRequiresOtp);
|
|
6160
|
+
const onErrorRef = react.useRef(onError);
|
|
6161
|
+
react.useEffect(() => {
|
|
6162
|
+
onReadyRef.current = onReady;
|
|
6163
|
+
onAuthenticatedRef.current = onAuthenticated;
|
|
6164
|
+
onRequiresOtpRef.current = onRequiresOtp;
|
|
6165
|
+
onErrorRef.current = onError;
|
|
6166
|
+
}, [onReady, onAuthenticated, onRequiresOtp, onError]);
|
|
6130
6167
|
react.useEffect(() => {
|
|
6131
6168
|
if (!elements || !containerRef.current) return;
|
|
6132
6169
|
const element = elements.create(ELEMENT_TYPES.AUTH, { prefillEmail });
|
|
6133
6170
|
elementRef.current = element;
|
|
6134
|
-
element.on(EVENT_TYPES.READY, () =>
|
|
6135
|
-
element.on(
|
|
6136
|
-
|
|
6137
|
-
|
|
6171
|
+
element.on(EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6172
|
+
element.on(
|
|
6173
|
+
EVENT_TYPES.AUTHENTICATED,
|
|
6174
|
+
(data) => onAuthenticatedRef.current?.(data)
|
|
6175
|
+
);
|
|
6176
|
+
element.on(
|
|
6177
|
+
EVENT_TYPES.REQUIRES_OTP,
|
|
6178
|
+
(data) => onRequiresOtpRef.current?.(data)
|
|
6179
|
+
);
|
|
6180
|
+
element.on(
|
|
6181
|
+
EVENT_TYPES.ERROR,
|
|
6182
|
+
(data) => onErrorRef.current?.(data)
|
|
6183
|
+
);
|
|
6138
6184
|
element.mount(containerRef.current);
|
|
6139
6185
|
return () => element.destroy();
|
|
6140
|
-
}, [elements, prefillEmail
|
|
6186
|
+
}, [elements, prefillEmail]);
|
|
6141
6187
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className, style });
|
|
6142
6188
|
}
|
|
6143
6189
|
function AddressElement({
|
|
@@ -6151,16 +6197,30 @@ function AddressElement({
|
|
|
6151
6197
|
const containerRef = react.useRef(null);
|
|
6152
6198
|
const elementRef = react.useRef(null);
|
|
6153
6199
|
const elements = useElements();
|
|
6200
|
+
const onReadyRef = react.useRef(onReady);
|
|
6201
|
+
const onChangeRef = react.useRef(onChange);
|
|
6202
|
+
const onErrorRef = react.useRef(onError);
|
|
6203
|
+
react.useEffect(() => {
|
|
6204
|
+
onReadyRef.current = onReady;
|
|
6205
|
+
onChangeRef.current = onChange;
|
|
6206
|
+
onErrorRef.current = onError;
|
|
6207
|
+
}, [onReady, onChange, onError]);
|
|
6154
6208
|
react.useEffect(() => {
|
|
6155
6209
|
if (!elements || !containerRef.current) return;
|
|
6156
6210
|
const element = elements.create(ELEMENT_TYPES.ADDRESS, { mode });
|
|
6157
6211
|
elementRef.current = element;
|
|
6158
|
-
element.on(EVENT_TYPES.READY, () =>
|
|
6159
|
-
element.on(
|
|
6160
|
-
|
|
6212
|
+
element.on(EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6213
|
+
element.on(
|
|
6214
|
+
EVENT_TYPES.CHANGE,
|
|
6215
|
+
(data) => onChangeRef.current?.(data)
|
|
6216
|
+
);
|
|
6217
|
+
element.on(
|
|
6218
|
+
EVENT_TYPES.ERROR,
|
|
6219
|
+
(data) => onErrorRef.current?.(data)
|
|
6220
|
+
);
|
|
6161
6221
|
element.mount(containerRef.current);
|
|
6162
6222
|
return () => element.destroy();
|
|
6163
|
-
}, [elements, mode
|
|
6223
|
+
}, [elements, mode]);
|
|
6164
6224
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className, style });
|
|
6165
6225
|
}
|
|
6166
6226
|
function PaymentElement({
|
|
@@ -6175,16 +6235,30 @@ function PaymentElement({
|
|
|
6175
6235
|
const containerRef = react.useRef(null);
|
|
6176
6236
|
const elementRef = react.useRef(null);
|
|
6177
6237
|
const elements = useElements();
|
|
6238
|
+
const onReadyRef = react.useRef(onReady);
|
|
6239
|
+
const onChangeRef = react.useRef(onChange);
|
|
6240
|
+
const onErrorRef = react.useRef(onError);
|
|
6241
|
+
react.useEffect(() => {
|
|
6242
|
+
onReadyRef.current = onReady;
|
|
6243
|
+
onChangeRef.current = onChange;
|
|
6244
|
+
onErrorRef.current = onError;
|
|
6245
|
+
}, [onReady, onChange, onError]);
|
|
6178
6246
|
react.useEffect(() => {
|
|
6179
6247
|
if (!elements || !containerRef.current) return;
|
|
6180
6248
|
const element = elements.create(ELEMENT_TYPES.PAYMENT, { amount, currency });
|
|
6181
6249
|
elementRef.current = element;
|
|
6182
|
-
element.on(EVENT_TYPES.READY, () =>
|
|
6183
|
-
element.on(
|
|
6184
|
-
|
|
6250
|
+
element.on(EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6251
|
+
element.on(
|
|
6252
|
+
EVENT_TYPES.CHANGE,
|
|
6253
|
+
(data) => onChangeRef.current?.(data)
|
|
6254
|
+
);
|
|
6255
|
+
element.on(
|
|
6256
|
+
EVENT_TYPES.ERROR,
|
|
6257
|
+
(data) => onErrorRef.current?.(data)
|
|
6258
|
+
);
|
|
6185
6259
|
element.mount(containerRef.current);
|
|
6186
6260
|
return () => element.destroy();
|
|
6187
|
-
}, [elements, amount, currency
|
|
6261
|
+
}, [elements, amount, currency]);
|
|
6188
6262
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className, style });
|
|
6189
6263
|
}
|
|
6190
6264
|
function useCheckout() {
|
package/dist/react.mjs
CHANGED
|
@@ -2967,6 +2967,12 @@ var CimplifyElements = class {
|
|
|
2967
2967
|
getElement(type) {
|
|
2968
2968
|
return this.elements.get(type);
|
|
2969
2969
|
}
|
|
2970
|
+
_removeElement(type, instance) {
|
|
2971
|
+
const current = this.elements.get(type);
|
|
2972
|
+
if (current === instance) {
|
|
2973
|
+
this.elements.delete(type);
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2970
2976
|
destroy() {
|
|
2971
2977
|
this.elements.forEach((element) => element.destroy());
|
|
2972
2978
|
this.elements.clear();
|
|
@@ -3005,7 +3011,9 @@ var CimplifyElements = class {
|
|
|
3005
3011
|
processCheckout(options) {
|
|
3006
3012
|
let abortFn = null;
|
|
3007
3013
|
const task = (async () => {
|
|
3014
|
+
console.debug("[cimplify:checkout] processCheckout called", { cart_id: options.cart_id, order_type: options.order_type, location_id: options.location_id });
|
|
3008
3015
|
if (this.checkoutInProgress) {
|
|
3016
|
+
console.debug("[cimplify:checkout] BLOCKED: already processing");
|
|
3009
3017
|
return toCheckoutError(
|
|
3010
3018
|
"ALREADY_PROCESSING",
|
|
3011
3019
|
"Checkout is already in progress.",
|
|
@@ -3013,6 +3021,7 @@ var CimplifyElements = class {
|
|
|
3013
3021
|
);
|
|
3014
3022
|
}
|
|
3015
3023
|
if (!options.cart_id) {
|
|
3024
|
+
console.debug("[cimplify:checkout] BLOCKED: no cart_id");
|
|
3016
3025
|
return toCheckoutError(
|
|
3017
3026
|
"INVALID_CART",
|
|
3018
3027
|
"A valid cart is required before checkout can start.",
|
|
@@ -3020,6 +3029,7 @@ var CimplifyElements = class {
|
|
|
3020
3029
|
);
|
|
3021
3030
|
}
|
|
3022
3031
|
if (!options.order_type) {
|
|
3032
|
+
console.debug("[cimplify:checkout] BLOCKED: no order_type");
|
|
3023
3033
|
return toCheckoutError(
|
|
3024
3034
|
"ORDER_TYPE_REQUIRED",
|
|
3025
3035
|
"Order type is required before checkout can start.",
|
|
@@ -3028,6 +3038,7 @@ var CimplifyElements = class {
|
|
|
3028
3038
|
}
|
|
3029
3039
|
const paymentElement = this.elements.get(ELEMENT_TYPES.PAYMENT);
|
|
3030
3040
|
if (!paymentElement) {
|
|
3041
|
+
console.debug("[cimplify:checkout] BLOCKED: no payment element");
|
|
3031
3042
|
return toCheckoutError(
|
|
3032
3043
|
"NO_PAYMENT_ELEMENT",
|
|
3033
3044
|
"Payment element must be mounted before checkout.",
|
|
@@ -3035,6 +3046,7 @@ var CimplifyElements = class {
|
|
|
3035
3046
|
);
|
|
3036
3047
|
}
|
|
3037
3048
|
if (!paymentElement.isMounted()) {
|
|
3049
|
+
console.debug("[cimplify:checkout] BLOCKED: payment element not mounted");
|
|
3038
3050
|
return toCheckoutError(
|
|
3039
3051
|
"PAYMENT_NOT_MOUNTED",
|
|
3040
3052
|
"Payment element must be mounted before checkout.",
|
|
@@ -3043,6 +3055,7 @@ var CimplifyElements = class {
|
|
|
3043
3055
|
}
|
|
3044
3056
|
const authElement = this.elements.get(ELEMENT_TYPES.AUTH);
|
|
3045
3057
|
if (authElement && !this.accessToken) {
|
|
3058
|
+
console.debug("[cimplify:checkout] BLOCKED: auth incomplete");
|
|
3046
3059
|
return toCheckoutError(
|
|
3047
3060
|
"AUTH_INCOMPLETE",
|
|
3048
3061
|
"Authentication must complete before checkout can start.",
|
|
@@ -3051,9 +3064,12 @@ var CimplifyElements = class {
|
|
|
3051
3064
|
}
|
|
3052
3065
|
const addressElement = this.elements.get(ELEMENT_TYPES.ADDRESS);
|
|
3053
3066
|
if (addressElement) {
|
|
3067
|
+
console.debug("[cimplify:checkout] getting address data...");
|
|
3054
3068
|
await addressElement.getData();
|
|
3069
|
+
console.debug("[cimplify:checkout] address data resolved", this.addressData);
|
|
3055
3070
|
}
|
|
3056
3071
|
await this.hydrateCustomerData();
|
|
3072
|
+
console.debug("[cimplify:checkout] customer data hydrated", { customerData: this.customerData, accountId: this.accountId });
|
|
3057
3073
|
const processMessage = {
|
|
3058
3074
|
type: MESSAGE_TYPES.PROCESS_CHECKOUT,
|
|
3059
3075
|
cart_id: options.cart_id,
|
|
@@ -3130,6 +3146,7 @@ var CimplifyElements = class {
|
|
|
3130
3146
|
return;
|
|
3131
3147
|
}
|
|
3132
3148
|
if (message.type === MESSAGE_TYPES.CHECKOUT_COMPLETE) {
|
|
3149
|
+
console.debug("[cimplify:checkout] received checkout_complete", { success: message.success, error: message.error });
|
|
3133
3150
|
settle({
|
|
3134
3151
|
success: message.success,
|
|
3135
3152
|
order: message.order,
|
|
@@ -3152,7 +3169,9 @@ var CimplifyElements = class {
|
|
|
3152
3169
|
);
|
|
3153
3170
|
};
|
|
3154
3171
|
this.activeCheckoutAbort = abortFn;
|
|
3172
|
+
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 });
|
|
3155
3173
|
paymentElement.sendMessage(processMessage);
|
|
3174
|
+
console.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
|
|
3156
3175
|
});
|
|
3157
3176
|
})();
|
|
3158
3177
|
const abortable = task;
|
|
@@ -3293,6 +3312,7 @@ var CimplifyElement = class {
|
|
|
3293
3312
|
this.mounted = false;
|
|
3294
3313
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
3295
3314
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
3315
|
+
this.listening = false;
|
|
3296
3316
|
this.type = type;
|
|
3297
3317
|
this.businessId = businessId;
|
|
3298
3318
|
this.linkUrl = linkUrl;
|
|
@@ -3302,6 +3322,7 @@ var CimplifyElement = class {
|
|
|
3302
3322
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
3303
3323
|
if (typeof window !== "undefined") {
|
|
3304
3324
|
window.addEventListener("message", this.boundHandleMessage);
|
|
3325
|
+
this.listening = true;
|
|
3305
3326
|
}
|
|
3306
3327
|
}
|
|
3307
3328
|
mount(container) {
|
|
@@ -3316,6 +3337,10 @@ var CimplifyElement = class {
|
|
|
3316
3337
|
}
|
|
3317
3338
|
this.container = target;
|
|
3318
3339
|
this.mounted = true;
|
|
3340
|
+
if (!this.listening && typeof window !== "undefined") {
|
|
3341
|
+
window.addEventListener("message", this.boundHandleMessage);
|
|
3342
|
+
this.listening = true;
|
|
3343
|
+
}
|
|
3319
3344
|
void this.createIframe();
|
|
3320
3345
|
}
|
|
3321
3346
|
destroy() {
|
|
@@ -3328,9 +3353,11 @@ var CimplifyElement = class {
|
|
|
3328
3353
|
this.eventHandlers.clear();
|
|
3329
3354
|
this.resolvers.forEach((entry) => clearTimeout(entry.timeoutId));
|
|
3330
3355
|
this.resolvers.clear();
|
|
3331
|
-
if (typeof window !== "undefined") {
|
|
3356
|
+
if (this.listening && typeof window !== "undefined") {
|
|
3332
3357
|
window.removeEventListener("message", this.boundHandleMessage);
|
|
3358
|
+
this.listening = false;
|
|
3333
3359
|
}
|
|
3360
|
+
this.parent._removeElement(this.type, this);
|
|
3334
3361
|
}
|
|
3335
3362
|
on(event, handler) {
|
|
3336
3363
|
if (!this.eventHandlers.has(event)) {
|
|
@@ -6125,17 +6152,36 @@ function AuthElement({
|
|
|
6125
6152
|
const containerRef = useRef(null);
|
|
6126
6153
|
const elementRef = useRef(null);
|
|
6127
6154
|
const elements = useElements();
|
|
6155
|
+
const onReadyRef = useRef(onReady);
|
|
6156
|
+
const onAuthenticatedRef = useRef(onAuthenticated);
|
|
6157
|
+
const onRequiresOtpRef = useRef(onRequiresOtp);
|
|
6158
|
+
const onErrorRef = useRef(onError);
|
|
6159
|
+
useEffect(() => {
|
|
6160
|
+
onReadyRef.current = onReady;
|
|
6161
|
+
onAuthenticatedRef.current = onAuthenticated;
|
|
6162
|
+
onRequiresOtpRef.current = onRequiresOtp;
|
|
6163
|
+
onErrorRef.current = onError;
|
|
6164
|
+
}, [onReady, onAuthenticated, onRequiresOtp, onError]);
|
|
6128
6165
|
useEffect(() => {
|
|
6129
6166
|
if (!elements || !containerRef.current) return;
|
|
6130
6167
|
const element = elements.create(ELEMENT_TYPES.AUTH, { prefillEmail });
|
|
6131
6168
|
elementRef.current = element;
|
|
6132
|
-
element.on(EVENT_TYPES.READY, () =>
|
|
6133
|
-
element.on(
|
|
6134
|
-
|
|
6135
|
-
|
|
6169
|
+
element.on(EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6170
|
+
element.on(
|
|
6171
|
+
EVENT_TYPES.AUTHENTICATED,
|
|
6172
|
+
(data) => onAuthenticatedRef.current?.(data)
|
|
6173
|
+
);
|
|
6174
|
+
element.on(
|
|
6175
|
+
EVENT_TYPES.REQUIRES_OTP,
|
|
6176
|
+
(data) => onRequiresOtpRef.current?.(data)
|
|
6177
|
+
);
|
|
6178
|
+
element.on(
|
|
6179
|
+
EVENT_TYPES.ERROR,
|
|
6180
|
+
(data) => onErrorRef.current?.(data)
|
|
6181
|
+
);
|
|
6136
6182
|
element.mount(containerRef.current);
|
|
6137
6183
|
return () => element.destroy();
|
|
6138
|
-
}, [elements, prefillEmail
|
|
6184
|
+
}, [elements, prefillEmail]);
|
|
6139
6185
|
return /* @__PURE__ */ jsx("div", { ref: containerRef, className, style });
|
|
6140
6186
|
}
|
|
6141
6187
|
function AddressElement({
|
|
@@ -6149,16 +6195,30 @@ function AddressElement({
|
|
|
6149
6195
|
const containerRef = useRef(null);
|
|
6150
6196
|
const elementRef = useRef(null);
|
|
6151
6197
|
const elements = useElements();
|
|
6198
|
+
const onReadyRef = useRef(onReady);
|
|
6199
|
+
const onChangeRef = useRef(onChange);
|
|
6200
|
+
const onErrorRef = useRef(onError);
|
|
6201
|
+
useEffect(() => {
|
|
6202
|
+
onReadyRef.current = onReady;
|
|
6203
|
+
onChangeRef.current = onChange;
|
|
6204
|
+
onErrorRef.current = onError;
|
|
6205
|
+
}, [onReady, onChange, onError]);
|
|
6152
6206
|
useEffect(() => {
|
|
6153
6207
|
if (!elements || !containerRef.current) return;
|
|
6154
6208
|
const element = elements.create(ELEMENT_TYPES.ADDRESS, { mode });
|
|
6155
6209
|
elementRef.current = element;
|
|
6156
|
-
element.on(EVENT_TYPES.READY, () =>
|
|
6157
|
-
element.on(
|
|
6158
|
-
|
|
6210
|
+
element.on(EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6211
|
+
element.on(
|
|
6212
|
+
EVENT_TYPES.CHANGE,
|
|
6213
|
+
(data) => onChangeRef.current?.(data)
|
|
6214
|
+
);
|
|
6215
|
+
element.on(
|
|
6216
|
+
EVENT_TYPES.ERROR,
|
|
6217
|
+
(data) => onErrorRef.current?.(data)
|
|
6218
|
+
);
|
|
6159
6219
|
element.mount(containerRef.current);
|
|
6160
6220
|
return () => element.destroy();
|
|
6161
|
-
}, [elements, mode
|
|
6221
|
+
}, [elements, mode]);
|
|
6162
6222
|
return /* @__PURE__ */ jsx("div", { ref: containerRef, className, style });
|
|
6163
6223
|
}
|
|
6164
6224
|
function PaymentElement({
|
|
@@ -6173,16 +6233,30 @@ function PaymentElement({
|
|
|
6173
6233
|
const containerRef = useRef(null);
|
|
6174
6234
|
const elementRef = useRef(null);
|
|
6175
6235
|
const elements = useElements();
|
|
6236
|
+
const onReadyRef = useRef(onReady);
|
|
6237
|
+
const onChangeRef = useRef(onChange);
|
|
6238
|
+
const onErrorRef = useRef(onError);
|
|
6239
|
+
useEffect(() => {
|
|
6240
|
+
onReadyRef.current = onReady;
|
|
6241
|
+
onChangeRef.current = onChange;
|
|
6242
|
+
onErrorRef.current = onError;
|
|
6243
|
+
}, [onReady, onChange, onError]);
|
|
6176
6244
|
useEffect(() => {
|
|
6177
6245
|
if (!elements || !containerRef.current) return;
|
|
6178
6246
|
const element = elements.create(ELEMENT_TYPES.PAYMENT, { amount, currency });
|
|
6179
6247
|
elementRef.current = element;
|
|
6180
|
-
element.on(EVENT_TYPES.READY, () =>
|
|
6181
|
-
element.on(
|
|
6182
|
-
|
|
6248
|
+
element.on(EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6249
|
+
element.on(
|
|
6250
|
+
EVENT_TYPES.CHANGE,
|
|
6251
|
+
(data) => onChangeRef.current?.(data)
|
|
6252
|
+
);
|
|
6253
|
+
element.on(
|
|
6254
|
+
EVENT_TYPES.ERROR,
|
|
6255
|
+
(data) => onErrorRef.current?.(data)
|
|
6256
|
+
);
|
|
6183
6257
|
element.mount(containerRef.current);
|
|
6184
6258
|
return () => element.destroy();
|
|
6185
|
-
}, [elements, amount, currency
|
|
6259
|
+
}, [elements, amount, currency]);
|
|
6186
6260
|
return /* @__PURE__ */ jsx("div", { ref: containerRef, className, style });
|
|
6187
6261
|
}
|
|
6188
6262
|
function useCheckout() {
|