@cimplify/sdk 0.6.10 → 0.6.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/ads-t3FBTU8p.d.mts +20 -0
- package/dist/ads-t3FBTU8p.d.ts +20 -0
- package/dist/advanced.d.mts +25 -0
- package/dist/advanced.d.ts +25 -0
- package/dist/advanced.js +534 -102
- package/dist/advanced.mjs +534 -102
- package/dist/client-2Rmdqutj.d.ts +2373 -0
- package/dist/client-BIbWQK7v.d.mts +2373 -0
- package/dist/index-DAztg_LQ.d.ts +326 -0
- package/dist/index-Dqaywky7.d.mts +326 -0
- package/dist/index.d.mts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +590 -105
- package/dist/index.mjs +587 -106
- package/dist/payment-CLIWNMaP.d.mts +1133 -0
- package/dist/payment-CLIWNMaP.d.ts +1133 -0
- package/dist/react.d.mts +375 -0
- package/dist/react.d.ts +375 -0
- package/dist/react.js +562 -105
- package/dist/react.mjs +562 -105
- package/dist/utils.d.mts +2 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +27 -0
- package/dist/utils.mjs +24 -1
- package/package.json +1 -1
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-Dqaywky7.mjs';
|
|
2
|
+
import './payment-CLIWNMaP.mjs';
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-DAztg_LQ.js';
|
|
2
|
+
import './payment-CLIWNMaP.js';
|
package/dist/utils.js
CHANGED
|
@@ -145,6 +145,25 @@ function parsePrice(value) {
|
|
|
145
145
|
const parsed = parseFloat(cleaned);
|
|
146
146
|
return isNaN(parsed) ? 0 : parsed;
|
|
147
147
|
}
|
|
148
|
+
function hasTaxInfo(priceInfo) {
|
|
149
|
+
return priceInfo.tax_info !== void 0 && priceInfo.tax_info !== null;
|
|
150
|
+
}
|
|
151
|
+
function getTaxAmount(priceInfo) {
|
|
152
|
+
return parsePrice(priceInfo.tax_info?.tax_amount);
|
|
153
|
+
}
|
|
154
|
+
function isTaxInclusive(priceInfo) {
|
|
155
|
+
return priceInfo.tax_info?.is_inclusive === true;
|
|
156
|
+
}
|
|
157
|
+
function formatPriceWithTax(priceInfo, currency = "GHS") {
|
|
158
|
+
const finalPrice = formatPrice(priceInfo.final_price, currency);
|
|
159
|
+
if (!hasTaxInfo(priceInfo)) {
|
|
160
|
+
return finalPrice;
|
|
161
|
+
}
|
|
162
|
+
if (isTaxInclusive(priceInfo)) {
|
|
163
|
+
return `${finalPrice} (incl. tax)`;
|
|
164
|
+
}
|
|
165
|
+
return `${finalPrice} + ${formatPrice(getTaxAmount(priceInfo), currency)} tax`;
|
|
166
|
+
}
|
|
148
167
|
function getDisplayPrice(product) {
|
|
149
168
|
if (product.price_info) {
|
|
150
169
|
return parsePrice(product.price_info.final_price);
|
|
@@ -238,6 +257,10 @@ var ERROR_SUGGESTIONS = {
|
|
|
238
257
|
CHECKOUT_VALIDATION_FAILED: "Checkout payload failed validation. Verify customer, order type, and address fields are complete.",
|
|
239
258
|
DELIVERY_ADDRESS_REQUIRED: "Delivery orders require an address. Collect and pass address info before processing checkout.",
|
|
240
259
|
CUSTOMER_INFO_REQUIRED: "Customer details are required. Ensure name/email/phone are available before checkout.",
|
|
260
|
+
QUOTE_NOT_FOUND: "Quote could not be found. Refresh pricing and create a new quote before checkout.",
|
|
261
|
+
QUOTE_EXPIRED: "Quote has expired. Re-fetch pricing to generate a new quote with a valid expiry window.",
|
|
262
|
+
QUOTE_CONSUMED: "Quote has already been used. Request a fresh quote to prevent duplicate checkout attempts.",
|
|
263
|
+
QUOTE_STORAGE_UNAVAILABLE: "Quote storage is temporarily unavailable. Retry shortly and avoid charging until quote fetch succeeds.",
|
|
241
264
|
PAYMENT_FAILED: "Payment provider rejected or failed processing. Show retry/change-method options to the shopper.",
|
|
242
265
|
PAYMENT_CANCELLED: "Payment was cancelled by the shopper or provider flow. Allow a safe retry path.",
|
|
243
266
|
INSUFFICIENT_FUNDS: "Payment method has insufficient funds. Prompt shopper to use another method.",
|
|
@@ -513,6 +536,7 @@ exports.formatNumberCompact = formatNumberCompact;
|
|
|
513
536
|
exports.formatPrice = formatPrice;
|
|
514
537
|
exports.formatPriceAdjustment = formatPriceAdjustment;
|
|
515
538
|
exports.formatPriceCompact = formatPriceCompact;
|
|
539
|
+
exports.formatPriceWithTax = formatPriceWithTax;
|
|
516
540
|
exports.formatProductPrice = formatProductPrice;
|
|
517
541
|
exports.getBasePrice = getBasePrice;
|
|
518
542
|
exports.getCurrencySymbol = getCurrencySymbol;
|
|
@@ -520,10 +544,13 @@ exports.getDiscountPercentage = getDiscountPercentage;
|
|
|
520
544
|
exports.getDisplayPrice = getDisplayPrice;
|
|
521
545
|
exports.getMarkupPercentage = getMarkupPercentage;
|
|
522
546
|
exports.getProductCurrency = getProductCurrency;
|
|
547
|
+
exports.getTaxAmount = getTaxAmount;
|
|
548
|
+
exports.hasTaxInfo = hasTaxInfo;
|
|
523
549
|
exports.isOnSale = isOnSale;
|
|
524
550
|
exports.isPaymentStatusFailure = isPaymentStatusFailure;
|
|
525
551
|
exports.isPaymentStatusRequiresAction = isPaymentStatusRequiresAction;
|
|
526
552
|
exports.isPaymentStatusSuccess = isPaymentStatusSuccess;
|
|
553
|
+
exports.isTaxInclusive = isTaxInclusive;
|
|
527
554
|
exports.normalizePaymentResponse = normalizePaymentResponse;
|
|
528
555
|
exports.normalizeStatusResponse = normalizeStatusResponse;
|
|
529
556
|
exports.parsePrice = parsePrice;
|
package/dist/utils.mjs
CHANGED
|
@@ -143,6 +143,25 @@ function parsePrice(value) {
|
|
|
143
143
|
const parsed = parseFloat(cleaned);
|
|
144
144
|
return isNaN(parsed) ? 0 : parsed;
|
|
145
145
|
}
|
|
146
|
+
function hasTaxInfo(priceInfo) {
|
|
147
|
+
return priceInfo.tax_info !== void 0 && priceInfo.tax_info !== null;
|
|
148
|
+
}
|
|
149
|
+
function getTaxAmount(priceInfo) {
|
|
150
|
+
return parsePrice(priceInfo.tax_info?.tax_amount);
|
|
151
|
+
}
|
|
152
|
+
function isTaxInclusive(priceInfo) {
|
|
153
|
+
return priceInfo.tax_info?.is_inclusive === true;
|
|
154
|
+
}
|
|
155
|
+
function formatPriceWithTax(priceInfo, currency = "GHS") {
|
|
156
|
+
const finalPrice = formatPrice(priceInfo.final_price, currency);
|
|
157
|
+
if (!hasTaxInfo(priceInfo)) {
|
|
158
|
+
return finalPrice;
|
|
159
|
+
}
|
|
160
|
+
if (isTaxInclusive(priceInfo)) {
|
|
161
|
+
return `${finalPrice} (incl. tax)`;
|
|
162
|
+
}
|
|
163
|
+
return `${finalPrice} + ${formatPrice(getTaxAmount(priceInfo), currency)} tax`;
|
|
164
|
+
}
|
|
146
165
|
function getDisplayPrice(product) {
|
|
147
166
|
if (product.price_info) {
|
|
148
167
|
return parsePrice(product.price_info.final_price);
|
|
@@ -236,6 +255,10 @@ var ERROR_SUGGESTIONS = {
|
|
|
236
255
|
CHECKOUT_VALIDATION_FAILED: "Checkout payload failed validation. Verify customer, order type, and address fields are complete.",
|
|
237
256
|
DELIVERY_ADDRESS_REQUIRED: "Delivery orders require an address. Collect and pass address info before processing checkout.",
|
|
238
257
|
CUSTOMER_INFO_REQUIRED: "Customer details are required. Ensure name/email/phone are available before checkout.",
|
|
258
|
+
QUOTE_NOT_FOUND: "Quote could not be found. Refresh pricing and create a new quote before checkout.",
|
|
259
|
+
QUOTE_EXPIRED: "Quote has expired. Re-fetch pricing to generate a new quote with a valid expiry window.",
|
|
260
|
+
QUOTE_CONSUMED: "Quote has already been used. Request a fresh quote to prevent duplicate checkout attempts.",
|
|
261
|
+
QUOTE_STORAGE_UNAVAILABLE: "Quote storage is temporarily unavailable. Retry shortly and avoid charging until quote fetch succeeds.",
|
|
239
262
|
PAYMENT_FAILED: "Payment provider rejected or failed processing. Show retry/change-method options to the shopper.",
|
|
240
263
|
PAYMENT_CANCELLED: "Payment was cancelled by the shopper or provider flow. Allow a safe retry path.",
|
|
241
264
|
INSUFFICIENT_FUNDS: "Payment method has insufficient funds. Prompt shopper to use another method.",
|
|
@@ -502,4 +525,4 @@ function detectMobileMoneyProvider(phoneNumber) {
|
|
|
502
525
|
return null;
|
|
503
526
|
}
|
|
504
527
|
|
|
505
|
-
export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, normalizePaymentResponse, normalizeStatusResponse, parsePrice };
|
|
528
|
+
export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, getTaxAmount, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, normalizePaymentResponse, normalizeStatusResponse, parsePrice };
|