@cimplify/sdk 0.6.0 → 0.6.2
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/README.md +5 -0
- package/dist/{ads-B5jcLFpD.d.mts → ads-CXOn6J7P.d.mts} +299 -218
- package/dist/{ads-B5jcLFpD.d.ts → ads-CXOn6J7P.d.ts} +299 -218
- package/dist/index.d.mts +28 -92
- package/dist/index.d.ts +28 -92
- package/dist/index.js +223 -185
- package/dist/index.mjs +221 -183
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -149,6 +149,63 @@ async function safe(promise) {
|
|
|
149
149
|
return err(toCimplifyError(error));
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
+
function isRecord(value) {
|
|
153
|
+
return typeof value === "object" && value !== null;
|
|
154
|
+
}
|
|
155
|
+
function readFinalPrice(value) {
|
|
156
|
+
if (!isRecord(value)) return void 0;
|
|
157
|
+
const finalPrice = value.final_price;
|
|
158
|
+
if (typeof finalPrice === "string" || typeof finalPrice === "number") {
|
|
159
|
+
return finalPrice;
|
|
160
|
+
}
|
|
161
|
+
return void 0;
|
|
162
|
+
}
|
|
163
|
+
function normalizeCatalogueProductPayload(product) {
|
|
164
|
+
const normalized = { ...product };
|
|
165
|
+
const defaultPrice = normalized["default_price"];
|
|
166
|
+
if (defaultPrice === void 0 || defaultPrice === null || defaultPrice === "") {
|
|
167
|
+
const derivedDefaultPrice = readFinalPrice(normalized["default_price_info"]) || readFinalPrice(normalized["price_info"]) || (typeof normalized["final_price"] === "string" || typeof normalized["final_price"] === "number" ? normalized["final_price"] : void 0);
|
|
168
|
+
normalized["default_price"] = derivedDefaultPrice ?? "0";
|
|
169
|
+
}
|
|
170
|
+
const variants = normalized["variants"];
|
|
171
|
+
if (Array.isArray(variants)) {
|
|
172
|
+
normalized["variants"] = variants.map((variant) => {
|
|
173
|
+
if (!isRecord(variant)) return variant;
|
|
174
|
+
const normalizedVariant = { ...variant };
|
|
175
|
+
const variantAdjustment = normalizedVariant["price_adjustment"];
|
|
176
|
+
if (variantAdjustment === void 0 || variantAdjustment === null || variantAdjustment === "") {
|
|
177
|
+
normalizedVariant["price_adjustment"] = readFinalPrice(normalizedVariant["price_info"]) ?? "0";
|
|
178
|
+
}
|
|
179
|
+
return normalizedVariant;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const addOns = normalized["add_ons"];
|
|
183
|
+
if (Array.isArray(addOns)) {
|
|
184
|
+
normalized["add_ons"] = addOns.map((addOn) => {
|
|
185
|
+
if (!isRecord(addOn)) return addOn;
|
|
186
|
+
const normalizedAddOn = { ...addOn };
|
|
187
|
+
const options = normalizedAddOn["options"];
|
|
188
|
+
if (!Array.isArray(options)) return normalizedAddOn;
|
|
189
|
+
normalizedAddOn["options"] = options.map((option) => {
|
|
190
|
+
if (!isRecord(option)) return option;
|
|
191
|
+
const normalizedOption = { ...option };
|
|
192
|
+
const optionPrice = normalizedOption["default_price"];
|
|
193
|
+
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
194
|
+
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
195
|
+
}
|
|
196
|
+
return normalizedOption;
|
|
197
|
+
});
|
|
198
|
+
return normalizedAddOn;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return normalized;
|
|
202
|
+
}
|
|
203
|
+
function findProductBySlug(products, slug) {
|
|
204
|
+
return products.find((product) => {
|
|
205
|
+
const value = product["slug"];
|
|
206
|
+
return typeof value === "string" && value === slug;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
152
209
|
var CatalogueQueries = class {
|
|
153
210
|
constructor(client) {
|
|
154
211
|
this.client = client;
|
|
@@ -186,20 +243,34 @@ var CatalogueQueries = class {
|
|
|
186
243
|
if (options?.offset) {
|
|
187
244
|
query2 += `#offset(${options.offset})`;
|
|
188
245
|
}
|
|
189
|
-
|
|
246
|
+
const result = await safe(this.client.query(query2));
|
|
247
|
+
if (!result.ok) return result;
|
|
248
|
+
return ok(result.value.map((product) => normalizeCatalogueProductPayload(product)));
|
|
190
249
|
}
|
|
191
250
|
async getProduct(id) {
|
|
192
|
-
|
|
251
|
+
const result = await safe(this.client.query(`products.${id}`));
|
|
252
|
+
if (!result.ok) return result;
|
|
253
|
+
return ok(normalizeCatalogueProductPayload(result.value));
|
|
193
254
|
}
|
|
194
255
|
async getProductBySlug(slug) {
|
|
195
|
-
const
|
|
256
|
+
const filteredResult = await safe(
|
|
196
257
|
this.client.query(`products[?(@.slug=='${slug}')]`)
|
|
197
258
|
);
|
|
198
|
-
if (!
|
|
199
|
-
|
|
259
|
+
if (!filteredResult.ok) return filteredResult;
|
|
260
|
+
const exactMatch = findProductBySlug(filteredResult.value, slug);
|
|
261
|
+
if (exactMatch) {
|
|
262
|
+
return ok(normalizeCatalogueProductPayload(exactMatch));
|
|
263
|
+
}
|
|
264
|
+
if (filteredResult.value.length === 1) {
|
|
265
|
+
return ok(normalizeCatalogueProductPayload(filteredResult.value[0]));
|
|
266
|
+
}
|
|
267
|
+
const unfilteredResult = await safe(this.client.query("products"));
|
|
268
|
+
if (!unfilteredResult.ok) return unfilteredResult;
|
|
269
|
+
const fallbackMatch = findProductBySlug(unfilteredResult.value, slug);
|
|
270
|
+
if (!fallbackMatch) {
|
|
200
271
|
return err(new CimplifyError("NOT_FOUND", `Product not found: ${slug}`, false));
|
|
201
272
|
}
|
|
202
|
-
return ok(
|
|
273
|
+
return ok(normalizeCatalogueProductPayload(fallbackMatch));
|
|
203
274
|
}
|
|
204
275
|
async getVariants(productId) {
|
|
205
276
|
return safe(this.client.query(`products.${productId}.variants`));
|
|
@@ -313,6 +384,19 @@ var CatalogueQueries = class {
|
|
|
313
384
|
})
|
|
314
385
|
);
|
|
315
386
|
}
|
|
387
|
+
async fetchQuote(input) {
|
|
388
|
+
return safe(this.client.call("catalogue.createQuote", input));
|
|
389
|
+
}
|
|
390
|
+
async getQuote(quoteId) {
|
|
391
|
+
return safe(
|
|
392
|
+
this.client.call("catalogue.getQuote", {
|
|
393
|
+
quote_id: quoteId
|
|
394
|
+
})
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
async refreshQuote(input) {
|
|
398
|
+
return safe(this.client.call("catalogue.refreshQuote", input));
|
|
399
|
+
}
|
|
316
400
|
async search(query2, options) {
|
|
317
401
|
const limit = options?.limit ?? 20;
|
|
318
402
|
let searchQuery = `products[?(@.name contains '${query2}')]`;
|
|
@@ -364,12 +448,20 @@ async function safe2(promise) {
|
|
|
364
448
|
return err(toCimplifyError2(error));
|
|
365
449
|
}
|
|
366
450
|
}
|
|
451
|
+
function isUICartResponse(value) {
|
|
452
|
+
return "cart" in value;
|
|
453
|
+
}
|
|
454
|
+
function unwrapEnrichedCart(value) {
|
|
455
|
+
return isUICartResponse(value) ? value.cart : value;
|
|
456
|
+
}
|
|
367
457
|
var CartOperations = class {
|
|
368
458
|
constructor(client) {
|
|
369
459
|
this.client = client;
|
|
370
460
|
}
|
|
371
461
|
async get() {
|
|
372
|
-
|
|
462
|
+
const result = await safe2(this.client.query("cart#enriched"));
|
|
463
|
+
if (!result.ok) return result;
|
|
464
|
+
return ok(unwrapEnrichedCart(result.value));
|
|
373
465
|
}
|
|
374
466
|
async getRaw() {
|
|
375
467
|
return safe2(this.client.query("cart"));
|
|
@@ -1322,7 +1414,7 @@ function toCheckoutFormData(data) {
|
|
|
1322
1414
|
} : void 0,
|
|
1323
1415
|
special_instructions: data.notes,
|
|
1324
1416
|
link_address_id: data.address?.id,
|
|
1325
|
-
link_payment_method_id: data.payment_method?.id
|
|
1417
|
+
link_payment_method_id: data.payment_method?.type === "card" && data.payment_method?.id ? data.payment_method.id : void 0
|
|
1326
1418
|
};
|
|
1327
1419
|
}
|
|
1328
1420
|
var DEFAULT_LINK_URL = "https://link.cimplify.io";
|
|
@@ -2273,169 +2365,27 @@ function parsePrice(value) {
|
|
|
2273
2365
|
const parsed = parseFloat(cleaned);
|
|
2274
2366
|
return isNaN(parsed) ? 0 : parsed;
|
|
2275
2367
|
}
|
|
2276
|
-
function
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
if (parts.length < 4 || parts[0] !== "T") {
|
|
2280
|
-
return void 0;
|
|
2281
|
-
}
|
|
2282
|
-
const taxRate = parseFloat(parts[1]);
|
|
2283
|
-
const taxAmount = parseFloat(parts[2]);
|
|
2284
|
-
const isInclusive = parts[3] === "I";
|
|
2285
|
-
const components = [];
|
|
2286
|
-
if (parts.length > 4 && parts[4]) {
|
|
2287
|
-
const componentPairs = parts[4].split(",");
|
|
2288
|
-
for (const pair of componentPairs) {
|
|
2289
|
-
const [name, rateStr] = pair.split(":");
|
|
2290
|
-
if (name && rateStr) {
|
|
2291
|
-
components.push({
|
|
2292
|
-
name: name.trim(),
|
|
2293
|
-
rate: parseFloat(rateStr)
|
|
2294
|
-
});
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
return {
|
|
2299
|
-
taxRate,
|
|
2300
|
-
taxAmount,
|
|
2301
|
-
isInclusive,
|
|
2302
|
-
components
|
|
2303
|
-
};
|
|
2304
|
-
} catch {
|
|
2305
|
-
return void 0;
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
function parsePricePath(signedPricePath) {
|
|
2309
|
-
if (!signedPricePath) {
|
|
2310
|
-
return {
|
|
2311
|
-
basePrice: 0,
|
|
2312
|
-
finalPrice: 0,
|
|
2313
|
-
currency: "GHS",
|
|
2314
|
-
decisionPath: "",
|
|
2315
|
-
isValid: false,
|
|
2316
|
-
isExpired: false
|
|
2317
|
-
};
|
|
2368
|
+
function getDisplayPrice(product) {
|
|
2369
|
+
if (product.price_info) {
|
|
2370
|
+
return parsePrice(product.price_info.final_price);
|
|
2318
2371
|
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
if (parts.length !== 3) {
|
|
2322
|
-
return {
|
|
2323
|
-
basePrice: 0,
|
|
2324
|
-
finalPrice: 0,
|
|
2325
|
-
currency: "GHS",
|
|
2326
|
-
decisionPath: "",
|
|
2327
|
-
isValid: false,
|
|
2328
|
-
isExpired: false
|
|
2329
|
-
};
|
|
2330
|
-
}
|
|
2331
|
-
const [pricePath, expiryStr, signature] = parts;
|
|
2332
|
-
const expiryTimestamp = parseInt(expiryStr, 10);
|
|
2333
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
2334
|
-
const isExpired = now > expiryTimestamp;
|
|
2335
|
-
const priceComponents = pricePath.split("|");
|
|
2336
|
-
if (priceComponents.length < 5) {
|
|
2337
|
-
return {
|
|
2338
|
-
basePrice: 0,
|
|
2339
|
-
finalPrice: 0,
|
|
2340
|
-
currency: "GHS",
|
|
2341
|
-
decisionPath: "",
|
|
2342
|
-
isValid: false,
|
|
2343
|
-
isExpired
|
|
2344
|
-
};
|
|
2345
|
-
}
|
|
2346
|
-
const basePrice = parseFloat(priceComponents[0]);
|
|
2347
|
-
const finalPrice = parseFloat(priceComponents[1]);
|
|
2348
|
-
const currency = priceComponents[2];
|
|
2349
|
-
const taxInfoStr = priceComponents[3];
|
|
2350
|
-
const decisionPath = priceComponents.slice(4).join("|");
|
|
2351
|
-
let taxInfo;
|
|
2352
|
-
if (taxInfoStr && taxInfoStr.startsWith("T:")) {
|
|
2353
|
-
taxInfo = parseTaxInfo(taxInfoStr);
|
|
2354
|
-
} else if (taxInfoStr === "0" || !taxInfoStr) {
|
|
2355
|
-
taxInfo = {
|
|
2356
|
-
taxRate: 0,
|
|
2357
|
-
taxAmount: 0,
|
|
2358
|
-
isInclusive: false,
|
|
2359
|
-
components: []
|
|
2360
|
-
};
|
|
2361
|
-
}
|
|
2362
|
-
let markupPercentage;
|
|
2363
|
-
let markupAmount;
|
|
2364
|
-
let discountPercentage;
|
|
2365
|
-
if (decisionPath) {
|
|
2366
|
-
const pathParts = decisionPath.split(":");
|
|
2367
|
-
if (pathParts.length > 1 && pathParts[1]) {
|
|
2368
|
-
const adjustments = pathParts[1].split(",");
|
|
2369
|
-
for (const adj of adjustments) {
|
|
2370
|
-
const adjParts = adj.split("|");
|
|
2371
|
-
if (adjParts[0] && adjParts[0].startsWith("ch")) {
|
|
2372
|
-
markupAmount = parseFloat(adjParts[1]) || 0;
|
|
2373
|
-
markupPercentage = parseFloat(adjParts[2]) || 0;
|
|
2374
|
-
break;
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
}
|
|
2378
|
-
}
|
|
2379
|
-
if (markupAmount === void 0 && finalPrice > basePrice) {
|
|
2380
|
-
markupAmount = finalPrice - basePrice;
|
|
2381
|
-
markupPercentage = basePrice > 0 ? markupAmount / basePrice * 100 : 0;
|
|
2382
|
-
} else if (basePrice > finalPrice) {
|
|
2383
|
-
discountPercentage = basePrice > 0 ? (basePrice - finalPrice) / basePrice * 100 : 0;
|
|
2384
|
-
}
|
|
2385
|
-
return {
|
|
2386
|
-
basePrice,
|
|
2387
|
-
finalPrice,
|
|
2388
|
-
currency,
|
|
2389
|
-
decisionPath,
|
|
2390
|
-
discountPercentage,
|
|
2391
|
-
markupPercentage,
|
|
2392
|
-
markupAmount,
|
|
2393
|
-
taxInfo,
|
|
2394
|
-
isValid: !isExpired && signature.length > 0,
|
|
2395
|
-
isExpired,
|
|
2396
|
-
expiryTimestamp
|
|
2397
|
-
};
|
|
2398
|
-
} catch {
|
|
2399
|
-
return {
|
|
2400
|
-
basePrice: 0,
|
|
2401
|
-
finalPrice: 0,
|
|
2402
|
-
currency: "GHS",
|
|
2403
|
-
decisionPath: "",
|
|
2404
|
-
isValid: false,
|
|
2405
|
-
isExpired: false
|
|
2406
|
-
};
|
|
2372
|
+
if (product.final_price !== void 0 && product.final_price !== null) {
|
|
2373
|
+
return parsePrice(product.final_price);
|
|
2407
2374
|
}
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
return {
|
|
2411
|
-
base_price: parsedPrice.basePrice,
|
|
2412
|
-
final_price: parsedPrice.finalPrice,
|
|
2413
|
-
markup_percentage: parsedPrice.markupPercentage,
|
|
2414
|
-
markup_amount: parsedPrice.markupAmount,
|
|
2415
|
-
currency: parsedPrice.currency,
|
|
2416
|
-
tax_info: parsedPrice.taxInfo,
|
|
2417
|
-
decision_path: parsedPrice.decisionPath
|
|
2418
|
-
};
|
|
2419
|
-
}
|
|
2420
|
-
function extractPriceInfo(signedPricePath) {
|
|
2421
|
-
const parsed = parsePricePath(signedPricePath);
|
|
2422
|
-
return parsedPriceToPriceInfo(parsed);
|
|
2423
|
-
}
|
|
2424
|
-
function getDisplayPrice(product) {
|
|
2425
|
-
if (product.price_path) {
|
|
2426
|
-
const priceInfo = extractPriceInfo(product.price_path);
|
|
2427
|
-
return priceInfo.final_price;
|
|
2428
|
-
} else if (product.price_info) {
|
|
2429
|
-
return product.price_info.final_price;
|
|
2375
|
+
if (product.default_price !== void 0 && product.default_price !== null) {
|
|
2376
|
+
return parsePrice(product.default_price);
|
|
2430
2377
|
}
|
|
2431
2378
|
return 0;
|
|
2432
2379
|
}
|
|
2433
2380
|
function getBasePrice(product) {
|
|
2434
|
-
if (product.
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
return product.
|
|
2381
|
+
if (product.price_info) {
|
|
2382
|
+
return parsePrice(product.price_info.base_price);
|
|
2383
|
+
}
|
|
2384
|
+
if (product.base_price !== void 0 && product.base_price !== null) {
|
|
2385
|
+
return parsePrice(product.base_price);
|
|
2386
|
+
}
|
|
2387
|
+
if (product.default_price !== void 0 && product.default_price !== null) {
|
|
2388
|
+
return parsePrice(product.default_price);
|
|
2439
2389
|
}
|
|
2440
2390
|
return 0;
|
|
2441
2391
|
}
|
|
@@ -2461,12 +2411,12 @@ function getMarkupPercentage(product) {
|
|
|
2461
2411
|
return 0;
|
|
2462
2412
|
}
|
|
2463
2413
|
function getProductCurrency(product) {
|
|
2464
|
-
if (product.
|
|
2465
|
-
const parsed = parsePricePath(product.price_path);
|
|
2466
|
-
return parsed.currency || "GHS";
|
|
2467
|
-
} else if (product.price_info?.currency) {
|
|
2414
|
+
if (product.price_info?.currency) {
|
|
2468
2415
|
return product.price_info.currency;
|
|
2469
2416
|
}
|
|
2417
|
+
if (product.currency) {
|
|
2418
|
+
return product.currency;
|
|
2419
|
+
}
|
|
2470
2420
|
return "GHS";
|
|
2471
2421
|
}
|
|
2472
2422
|
function formatProductPrice(product, locale = "en-US") {
|
|
@@ -2569,6 +2519,95 @@ function normalizePaymentResponse(response) {
|
|
|
2569
2519
|
metadata: {}
|
|
2570
2520
|
};
|
|
2571
2521
|
}
|
|
2522
|
+
var PAYMENT_SUCCESS_STATUSES = /* @__PURE__ */ new Set([
|
|
2523
|
+
"success",
|
|
2524
|
+
"succeeded",
|
|
2525
|
+
"paid",
|
|
2526
|
+
"captured",
|
|
2527
|
+
"completed",
|
|
2528
|
+
"authorized"
|
|
2529
|
+
]);
|
|
2530
|
+
var PAYMENT_FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
2531
|
+
"failed",
|
|
2532
|
+
"declined",
|
|
2533
|
+
"cancelled",
|
|
2534
|
+
"voided",
|
|
2535
|
+
"error"
|
|
2536
|
+
]);
|
|
2537
|
+
var PAYMENT_REQUIRES_ACTION_STATUSES = /* @__PURE__ */ new Set([
|
|
2538
|
+
"requires_action",
|
|
2539
|
+
"requires_payment_method",
|
|
2540
|
+
"requires_capture"
|
|
2541
|
+
]);
|
|
2542
|
+
var PAYMENT_STATUS_ALIAS_MAP = {
|
|
2543
|
+
ok: "success",
|
|
2544
|
+
done: "success",
|
|
2545
|
+
paid: "paid",
|
|
2546
|
+
paid_in_full: "paid",
|
|
2547
|
+
paid_successfully: "paid",
|
|
2548
|
+
succeeded: "success",
|
|
2549
|
+
captured: "captured",
|
|
2550
|
+
completed: "completed",
|
|
2551
|
+
pending_confirmation: "pending_confirmation",
|
|
2552
|
+
requires_authorization: "requires_action",
|
|
2553
|
+
requires_action: "requires_action",
|
|
2554
|
+
requires_payment_method: "requires_payment_method",
|
|
2555
|
+
requires_capture: "requires_capture",
|
|
2556
|
+
partially_paid: "partially_paid",
|
|
2557
|
+
partially_refunded: "partially_refunded",
|
|
2558
|
+
card_declined: "declined",
|
|
2559
|
+
canceled: "cancelled",
|
|
2560
|
+
authorized: "authorized",
|
|
2561
|
+
cancelled: "cancelled",
|
|
2562
|
+
unresolved: "pending"
|
|
2563
|
+
};
|
|
2564
|
+
var KNOWN_PAYMENT_STATUSES = /* @__PURE__ */ new Set([
|
|
2565
|
+
"pending",
|
|
2566
|
+
"processing",
|
|
2567
|
+
"created",
|
|
2568
|
+
"pending_confirmation",
|
|
2569
|
+
"success",
|
|
2570
|
+
"succeeded",
|
|
2571
|
+
"failed",
|
|
2572
|
+
"declined",
|
|
2573
|
+
"authorized",
|
|
2574
|
+
"refunded",
|
|
2575
|
+
"partially_refunded",
|
|
2576
|
+
"partially_paid",
|
|
2577
|
+
"paid",
|
|
2578
|
+
"unpaid",
|
|
2579
|
+
"requires_action",
|
|
2580
|
+
"requires_payment_method",
|
|
2581
|
+
"requires_capture",
|
|
2582
|
+
"captured",
|
|
2583
|
+
"cancelled",
|
|
2584
|
+
"completed",
|
|
2585
|
+
"voided",
|
|
2586
|
+
"error",
|
|
2587
|
+
"unknown"
|
|
2588
|
+
]);
|
|
2589
|
+
function normalizeStatusToken(status) {
|
|
2590
|
+
return status?.trim().toLowerCase().replace(/[\s-]+/g, "_") ?? "";
|
|
2591
|
+
}
|
|
2592
|
+
function normalizePaymentStatusValue(status) {
|
|
2593
|
+
const normalized = normalizeStatusToken(status);
|
|
2594
|
+
if (Object.prototype.hasOwnProperty.call(PAYMENT_STATUS_ALIAS_MAP, normalized)) {
|
|
2595
|
+
return PAYMENT_STATUS_ALIAS_MAP[normalized];
|
|
2596
|
+
}
|
|
2597
|
+
return KNOWN_PAYMENT_STATUSES.has(normalized) ? normalized : "unknown";
|
|
2598
|
+
}
|
|
2599
|
+
function isPaymentStatusSuccess(status) {
|
|
2600
|
+
const normalizedStatus = normalizePaymentStatusValue(status);
|
|
2601
|
+
return PAYMENT_SUCCESS_STATUSES.has(normalizedStatus);
|
|
2602
|
+
}
|
|
2603
|
+
function isPaymentStatusFailure(status) {
|
|
2604
|
+
const normalizedStatus = normalizePaymentStatusValue(status);
|
|
2605
|
+
return PAYMENT_FAILURE_STATUSES.has(normalizedStatus);
|
|
2606
|
+
}
|
|
2607
|
+
function isPaymentStatusRequiresAction(status) {
|
|
2608
|
+
const normalizedStatus = normalizePaymentStatusValue(status);
|
|
2609
|
+
return PAYMENT_REQUIRES_ACTION_STATUSES.has(normalizedStatus);
|
|
2610
|
+
}
|
|
2572
2611
|
function normalizeStatusResponse(response) {
|
|
2573
2612
|
if (!response || typeof response !== "object") {
|
|
2574
2613
|
return {
|
|
@@ -2578,20 +2617,19 @@ function normalizeStatusResponse(response) {
|
|
|
2578
2617
|
};
|
|
2579
2618
|
}
|
|
2580
2619
|
const res = response;
|
|
2581
|
-
const
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
}
|
|
2620
|
+
const normalizedStatus = normalizePaymentStatusValue(res.status ?? void 0);
|
|
2621
|
+
const paidValue = res.paid === true;
|
|
2622
|
+
const derivedPaid = paidValue || [
|
|
2623
|
+
"success",
|
|
2624
|
+
"succeeded",
|
|
2625
|
+
"paid",
|
|
2626
|
+
"captured",
|
|
2627
|
+
"authorized",
|
|
2628
|
+
"completed"
|
|
2629
|
+
].includes(normalizedStatus);
|
|
2592
2630
|
return {
|
|
2593
|
-
status:
|
|
2594
|
-
paid:
|
|
2631
|
+
status: normalizedStatus,
|
|
2632
|
+
paid: derivedPaid,
|
|
2595
2633
|
amount: res.amount,
|
|
2596
2634
|
currency: res.currency,
|
|
2597
2635
|
reference: res.reference,
|
|
@@ -2614,4 +2652,4 @@ function detectMobileMoneyProvider(phoneNumber) {
|
|
|
2614
2652
|
return null;
|
|
2615
2653
|
}
|
|
2616
2654
|
|
|
2617
|
-
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyElement, CimplifyElements, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, EVENT_TYPES, ErrorCode, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, categorizePaymentError, combine, combineObject, createCimplifyClient, createElements, detectMobileMoneyProvider, err,
|
|
2655
|
+
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyElement, CimplifyElements, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, EVENT_TYPES, ErrorCode, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, categorizePaymentError, combine, combineObject, createCimplifyClient, createElements, detectMobileMoneyProvider, err, flatMap, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, fromPromise, generateIdempotencyKey, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getOrElse, getProductCurrency, isCimplifyError, isErr, isOk, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isRetryableError, mapError, mapResult, normalizePaymentResponse, normalizeStatusResponse, ok, parsePrice, query, toNullable, tryCatch, unwrap };
|
package/dist/react.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { eB as AdSlot, eC as AdPosition, eG as AdContextValue, y as CimplifyElements, C as CimplifyClient, J as ElementsOptions, ev as AuthenticatedData, et as AddressInfo, eu as PaymentMethodInfo, ex as ElementsCheckoutResult } from './ads-CXOn6J7P.mjs';
|
|
2
|
+
export { eE as AdConfig } from './ads-CXOn6J7P.mjs';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
interface UserIdentity {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { eB as AdSlot, eC as AdPosition, eG as AdContextValue, y as CimplifyElements, C as CimplifyClient, J as ElementsOptions, ev as AuthenticatedData, et as AddressInfo, eu as PaymentMethodInfo, ex as ElementsCheckoutResult } from './ads-CXOn6J7P.js';
|
|
2
|
+
export { eE as AdConfig } from './ads-CXOn6J7P.js';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
interface UserIdentity {
|