@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.
@@ -0,0 +1,326 @@
1
+ import { an as ChosenPrice, C as CurrencyCode, ak as TaxPathComponent, al as PricePathTaxInfo, M as Money, b5 as PaymentErrorDetails, b3 as PaymentResponse, b4 as PaymentStatusResponse } from './payment-CLIWNMaP.js';
2
+
3
+ /**
4
+ * Price Types
5
+ *
6
+ * Types for price parsing, formatting, and display utilities.
7
+ */
8
+
9
+ /**
10
+ * Individual tax component (e.g., VAT, NHIL, GETFund)
11
+ */
12
+ /**
13
+ * @deprecated Use `TaxPathComponent` from `types/cart` instead.
14
+ */
15
+ type TaxComponent = TaxPathComponent;
16
+ /**
17
+ * Complete tax information from a pricing response
18
+ */
19
+ /**
20
+ * @deprecated Use `PricePathTaxInfo` from `types/cart` instead.
21
+ */
22
+ type TaxInfo = PricePathTaxInfo;
23
+ /**
24
+ * Price information in snake_case format (as returned from backend)
25
+ * Used by components that work with raw API responses
26
+ */
27
+ /**
28
+ * @deprecated Use `ChosenPrice` from `types/cart` instead.
29
+ */
30
+ type PriceInfo = ChosenPrice;
31
+ /**
32
+ * Minimal product shape for price utilities.
33
+ * Uses quote-aware `price_info` and plain numeric fallback fields.
34
+ */
35
+ interface ProductWithPrice {
36
+ /** Pre-parsed price info from backend */
37
+ price_info?: ChosenPrice;
38
+ /** Final computed price in plain field form (if provided by API) */
39
+ final_price?: number | string | null;
40
+ /** Base/original price in plain field form */
41
+ base_price?: number | string | null;
42
+ /** Default/indicative price in plain field form */
43
+ default_price?: number | string | null;
44
+ /** Currency in plain field form */
45
+ currency?: CurrencyCode | null;
46
+ }
47
+ /**
48
+ * Options for price formatting functions
49
+ */
50
+ interface FormatPriceOptions {
51
+ /** Currency code (default: "GHS") */
52
+ currency?: CurrencyCode;
53
+ /** Locale for Intl.NumberFormat (default: "en-US") */
54
+ locale?: string;
55
+ /** Minimum fraction digits (default: 2) */
56
+ minimumFractionDigits?: number;
57
+ /** Maximum fraction digits (default: 2) */
58
+ maximumFractionDigits?: number;
59
+ }
60
+ /**
61
+ * Options for compact price formatting
62
+ */
63
+ interface FormatCompactOptions {
64
+ /** Currency code (default: "GHS") */
65
+ currency?: CurrencyCode;
66
+ /** Number of decimal places for compact notation (default: 1) */
67
+ decimals?: number;
68
+ }
69
+
70
+ /**
71
+ * Price Utilities
72
+ *
73
+ * Comprehensive utilities for parsing, formatting, and displaying prices.
74
+ * Handles quote-aware pricing fields, currency formatting, and product price helpers.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * import {
79
+ * formatPrice,
80
+ * formatPriceCompact,
81
+ * isOnSale,
82
+ * getDiscountPercentage
83
+ * } from '@cimplify/sdk';
84
+ *
85
+ * // Format prices
86
+ * formatPrice(29.99, 'USD'); // "$29.99"
87
+ * formatPrice(29.99, 'GHS'); // "GH₵29.99"
88
+ * formatPriceCompact(1500000, 'USD'); // "$1.5M"
89
+ *
90
+ * // Check for discounts
91
+ * if (isOnSale(product)) {
92
+ * console.log(`${getDiscountPercentage(product)}% off!`);
93
+ * }
94
+ * ```
95
+ */
96
+
97
+ /**
98
+ * Currency code to symbol mapping
99
+ * Includes major world currencies and African currencies
100
+ */
101
+ declare const CURRENCY_SYMBOLS: Record<string, string>;
102
+ /**
103
+ * Get currency symbol for a currency code
104
+ * @param currencyCode - ISO 4217 currency code (e.g., "USD", "GHS")
105
+ * @returns Currency symbol or the code itself if not found
106
+ *
107
+ * @example
108
+ * getCurrencySymbol('USD') // "$"
109
+ * getCurrencySymbol('GHS') // "GH₵"
110
+ * getCurrencySymbol('XYZ') // "XYZ"
111
+ */
112
+ declare function getCurrencySymbol(currencyCode: CurrencyCode): string;
113
+ /**
114
+ * Format a number compactly with K/M/B suffixes
115
+ * @param value - Number to format
116
+ * @param decimals - Decimal places (default: 1)
117
+ * @returns Compact string representation
118
+ *
119
+ * @example
120
+ * formatNumberCompact(1234) // "1.2K"
121
+ * formatNumberCompact(1500000) // "1.5M"
122
+ * formatNumberCompact(2500000000) // "2.5B"
123
+ */
124
+ declare function formatNumberCompact(value: number, decimals?: number): string;
125
+ /**
126
+ * Format a price with locale-aware currency formatting
127
+ * Uses Intl.NumberFormat for proper localization
128
+ *
129
+ * @param amount - Price amount (number or string)
130
+ * @param currency - ISO 4217 currency code (default: "GHS")
131
+ * @param locale - BCP 47 locale string (default: "en-US")
132
+ * @returns Formatted price string
133
+ *
134
+ * @example
135
+ * formatPrice(29.99, 'USD') // "$29.99"
136
+ * formatPrice(29.99, 'GHS') // "GH₵29.99"
137
+ * formatPrice('29.99', 'EUR') // "€29.99"
138
+ * formatPrice(1234.56, 'USD', 'de-DE') // "1.234,56 $"
139
+ */
140
+ declare function formatPrice(amount: number | Money, currency?: CurrencyCode, locale?: string): string;
141
+ /**
142
+ * Format a price with +/- sign for adjustments
143
+ * Useful for showing price changes, modifiers, or discounts
144
+ *
145
+ * @param amount - Adjustment amount (positive or negative)
146
+ * @param currency - ISO 4217 currency code (default: "GHS")
147
+ * @param locale - BCP 47 locale string (default: "en-US")
148
+ * @returns Formatted adjustment string with sign
149
+ *
150
+ * @example
151
+ * formatPriceAdjustment(5.00, 'USD') // "+$5.00"
152
+ * formatPriceAdjustment(-3.50, 'GHS') // "-GH₵3.50"
153
+ * formatPriceAdjustment(0, 'EUR') // "€0.00"
154
+ */
155
+ declare function formatPriceAdjustment(amount: number, currency?: CurrencyCode, locale?: string): string;
156
+ /**
157
+ * Format a price compactly for large numbers
158
+ * Uses K/M/B suffixes for thousands, millions, billions
159
+ *
160
+ * @param amount - Price amount (number or string)
161
+ * @param currency - ISO 4217 currency code (default: "GHS")
162
+ * @param decimals - Decimal places for compact notation (default: 1)
163
+ * @returns Compact formatted price
164
+ *
165
+ * @example
166
+ * formatPriceCompact(999, 'USD') // "$999.00"
167
+ * formatPriceCompact(1500, 'GHS') // "GH₵1.5K"
168
+ * formatPriceCompact(2500000, 'USD') // "$2.5M"
169
+ * formatPriceCompact(1200000000, 'EUR') // "€1.2B"
170
+ */
171
+ declare function formatPriceCompact(amount: number | Money, currency?: CurrencyCode, decimals?: number): string;
172
+ /**
173
+ * Simple currency symbol + amount format
174
+ * Lighter alternative to formatPrice without Intl
175
+ *
176
+ * @param amount - Price amount (number or string)
177
+ * @param currency - ISO 4217 currency code (default: "GHS")
178
+ * @returns Simple formatted price
179
+ *
180
+ * @example
181
+ * formatMoney(29.99, 'USD') // "$29.99"
182
+ * formatMoney('15.00', 'GHS') // "GH₵15.00"
183
+ */
184
+ declare function formatMoney(amount: Money | number, currency?: CurrencyCode): string;
185
+ /**
186
+ * Parse a price string or number to a numeric value
187
+ * Handles various input formats gracefully
188
+ *
189
+ * @param value - Value to parse (string, number, or undefined)
190
+ * @returns Parsed numeric value, or 0 if invalid
191
+ *
192
+ * @example
193
+ * parsePrice('29.99') // 29.99
194
+ * parsePrice(29.99) // 29.99
195
+ * parsePrice('$29.99') // 29.99 (strips non-numeric prefix)
196
+ * parsePrice(undefined) // 0
197
+ * parsePrice('invalid') // 0
198
+ */
199
+ declare function parsePrice(value: Money | string | number | undefined | null): number;
200
+ /** Check whether tax info exists on the selected price payload. */
201
+ declare function hasTaxInfo(priceInfo: {
202
+ tax_info?: PricePathTaxInfo;
203
+ }): boolean;
204
+ /** Get tax amount from a selected price payload, defaulting to 0 when tax info is absent. */
205
+ declare function getTaxAmount(priceInfo: {
206
+ tax_info?: PricePathTaxInfo;
207
+ }): number;
208
+ /** Check whether the selected price is tax-inclusive. */
209
+ declare function isTaxInclusive(priceInfo: {
210
+ tax_info?: PricePathTaxInfo;
211
+ }): boolean;
212
+ /**
213
+ * Format a final price with tax annotation.
214
+ * Examples: "$10.50 (incl. tax)" or "$10.50 + $1.05 tax"
215
+ */
216
+ declare function formatPriceWithTax(priceInfo: {
217
+ final_price: Money;
218
+ tax_info?: PricePathTaxInfo;
219
+ }, currency?: CurrencyCode): string;
220
+ /**
221
+ * Get the display price from a product.
222
+ * Prefers quote-aware price_info, then plain price fields.
223
+ *
224
+ * @param product - Product with price data
225
+ * @returns The final price to display
226
+ *
227
+ * @example
228
+ * const price = getDisplayPrice(product);
229
+ * console.log(formatPrice(price, 'GHS')); // "GH₵29.99"
230
+ */
231
+ declare function getDisplayPrice(product: ProductWithPrice): number;
232
+ /**
233
+ * Get the base price from a product (before markup/discount)
234
+ *
235
+ * @param product - Product with price data
236
+ * @returns The base price before adjustments
237
+ */
238
+ declare function getBasePrice(product: ProductWithPrice): number;
239
+ /**
240
+ * Check if a product is on sale (discounted)
241
+ *
242
+ * @param product - Product with price data
243
+ * @returns True if the final price is less than the base price
244
+ *
245
+ * @example
246
+ * if (isOnSale(product)) {
247
+ * return <Badge>Sale!</Badge>;
248
+ * }
249
+ */
250
+ declare function isOnSale(product: ProductWithPrice): boolean;
251
+ /**
252
+ * Get the discount percentage for a product on sale
253
+ *
254
+ * @param product - Product with price data
255
+ * @returns Discount percentage (0-100), or 0 if not on sale
256
+ *
257
+ * @example
258
+ * const discount = getDiscountPercentage(product);
259
+ * if (discount > 0) {
260
+ * return <Badge>{discount}% OFF</Badge>;
261
+ * }
262
+ */
263
+ declare function getDiscountPercentage(product: ProductWithPrice): number;
264
+ /**
265
+ * Get the markup percentage for a product
266
+ *
267
+ * @param product - Product with price data
268
+ * @returns Markup percentage, or 0 if no markup
269
+ */
270
+ declare function getMarkupPercentage(product: ProductWithPrice): number;
271
+ /**
272
+ * Get the currency for a product
273
+ *
274
+ * @param product - Product with price data
275
+ * @returns Currency code (default: "GHS")
276
+ */
277
+ declare function getProductCurrency(product: ProductWithPrice): CurrencyCode;
278
+ /**
279
+ * Format a product's display price
280
+ * Convenience function combining getDisplayPrice and formatPrice
281
+ *
282
+ * @param product - Product with price data
283
+ * @param locale - BCP 47 locale string (default: "en-US")
284
+ * @returns Formatted price string
285
+ *
286
+ * @example
287
+ * <span>{formatProductPrice(product)}</span> // "GH₵29.99"
288
+ */
289
+ declare function formatProductPrice(product: ProductWithPrice, locale?: string): string;
290
+
291
+ /**
292
+ * Categorize payment errors into user-friendly messages
293
+ */
294
+ declare function categorizePaymentError(error: Error, errorCode?: string): PaymentErrorDetails;
295
+ /**
296
+ * Normalize payment response from different formats into a standard PaymentResponse
297
+ */
298
+ declare function normalizePaymentResponse(response: unknown): PaymentResponse;
299
+ declare function isPaymentStatusSuccess(status: string | undefined): boolean;
300
+ declare function isPaymentStatusFailure(status: string | undefined): boolean;
301
+ declare function isPaymentStatusRequiresAction(status: string | undefined): boolean;
302
+ /**
303
+ * Normalize payment status response into a standard format
304
+ */
305
+ declare function normalizeStatusResponse(response: unknown): PaymentStatusResponse;
306
+ /** Mobile money provider display names */
307
+ declare const MOBILE_MONEY_PROVIDERS: {
308
+ readonly mtn: {
309
+ readonly name: "MTN Mobile Money";
310
+ readonly prefix: readonly ["024", "054", "055", "059"];
311
+ };
312
+ readonly vodafone: {
313
+ readonly name: "Vodafone Cash";
314
+ readonly prefix: readonly ["020", "050"];
315
+ };
316
+ readonly airtel: {
317
+ readonly name: "AirtelTigo Money";
318
+ readonly prefix: readonly ["027", "057", "026", "056"];
319
+ };
320
+ };
321
+ /**
322
+ * Detect mobile money provider from phone number
323
+ */
324
+ declare function detectMobileMoneyProvider(phoneNumber: string): "mtn" | "vodafone" | "airtel" | null;
325
+
326
+ export { type ProductWithPrice as A, type FormatCompactOptions as B, CURRENCY_SYMBOLS as C, type FormatPriceOptions as F, MOBILE_MONEY_PROVIDERS as M, type PriceInfo as P, type TaxComponent as T, formatPriceAdjustment as a, formatPriceCompact as b, formatMoney as c, formatNumberCompact as d, formatProductPrice as e, formatPrice as f, getTaxAmount as g, hasTaxInfo as h, isTaxInclusive as i, formatPriceWithTax as j, getCurrencySymbol as k, getDisplayPrice as l, getBasePrice as m, isOnSale as n, getDiscountPercentage as o, parsePrice as p, getMarkupPercentage as q, getProductCurrency as r, categorizePaymentError as s, normalizePaymentResponse as t, normalizeStatusResponse as u, isPaymentStatusFailure as v, isPaymentStatusRequiresAction as w, isPaymentStatusSuccess as x, detectMobileMoneyProvider as y, type TaxInfo as z };
@@ -0,0 +1,326 @@
1
+ import { an as ChosenPrice, C as CurrencyCode, ak as TaxPathComponent, al as PricePathTaxInfo, M as Money, b5 as PaymentErrorDetails, b3 as PaymentResponse, b4 as PaymentStatusResponse } from './payment-CLIWNMaP.mjs';
2
+
3
+ /**
4
+ * Price Types
5
+ *
6
+ * Types for price parsing, formatting, and display utilities.
7
+ */
8
+
9
+ /**
10
+ * Individual tax component (e.g., VAT, NHIL, GETFund)
11
+ */
12
+ /**
13
+ * @deprecated Use `TaxPathComponent` from `types/cart` instead.
14
+ */
15
+ type TaxComponent = TaxPathComponent;
16
+ /**
17
+ * Complete tax information from a pricing response
18
+ */
19
+ /**
20
+ * @deprecated Use `PricePathTaxInfo` from `types/cart` instead.
21
+ */
22
+ type TaxInfo = PricePathTaxInfo;
23
+ /**
24
+ * Price information in snake_case format (as returned from backend)
25
+ * Used by components that work with raw API responses
26
+ */
27
+ /**
28
+ * @deprecated Use `ChosenPrice` from `types/cart` instead.
29
+ */
30
+ type PriceInfo = ChosenPrice;
31
+ /**
32
+ * Minimal product shape for price utilities.
33
+ * Uses quote-aware `price_info` and plain numeric fallback fields.
34
+ */
35
+ interface ProductWithPrice {
36
+ /** Pre-parsed price info from backend */
37
+ price_info?: ChosenPrice;
38
+ /** Final computed price in plain field form (if provided by API) */
39
+ final_price?: number | string | null;
40
+ /** Base/original price in plain field form */
41
+ base_price?: number | string | null;
42
+ /** Default/indicative price in plain field form */
43
+ default_price?: number | string | null;
44
+ /** Currency in plain field form */
45
+ currency?: CurrencyCode | null;
46
+ }
47
+ /**
48
+ * Options for price formatting functions
49
+ */
50
+ interface FormatPriceOptions {
51
+ /** Currency code (default: "GHS") */
52
+ currency?: CurrencyCode;
53
+ /** Locale for Intl.NumberFormat (default: "en-US") */
54
+ locale?: string;
55
+ /** Minimum fraction digits (default: 2) */
56
+ minimumFractionDigits?: number;
57
+ /** Maximum fraction digits (default: 2) */
58
+ maximumFractionDigits?: number;
59
+ }
60
+ /**
61
+ * Options for compact price formatting
62
+ */
63
+ interface FormatCompactOptions {
64
+ /** Currency code (default: "GHS") */
65
+ currency?: CurrencyCode;
66
+ /** Number of decimal places for compact notation (default: 1) */
67
+ decimals?: number;
68
+ }
69
+
70
+ /**
71
+ * Price Utilities
72
+ *
73
+ * Comprehensive utilities for parsing, formatting, and displaying prices.
74
+ * Handles quote-aware pricing fields, currency formatting, and product price helpers.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * import {
79
+ * formatPrice,
80
+ * formatPriceCompact,
81
+ * isOnSale,
82
+ * getDiscountPercentage
83
+ * } from '@cimplify/sdk';
84
+ *
85
+ * // Format prices
86
+ * formatPrice(29.99, 'USD'); // "$29.99"
87
+ * formatPrice(29.99, 'GHS'); // "GH₵29.99"
88
+ * formatPriceCompact(1500000, 'USD'); // "$1.5M"
89
+ *
90
+ * // Check for discounts
91
+ * if (isOnSale(product)) {
92
+ * console.log(`${getDiscountPercentage(product)}% off!`);
93
+ * }
94
+ * ```
95
+ */
96
+
97
+ /**
98
+ * Currency code to symbol mapping
99
+ * Includes major world currencies and African currencies
100
+ */
101
+ declare const CURRENCY_SYMBOLS: Record<string, string>;
102
+ /**
103
+ * Get currency symbol for a currency code
104
+ * @param currencyCode - ISO 4217 currency code (e.g., "USD", "GHS")
105
+ * @returns Currency symbol or the code itself if not found
106
+ *
107
+ * @example
108
+ * getCurrencySymbol('USD') // "$"
109
+ * getCurrencySymbol('GHS') // "GH₵"
110
+ * getCurrencySymbol('XYZ') // "XYZ"
111
+ */
112
+ declare function getCurrencySymbol(currencyCode: CurrencyCode): string;
113
+ /**
114
+ * Format a number compactly with K/M/B suffixes
115
+ * @param value - Number to format
116
+ * @param decimals - Decimal places (default: 1)
117
+ * @returns Compact string representation
118
+ *
119
+ * @example
120
+ * formatNumberCompact(1234) // "1.2K"
121
+ * formatNumberCompact(1500000) // "1.5M"
122
+ * formatNumberCompact(2500000000) // "2.5B"
123
+ */
124
+ declare function formatNumberCompact(value: number, decimals?: number): string;
125
+ /**
126
+ * Format a price with locale-aware currency formatting
127
+ * Uses Intl.NumberFormat for proper localization
128
+ *
129
+ * @param amount - Price amount (number or string)
130
+ * @param currency - ISO 4217 currency code (default: "GHS")
131
+ * @param locale - BCP 47 locale string (default: "en-US")
132
+ * @returns Formatted price string
133
+ *
134
+ * @example
135
+ * formatPrice(29.99, 'USD') // "$29.99"
136
+ * formatPrice(29.99, 'GHS') // "GH₵29.99"
137
+ * formatPrice('29.99', 'EUR') // "€29.99"
138
+ * formatPrice(1234.56, 'USD', 'de-DE') // "1.234,56 $"
139
+ */
140
+ declare function formatPrice(amount: number | Money, currency?: CurrencyCode, locale?: string): string;
141
+ /**
142
+ * Format a price with +/- sign for adjustments
143
+ * Useful for showing price changes, modifiers, or discounts
144
+ *
145
+ * @param amount - Adjustment amount (positive or negative)
146
+ * @param currency - ISO 4217 currency code (default: "GHS")
147
+ * @param locale - BCP 47 locale string (default: "en-US")
148
+ * @returns Formatted adjustment string with sign
149
+ *
150
+ * @example
151
+ * formatPriceAdjustment(5.00, 'USD') // "+$5.00"
152
+ * formatPriceAdjustment(-3.50, 'GHS') // "-GH₵3.50"
153
+ * formatPriceAdjustment(0, 'EUR') // "€0.00"
154
+ */
155
+ declare function formatPriceAdjustment(amount: number, currency?: CurrencyCode, locale?: string): string;
156
+ /**
157
+ * Format a price compactly for large numbers
158
+ * Uses K/M/B suffixes for thousands, millions, billions
159
+ *
160
+ * @param amount - Price amount (number or string)
161
+ * @param currency - ISO 4217 currency code (default: "GHS")
162
+ * @param decimals - Decimal places for compact notation (default: 1)
163
+ * @returns Compact formatted price
164
+ *
165
+ * @example
166
+ * formatPriceCompact(999, 'USD') // "$999.00"
167
+ * formatPriceCompact(1500, 'GHS') // "GH₵1.5K"
168
+ * formatPriceCompact(2500000, 'USD') // "$2.5M"
169
+ * formatPriceCompact(1200000000, 'EUR') // "€1.2B"
170
+ */
171
+ declare function formatPriceCompact(amount: number | Money, currency?: CurrencyCode, decimals?: number): string;
172
+ /**
173
+ * Simple currency symbol + amount format
174
+ * Lighter alternative to formatPrice without Intl
175
+ *
176
+ * @param amount - Price amount (number or string)
177
+ * @param currency - ISO 4217 currency code (default: "GHS")
178
+ * @returns Simple formatted price
179
+ *
180
+ * @example
181
+ * formatMoney(29.99, 'USD') // "$29.99"
182
+ * formatMoney('15.00', 'GHS') // "GH₵15.00"
183
+ */
184
+ declare function formatMoney(amount: Money | number, currency?: CurrencyCode): string;
185
+ /**
186
+ * Parse a price string or number to a numeric value
187
+ * Handles various input formats gracefully
188
+ *
189
+ * @param value - Value to parse (string, number, or undefined)
190
+ * @returns Parsed numeric value, or 0 if invalid
191
+ *
192
+ * @example
193
+ * parsePrice('29.99') // 29.99
194
+ * parsePrice(29.99) // 29.99
195
+ * parsePrice('$29.99') // 29.99 (strips non-numeric prefix)
196
+ * parsePrice(undefined) // 0
197
+ * parsePrice('invalid') // 0
198
+ */
199
+ declare function parsePrice(value: Money | string | number | undefined | null): number;
200
+ /** Check whether tax info exists on the selected price payload. */
201
+ declare function hasTaxInfo(priceInfo: {
202
+ tax_info?: PricePathTaxInfo;
203
+ }): boolean;
204
+ /** Get tax amount from a selected price payload, defaulting to 0 when tax info is absent. */
205
+ declare function getTaxAmount(priceInfo: {
206
+ tax_info?: PricePathTaxInfo;
207
+ }): number;
208
+ /** Check whether the selected price is tax-inclusive. */
209
+ declare function isTaxInclusive(priceInfo: {
210
+ tax_info?: PricePathTaxInfo;
211
+ }): boolean;
212
+ /**
213
+ * Format a final price with tax annotation.
214
+ * Examples: "$10.50 (incl. tax)" or "$10.50 + $1.05 tax"
215
+ */
216
+ declare function formatPriceWithTax(priceInfo: {
217
+ final_price: Money;
218
+ tax_info?: PricePathTaxInfo;
219
+ }, currency?: CurrencyCode): string;
220
+ /**
221
+ * Get the display price from a product.
222
+ * Prefers quote-aware price_info, then plain price fields.
223
+ *
224
+ * @param product - Product with price data
225
+ * @returns The final price to display
226
+ *
227
+ * @example
228
+ * const price = getDisplayPrice(product);
229
+ * console.log(formatPrice(price, 'GHS')); // "GH₵29.99"
230
+ */
231
+ declare function getDisplayPrice(product: ProductWithPrice): number;
232
+ /**
233
+ * Get the base price from a product (before markup/discount)
234
+ *
235
+ * @param product - Product with price data
236
+ * @returns The base price before adjustments
237
+ */
238
+ declare function getBasePrice(product: ProductWithPrice): number;
239
+ /**
240
+ * Check if a product is on sale (discounted)
241
+ *
242
+ * @param product - Product with price data
243
+ * @returns True if the final price is less than the base price
244
+ *
245
+ * @example
246
+ * if (isOnSale(product)) {
247
+ * return <Badge>Sale!</Badge>;
248
+ * }
249
+ */
250
+ declare function isOnSale(product: ProductWithPrice): boolean;
251
+ /**
252
+ * Get the discount percentage for a product on sale
253
+ *
254
+ * @param product - Product with price data
255
+ * @returns Discount percentage (0-100), or 0 if not on sale
256
+ *
257
+ * @example
258
+ * const discount = getDiscountPercentage(product);
259
+ * if (discount > 0) {
260
+ * return <Badge>{discount}% OFF</Badge>;
261
+ * }
262
+ */
263
+ declare function getDiscountPercentage(product: ProductWithPrice): number;
264
+ /**
265
+ * Get the markup percentage for a product
266
+ *
267
+ * @param product - Product with price data
268
+ * @returns Markup percentage, or 0 if no markup
269
+ */
270
+ declare function getMarkupPercentage(product: ProductWithPrice): number;
271
+ /**
272
+ * Get the currency for a product
273
+ *
274
+ * @param product - Product with price data
275
+ * @returns Currency code (default: "GHS")
276
+ */
277
+ declare function getProductCurrency(product: ProductWithPrice): CurrencyCode;
278
+ /**
279
+ * Format a product's display price
280
+ * Convenience function combining getDisplayPrice and formatPrice
281
+ *
282
+ * @param product - Product with price data
283
+ * @param locale - BCP 47 locale string (default: "en-US")
284
+ * @returns Formatted price string
285
+ *
286
+ * @example
287
+ * <span>{formatProductPrice(product)}</span> // "GH₵29.99"
288
+ */
289
+ declare function formatProductPrice(product: ProductWithPrice, locale?: string): string;
290
+
291
+ /**
292
+ * Categorize payment errors into user-friendly messages
293
+ */
294
+ declare function categorizePaymentError(error: Error, errorCode?: string): PaymentErrorDetails;
295
+ /**
296
+ * Normalize payment response from different formats into a standard PaymentResponse
297
+ */
298
+ declare function normalizePaymentResponse(response: unknown): PaymentResponse;
299
+ declare function isPaymentStatusSuccess(status: string | undefined): boolean;
300
+ declare function isPaymentStatusFailure(status: string | undefined): boolean;
301
+ declare function isPaymentStatusRequiresAction(status: string | undefined): boolean;
302
+ /**
303
+ * Normalize payment status response into a standard format
304
+ */
305
+ declare function normalizeStatusResponse(response: unknown): PaymentStatusResponse;
306
+ /** Mobile money provider display names */
307
+ declare const MOBILE_MONEY_PROVIDERS: {
308
+ readonly mtn: {
309
+ readonly name: "MTN Mobile Money";
310
+ readonly prefix: readonly ["024", "054", "055", "059"];
311
+ };
312
+ readonly vodafone: {
313
+ readonly name: "Vodafone Cash";
314
+ readonly prefix: readonly ["020", "050"];
315
+ };
316
+ readonly airtel: {
317
+ readonly name: "AirtelTigo Money";
318
+ readonly prefix: readonly ["027", "057", "026", "056"];
319
+ };
320
+ };
321
+ /**
322
+ * Detect mobile money provider from phone number
323
+ */
324
+ declare function detectMobileMoneyProvider(phoneNumber: string): "mtn" | "vodafone" | "airtel" | null;
325
+
326
+ export { type ProductWithPrice as A, type FormatCompactOptions as B, CURRENCY_SYMBOLS as C, type FormatPriceOptions as F, MOBILE_MONEY_PROVIDERS as M, type PriceInfo as P, type TaxComponent as T, formatPriceAdjustment as a, formatPriceCompact as b, formatMoney as c, formatNumberCompact as d, formatProductPrice as e, formatPrice as f, getTaxAmount as g, hasTaxInfo as h, isTaxInclusive as i, formatPriceWithTax as j, getCurrencySymbol as k, getDisplayPrice as l, getBasePrice as m, isOnSale as n, getDiscountPercentage as o, parsePrice as p, getMarkupPercentage as q, getProductCurrency as r, categorizePaymentError as s, normalizePaymentResponse as t, normalizeStatusResponse as u, isPaymentStatusFailure as v, isPaymentStatusRequiresAction as w, isPaymentStatusSuccess as x, detectMobileMoneyProvider as y, type TaxInfo as z };