@cimplify/sdk 0.6.10 → 0.6.11

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 { C as CurrencyCode, M as Money, w as PaymentErrorDetails, u as PaymentResponse, v as PaymentStatusResponse } from './payment-Cu75tmUc.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
+ interface TaxComponent {
13
+ /** Tax component name */
14
+ name: string;
15
+ /** Tax rate as percentage (e.g., 15.0 for 15%) */
16
+ rate: number;
17
+ }
18
+ /**
19
+ * Complete tax information from a pricing response
20
+ */
21
+ interface TaxInfo {
22
+ /** Total tax rate as percentage */
23
+ taxRate: number;
24
+ /** Calculated tax amount */
25
+ taxAmount: number;
26
+ /** Whether tax is included in the displayed price */
27
+ isInclusive: boolean;
28
+ /** Individual tax components that make up the total */
29
+ components: TaxComponent[];
30
+ }
31
+ /**
32
+ * Price information in snake_case format (as returned from backend)
33
+ * Used by components that work with raw API responses
34
+ */
35
+ interface PriceInfo {
36
+ /** Original price before markup/discount */
37
+ base_price: number;
38
+ /** Final price after all adjustments */
39
+ final_price: number;
40
+ /** Markup percentage if applicable */
41
+ markup_percentage?: number;
42
+ /** Markup amount if applicable */
43
+ markup_amount?: number;
44
+ /** Currency code (e.g., "GHS", "USD") */
45
+ currency?: CurrencyCode;
46
+ /** Tax information */
47
+ tax_info?: TaxInfo;
48
+ /** Decision path showing pricing adjustments */
49
+ decision_path?: string;
50
+ }
51
+ /**
52
+ * Minimal product shape for price utilities.
53
+ * Uses quote-aware `price_info` and plain numeric fallback fields.
54
+ */
55
+ interface ProductWithPrice {
56
+ /** Pre-parsed price info from backend */
57
+ price_info?: PriceInfo;
58
+ /** Final computed price in plain field form (if provided by API) */
59
+ final_price?: number | string | null;
60
+ /** Base/original price in plain field form */
61
+ base_price?: number | string | null;
62
+ /** Default/indicative price in plain field form */
63
+ default_price?: number | string | null;
64
+ /** Currency in plain field form */
65
+ currency?: CurrencyCode | null;
66
+ }
67
+ /**
68
+ * Options for price formatting functions
69
+ */
70
+ interface FormatPriceOptions {
71
+ /** Currency code (default: "GHS") */
72
+ currency?: CurrencyCode;
73
+ /** Locale for Intl.NumberFormat (default: "en-US") */
74
+ locale?: string;
75
+ /** Minimum fraction digits (default: 2) */
76
+ minimumFractionDigits?: number;
77
+ /** Maximum fraction digits (default: 2) */
78
+ maximumFractionDigits?: number;
79
+ }
80
+ /**
81
+ * Options for compact price formatting
82
+ */
83
+ interface FormatCompactOptions {
84
+ /** Currency code (default: "GHS") */
85
+ currency?: CurrencyCode;
86
+ /** Number of decimal places for compact notation (default: 1) */
87
+ decimals?: number;
88
+ }
89
+
90
+ /**
91
+ * Price Utilities
92
+ *
93
+ * Comprehensive utilities for parsing, formatting, and displaying prices.
94
+ * Handles quote-aware pricing fields, currency formatting, and product price helpers.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * import {
99
+ * formatPrice,
100
+ * formatPriceCompact,
101
+ * isOnSale,
102
+ * getDiscountPercentage
103
+ * } from '@cimplify/sdk';
104
+ *
105
+ * // Format prices
106
+ * formatPrice(29.99, 'USD'); // "$29.99"
107
+ * formatPrice(29.99, 'GHS'); // "GH₵29.99"
108
+ * formatPriceCompact(1500000, 'USD'); // "$1.5M"
109
+ *
110
+ * // Check for discounts
111
+ * if (isOnSale(product)) {
112
+ * console.log(`${getDiscountPercentage(product)}% off!`);
113
+ * }
114
+ * ```
115
+ */
116
+
117
+ /**
118
+ * Currency code to symbol mapping
119
+ * Includes major world currencies and African currencies
120
+ */
121
+ declare const CURRENCY_SYMBOLS: Record<string, string>;
122
+ /**
123
+ * Get currency symbol for a currency code
124
+ * @param currencyCode - ISO 4217 currency code (e.g., "USD", "GHS")
125
+ * @returns Currency symbol or the code itself if not found
126
+ *
127
+ * @example
128
+ * getCurrencySymbol('USD') // "$"
129
+ * getCurrencySymbol('GHS') // "GH₵"
130
+ * getCurrencySymbol('XYZ') // "XYZ"
131
+ */
132
+ declare function getCurrencySymbol(currencyCode: CurrencyCode): string;
133
+ /**
134
+ * Format a number compactly with K/M/B suffixes
135
+ * @param value - Number to format
136
+ * @param decimals - Decimal places (default: 1)
137
+ * @returns Compact string representation
138
+ *
139
+ * @example
140
+ * formatNumberCompact(1234) // "1.2K"
141
+ * formatNumberCompact(1500000) // "1.5M"
142
+ * formatNumberCompact(2500000000) // "2.5B"
143
+ */
144
+ declare function formatNumberCompact(value: number, decimals?: number): string;
145
+ /**
146
+ * Format a price with locale-aware currency formatting
147
+ * Uses Intl.NumberFormat for proper localization
148
+ *
149
+ * @param amount - Price amount (number or string)
150
+ * @param currency - ISO 4217 currency code (default: "GHS")
151
+ * @param locale - BCP 47 locale string (default: "en-US")
152
+ * @returns Formatted price string
153
+ *
154
+ * @example
155
+ * formatPrice(29.99, 'USD') // "$29.99"
156
+ * formatPrice(29.99, 'GHS') // "GH₵29.99"
157
+ * formatPrice('29.99', 'EUR') // "€29.99"
158
+ * formatPrice(1234.56, 'USD', 'de-DE') // "1.234,56 $"
159
+ */
160
+ declare function formatPrice(amount: number | Money, currency?: CurrencyCode, locale?: string): string;
161
+ /**
162
+ * Format a price with +/- sign for adjustments
163
+ * Useful for showing price changes, modifiers, or discounts
164
+ *
165
+ * @param amount - Adjustment amount (positive or negative)
166
+ * @param currency - ISO 4217 currency code (default: "GHS")
167
+ * @param locale - BCP 47 locale string (default: "en-US")
168
+ * @returns Formatted adjustment string with sign
169
+ *
170
+ * @example
171
+ * formatPriceAdjustment(5.00, 'USD') // "+$5.00"
172
+ * formatPriceAdjustment(-3.50, 'GHS') // "-GH₵3.50"
173
+ * formatPriceAdjustment(0, 'EUR') // "€0.00"
174
+ */
175
+ declare function formatPriceAdjustment(amount: number, currency?: CurrencyCode, locale?: string): string;
176
+ /**
177
+ * Format a price compactly for large numbers
178
+ * Uses K/M/B suffixes for thousands, millions, billions
179
+ *
180
+ * @param amount - Price amount (number or string)
181
+ * @param currency - ISO 4217 currency code (default: "GHS")
182
+ * @param decimals - Decimal places for compact notation (default: 1)
183
+ * @returns Compact formatted price
184
+ *
185
+ * @example
186
+ * formatPriceCompact(999, 'USD') // "$999.00"
187
+ * formatPriceCompact(1500, 'GHS') // "GH₵1.5K"
188
+ * formatPriceCompact(2500000, 'USD') // "$2.5M"
189
+ * formatPriceCompact(1200000000, 'EUR') // "€1.2B"
190
+ */
191
+ declare function formatPriceCompact(amount: number | Money, currency?: CurrencyCode, decimals?: number): string;
192
+ /**
193
+ * Simple currency symbol + amount format
194
+ * Lighter alternative to formatPrice without Intl
195
+ *
196
+ * @param amount - Price amount (number or string)
197
+ * @param currency - ISO 4217 currency code (default: "GHS")
198
+ * @returns Simple formatted price
199
+ *
200
+ * @example
201
+ * formatMoney(29.99, 'USD') // "$29.99"
202
+ * formatMoney('15.00', 'GHS') // "GH₵15.00"
203
+ */
204
+ declare function formatMoney(amount: Money | number, currency?: CurrencyCode): string;
205
+ /**
206
+ * Parse a price string or number to a numeric value
207
+ * Handles various input formats gracefully
208
+ *
209
+ * @param value - Value to parse (string, number, or undefined)
210
+ * @returns Parsed numeric value, or 0 if invalid
211
+ *
212
+ * @example
213
+ * parsePrice('29.99') // 29.99
214
+ * parsePrice(29.99) // 29.99
215
+ * parsePrice('$29.99') // 29.99 (strips non-numeric prefix)
216
+ * parsePrice(undefined) // 0
217
+ * parsePrice('invalid') // 0
218
+ */
219
+ declare function parsePrice(value: Money | string | number | undefined | null): number;
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 { 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, getCurrencySymbol as g, getDisplayPrice as h, getBasePrice as i, isOnSale as j, getDiscountPercentage as k, getMarkupPercentage as l, getProductCurrency as m, categorizePaymentError as n, normalizePaymentResponse as o, parsePrice as p, normalizeStatusResponse as q, isPaymentStatusFailure as r, isPaymentStatusRequiresAction as s, isPaymentStatusSuccess as t, detectMobileMoneyProvider as u, type TaxInfo as v, type ProductWithPrice as w, type FormatCompactOptions as x };
@@ -0,0 +1,326 @@
1
+ import { C as CurrencyCode, M as Money, w as PaymentErrorDetails, u as PaymentResponse, v as PaymentStatusResponse } from './payment-Cu75tmUc.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
+ interface TaxComponent {
13
+ /** Tax component name */
14
+ name: string;
15
+ /** Tax rate as percentage (e.g., 15.0 for 15%) */
16
+ rate: number;
17
+ }
18
+ /**
19
+ * Complete tax information from a pricing response
20
+ */
21
+ interface TaxInfo {
22
+ /** Total tax rate as percentage */
23
+ taxRate: number;
24
+ /** Calculated tax amount */
25
+ taxAmount: number;
26
+ /** Whether tax is included in the displayed price */
27
+ isInclusive: boolean;
28
+ /** Individual tax components that make up the total */
29
+ components: TaxComponent[];
30
+ }
31
+ /**
32
+ * Price information in snake_case format (as returned from backend)
33
+ * Used by components that work with raw API responses
34
+ */
35
+ interface PriceInfo {
36
+ /** Original price before markup/discount */
37
+ base_price: number;
38
+ /** Final price after all adjustments */
39
+ final_price: number;
40
+ /** Markup percentage if applicable */
41
+ markup_percentage?: number;
42
+ /** Markup amount if applicable */
43
+ markup_amount?: number;
44
+ /** Currency code (e.g., "GHS", "USD") */
45
+ currency?: CurrencyCode;
46
+ /** Tax information */
47
+ tax_info?: TaxInfo;
48
+ /** Decision path showing pricing adjustments */
49
+ decision_path?: string;
50
+ }
51
+ /**
52
+ * Minimal product shape for price utilities.
53
+ * Uses quote-aware `price_info` and plain numeric fallback fields.
54
+ */
55
+ interface ProductWithPrice {
56
+ /** Pre-parsed price info from backend */
57
+ price_info?: PriceInfo;
58
+ /** Final computed price in plain field form (if provided by API) */
59
+ final_price?: number | string | null;
60
+ /** Base/original price in plain field form */
61
+ base_price?: number | string | null;
62
+ /** Default/indicative price in plain field form */
63
+ default_price?: number | string | null;
64
+ /** Currency in plain field form */
65
+ currency?: CurrencyCode | null;
66
+ }
67
+ /**
68
+ * Options for price formatting functions
69
+ */
70
+ interface FormatPriceOptions {
71
+ /** Currency code (default: "GHS") */
72
+ currency?: CurrencyCode;
73
+ /** Locale for Intl.NumberFormat (default: "en-US") */
74
+ locale?: string;
75
+ /** Minimum fraction digits (default: 2) */
76
+ minimumFractionDigits?: number;
77
+ /** Maximum fraction digits (default: 2) */
78
+ maximumFractionDigits?: number;
79
+ }
80
+ /**
81
+ * Options for compact price formatting
82
+ */
83
+ interface FormatCompactOptions {
84
+ /** Currency code (default: "GHS") */
85
+ currency?: CurrencyCode;
86
+ /** Number of decimal places for compact notation (default: 1) */
87
+ decimals?: number;
88
+ }
89
+
90
+ /**
91
+ * Price Utilities
92
+ *
93
+ * Comprehensive utilities for parsing, formatting, and displaying prices.
94
+ * Handles quote-aware pricing fields, currency formatting, and product price helpers.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * import {
99
+ * formatPrice,
100
+ * formatPriceCompact,
101
+ * isOnSale,
102
+ * getDiscountPercentage
103
+ * } from '@cimplify/sdk';
104
+ *
105
+ * // Format prices
106
+ * formatPrice(29.99, 'USD'); // "$29.99"
107
+ * formatPrice(29.99, 'GHS'); // "GH₵29.99"
108
+ * formatPriceCompact(1500000, 'USD'); // "$1.5M"
109
+ *
110
+ * // Check for discounts
111
+ * if (isOnSale(product)) {
112
+ * console.log(`${getDiscountPercentage(product)}% off!`);
113
+ * }
114
+ * ```
115
+ */
116
+
117
+ /**
118
+ * Currency code to symbol mapping
119
+ * Includes major world currencies and African currencies
120
+ */
121
+ declare const CURRENCY_SYMBOLS: Record<string, string>;
122
+ /**
123
+ * Get currency symbol for a currency code
124
+ * @param currencyCode - ISO 4217 currency code (e.g., "USD", "GHS")
125
+ * @returns Currency symbol or the code itself if not found
126
+ *
127
+ * @example
128
+ * getCurrencySymbol('USD') // "$"
129
+ * getCurrencySymbol('GHS') // "GH₵"
130
+ * getCurrencySymbol('XYZ') // "XYZ"
131
+ */
132
+ declare function getCurrencySymbol(currencyCode: CurrencyCode): string;
133
+ /**
134
+ * Format a number compactly with K/M/B suffixes
135
+ * @param value - Number to format
136
+ * @param decimals - Decimal places (default: 1)
137
+ * @returns Compact string representation
138
+ *
139
+ * @example
140
+ * formatNumberCompact(1234) // "1.2K"
141
+ * formatNumberCompact(1500000) // "1.5M"
142
+ * formatNumberCompact(2500000000) // "2.5B"
143
+ */
144
+ declare function formatNumberCompact(value: number, decimals?: number): string;
145
+ /**
146
+ * Format a price with locale-aware currency formatting
147
+ * Uses Intl.NumberFormat for proper localization
148
+ *
149
+ * @param amount - Price amount (number or string)
150
+ * @param currency - ISO 4217 currency code (default: "GHS")
151
+ * @param locale - BCP 47 locale string (default: "en-US")
152
+ * @returns Formatted price string
153
+ *
154
+ * @example
155
+ * formatPrice(29.99, 'USD') // "$29.99"
156
+ * formatPrice(29.99, 'GHS') // "GH₵29.99"
157
+ * formatPrice('29.99', 'EUR') // "€29.99"
158
+ * formatPrice(1234.56, 'USD', 'de-DE') // "1.234,56 $"
159
+ */
160
+ declare function formatPrice(amount: number | Money, currency?: CurrencyCode, locale?: string): string;
161
+ /**
162
+ * Format a price with +/- sign for adjustments
163
+ * Useful for showing price changes, modifiers, or discounts
164
+ *
165
+ * @param amount - Adjustment amount (positive or negative)
166
+ * @param currency - ISO 4217 currency code (default: "GHS")
167
+ * @param locale - BCP 47 locale string (default: "en-US")
168
+ * @returns Formatted adjustment string with sign
169
+ *
170
+ * @example
171
+ * formatPriceAdjustment(5.00, 'USD') // "+$5.00"
172
+ * formatPriceAdjustment(-3.50, 'GHS') // "-GH₵3.50"
173
+ * formatPriceAdjustment(0, 'EUR') // "€0.00"
174
+ */
175
+ declare function formatPriceAdjustment(amount: number, currency?: CurrencyCode, locale?: string): string;
176
+ /**
177
+ * Format a price compactly for large numbers
178
+ * Uses K/M/B suffixes for thousands, millions, billions
179
+ *
180
+ * @param amount - Price amount (number or string)
181
+ * @param currency - ISO 4217 currency code (default: "GHS")
182
+ * @param decimals - Decimal places for compact notation (default: 1)
183
+ * @returns Compact formatted price
184
+ *
185
+ * @example
186
+ * formatPriceCompact(999, 'USD') // "$999.00"
187
+ * formatPriceCompact(1500, 'GHS') // "GH₵1.5K"
188
+ * formatPriceCompact(2500000, 'USD') // "$2.5M"
189
+ * formatPriceCompact(1200000000, 'EUR') // "€1.2B"
190
+ */
191
+ declare function formatPriceCompact(amount: number | Money, currency?: CurrencyCode, decimals?: number): string;
192
+ /**
193
+ * Simple currency symbol + amount format
194
+ * Lighter alternative to formatPrice without Intl
195
+ *
196
+ * @param amount - Price amount (number or string)
197
+ * @param currency - ISO 4217 currency code (default: "GHS")
198
+ * @returns Simple formatted price
199
+ *
200
+ * @example
201
+ * formatMoney(29.99, 'USD') // "$29.99"
202
+ * formatMoney('15.00', 'GHS') // "GH₵15.00"
203
+ */
204
+ declare function formatMoney(amount: Money | number, currency?: CurrencyCode): string;
205
+ /**
206
+ * Parse a price string or number to a numeric value
207
+ * Handles various input formats gracefully
208
+ *
209
+ * @param value - Value to parse (string, number, or undefined)
210
+ * @returns Parsed numeric value, or 0 if invalid
211
+ *
212
+ * @example
213
+ * parsePrice('29.99') // 29.99
214
+ * parsePrice(29.99) // 29.99
215
+ * parsePrice('$29.99') // 29.99 (strips non-numeric prefix)
216
+ * parsePrice(undefined) // 0
217
+ * parsePrice('invalid') // 0
218
+ */
219
+ declare function parsePrice(value: Money | string | number | undefined | null): number;
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 { 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, getCurrencySymbol as g, getDisplayPrice as h, getBasePrice as i, isOnSale as j, getDiscountPercentage as k, getMarkupPercentage as l, getProductCurrency as m, categorizePaymentError as n, normalizePaymentResponse as o, parsePrice as p, normalizeStatusResponse as q, isPaymentStatusFailure as r, isPaymentStatusRequiresAction as s, isPaymentStatusSuccess as t, detectMobileMoneyProvider as u, type TaxInfo as v, type ProductWithPrice as w, type FormatCompactOptions as x };