@cimplify/sdk 0.6.6 → 0.6.8

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.
@@ -1,4 +1,4 @@
1
- import { M as Money, c as CimplifyError, h as AuthorizationType, k as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, n as PaymentStatusResponse } from './payment-D-u3asA8.mjs';
1
+ import { M as Money, C as CurrencyCode, h as CimplifyError, q as AuthorizationType, s as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, v as PaymentStatusResponse } from './payment-Cu75tmUc.js';
2
2
 
3
3
  /**
4
4
  * Observability hooks for monitoring SDK behavior.
@@ -50,6 +50,8 @@ interface RequestSuccessEvent extends RequestContext {
50
50
  interface RequestErrorEvent extends RequestContext {
51
51
  /** The error that occurred */
52
52
  error: Error;
53
+ /** HTTP status code (when available) */
54
+ status?: number;
53
55
  /** Duration in milliseconds */
54
56
  durationMs: number;
55
57
  /** Number of retries attempted before giving up */
@@ -84,7 +86,7 @@ interface ObservabilityHooks {
84
86
  onRequestStart?: (event: RequestStartEvent) => void;
85
87
  /** Called when a request completes successfully */
86
88
  onRequestSuccess?: (event: RequestSuccessEvent) => void;
87
- /** Called when a request fails (after all retries exhausted) */
89
+ /** Called when a request fails (4xx/5xx responses or network errors after retries) */
88
90
  onRequestError?: (event: RequestErrorEvent) => void;
89
91
  /** Called before each retry attempt */
90
92
  onRetry?: (event: RetryEvent) => void;
@@ -152,7 +154,7 @@ interface Product {
152
154
  access_duration_days?: number;
153
155
  code_type?: string;
154
156
  code_value?: Money;
155
- code_currency?: string;
157
+ code_currency?: CurrencyCode;
156
158
  duration_minutes?: number;
157
159
  preparation_time_minutes?: number;
158
160
  staff_required_count?: number;
@@ -613,7 +615,7 @@ interface ChosenPrice {
613
615
  markup_amount: Money;
614
616
  markup_discount_percentage: Money;
615
617
  markup_discount_amount: Money;
616
- currency?: string;
618
+ currency?: CurrencyCode;
617
619
  custom_fields?: Record<string, unknown>;
618
620
  decision_path?: PriceDecisionPath;
619
621
  tax_info?: PricePathTaxInfo;
@@ -758,7 +760,7 @@ interface Cart {
758
760
  applied_discount_ids: string[];
759
761
  applied_discount_codes: string[];
760
762
  discount_details?: DiscountDetails;
761
- currency: string;
763
+ currency: CurrencyCode;
762
764
  customer_name?: string;
763
765
  customer_email?: string;
764
766
  customer_phone?: string;
@@ -813,7 +815,7 @@ interface DisplayCart {
813
815
  total_items: number;
814
816
  tax_rate?: Money;
815
817
  service_charge_rate?: Money;
816
- currency: string;
818
+ currency: CurrencyCode;
817
819
  channel: string;
818
820
  status: string;
819
821
  business_name: string;
@@ -888,7 +890,7 @@ interface UICartPricing {
888
890
  total_price: Money;
889
891
  tax_rate?: Money;
890
892
  service_charge_rate?: Money;
891
- currency: string;
893
+ currency: CurrencyCode;
892
894
  }
893
895
  interface AddOnOptionDetails {
894
896
  id: string;
@@ -1015,7 +1017,7 @@ interface CartSummary {
1015
1017
  discount_amount: Money;
1016
1018
  tax_amount: Money;
1017
1019
  total: Money;
1018
- currency: string;
1020
+ currency: CurrencyCode;
1019
1021
  }
1020
1022
 
1021
1023
  /**
@@ -1442,7 +1444,7 @@ interface Order {
1442
1444
  service_charge?: Money;
1443
1445
  tax?: Money;
1444
1446
  price_info: ChosenPrice;
1445
- currency: string;
1447
+ currency: CurrencyCode;
1446
1448
  bill_token?: string;
1447
1449
  order_group_id?: string;
1448
1450
  paid_via_group: boolean;
@@ -1490,7 +1492,7 @@ interface OrderGroup {
1490
1492
  payment_status: OrderGroupPaymentState;
1491
1493
  split_method?: string;
1492
1494
  max_orders?: number;
1493
- currency?: string;
1495
+ currency?: CurrencyCode;
1494
1496
  amount_to_pay: AmountToPay;
1495
1497
  metadata?: Record<string, unknown>;
1496
1498
  }
@@ -2004,7 +2006,7 @@ interface CheckoutFormData {
2004
2006
  idempotency_key?: string;
2005
2007
  /** Optional metadata passed through to the payment provider (e.g. success_url, cancel_url) */
2006
2008
  metadata?: Record<string, unknown>;
2007
- pay_currency?: string;
2009
+ pay_currency?: CurrencyCode;
2008
2010
  fx_quote_id?: string;
2009
2011
  }
2010
2012
  interface CheckoutResult {
@@ -2020,10 +2022,10 @@ interface CheckoutResult {
2020
2022
  client_secret?: string;
2021
2023
  public_key?: string;
2022
2024
  fx?: {
2023
- base_currency: string;
2024
- base_amount: number;
2025
- pay_currency: string;
2026
- pay_amount: number;
2025
+ base_currency: CurrencyCode;
2026
+ base_amount: Money;
2027
+ pay_currency: CurrencyCode;
2028
+ pay_amount: Money;
2027
2029
  rate: number;
2028
2030
  quote_id: string;
2029
2031
  };
@@ -2046,7 +2048,7 @@ interface ProcessCheckoutOptions {
2046
2048
  scheduled_time?: string;
2047
2049
  tip_amount?: number;
2048
2050
  enroll_in_link?: boolean;
2049
- pay_currency?: string;
2051
+ pay_currency?: CurrencyCode;
2050
2052
  timeout_ms?: number;
2051
2053
  on_status_change?: (status: CheckoutStatus, context: CheckoutStatusContext) => void;
2052
2054
  }
@@ -2057,12 +2059,14 @@ interface ProcessCheckoutResult {
2057
2059
  order_number: string;
2058
2060
  status: string;
2059
2061
  total: string;
2060
- currency: string;
2062
+ currency: CurrencyCode;
2061
2063
  };
2062
2064
  error?: {
2063
2065
  code: string;
2064
2066
  message: string;
2065
2067
  recoverable: boolean;
2068
+ docs_url?: string;
2069
+ suggestion?: string;
2066
2070
  };
2067
2071
  enrolled_in_link?: boolean;
2068
2072
  }
@@ -2216,7 +2220,7 @@ interface Business {
2216
2220
  handle: string;
2217
2221
  business_type: BusinessType;
2218
2222
  email: string;
2219
- default_currency: string;
2223
+ default_currency: CurrencyCode;
2220
2224
  default_phone?: string;
2221
2225
  default_address?: string;
2222
2226
  default_offers_table_service: boolean;
@@ -2254,7 +2258,7 @@ interface Location {
2254
2258
  phone?: string;
2255
2259
  address?: string;
2256
2260
  service_charge_rate?: number;
2257
- currency: string;
2261
+ currency: CurrencyCode;
2258
2262
  capacity: number;
2259
2263
  status: string;
2260
2264
  enabled_payment_types?: string[];
@@ -2321,7 +2325,7 @@ interface StorefrontBootstrap {
2321
2325
  location?: Location;
2322
2326
  locations: Location[];
2323
2327
  categories: CategoryInfo[];
2324
- currency: string;
2328
+ currency: CurrencyCode;
2325
2329
  is_open: boolean;
2326
2330
  accepts_orders: boolean;
2327
2331
  time_profiles?: LocationTimeProfile[];
@@ -2651,7 +2655,7 @@ interface Service {
2651
2655
  buffer_after_minutes: number;
2652
2656
  max_participants: number;
2653
2657
  price: Money;
2654
- currency: string;
2658
+ currency: CurrencyCode;
2655
2659
  requires_staff: boolean;
2656
2660
  is_active: boolean;
2657
2661
  image_url?: string;
@@ -2871,24 +2875,24 @@ declare class LiteService {
2871
2875
  }
2872
2876
 
2873
2877
  interface FxQuoteRequest {
2874
- from: string;
2875
- to: string;
2876
- amount: number;
2878
+ from: CurrencyCode;
2879
+ to: CurrencyCode;
2880
+ amount: Money;
2877
2881
  }
2878
2882
  interface FxQuote {
2879
2883
  id: string;
2880
- base_currency: string;
2881
- pay_currency: string;
2884
+ base_currency: CurrencyCode;
2885
+ pay_currency: CurrencyCode;
2882
2886
  rate: number;
2883
2887
  inverse_rate: number;
2884
- base_amount: number;
2885
- converted_amount: number;
2888
+ base_amount: Money;
2889
+ converted_amount: Money;
2886
2890
  quoted_at: string;
2887
2891
  valid_until: string;
2888
2892
  }
2889
2893
  interface FxRateResponse {
2890
- from: string;
2891
- to: string;
2894
+ from: CurrencyCode;
2895
+ to: CurrencyCode;
2892
2896
  rate: number;
2893
2897
  inverse_rate: number;
2894
2898
  quoted_at: string;
@@ -2898,7 +2902,7 @@ interface FxRateResponse {
2898
2902
  declare class FxService {
2899
2903
  private client;
2900
2904
  constructor(client: CimplifyClient);
2901
- getRate(from: string, to: string): Promise<Result<FxRateResponse, CimplifyError>>;
2905
+ getRate(from: CurrencyCode, to: CurrencyCode): Promise<Result<FxRateResponse, CimplifyError>>;
2902
2906
  lockQuote(request: FxQuoteRequest): Promise<Result<FxQuote, CimplifyError>>;
2903
2907
  }
2904
2908
 
@@ -2945,7 +2949,7 @@ interface ElementOptions {
2945
2949
  mode?: "shipping" | "billing";
2946
2950
  prefillEmail?: string;
2947
2951
  amount?: number;
2948
- currency?: string;
2952
+ currency?: CurrencyCode;
2949
2953
  }
2950
2954
  interface AddressInfo {
2951
2955
  id?: string;
@@ -3026,7 +3030,7 @@ type ParentToIframeMessage = {
3026
3030
  notes?: string;
3027
3031
  scheduled_time?: string;
3028
3032
  tip_amount?: number;
3029
- pay_currency?: string;
3033
+ pay_currency?: CurrencyCode;
3030
3034
  enroll_in_link?: boolean;
3031
3035
  address?: AddressInfo;
3032
3036
  customer: ElementsCustomerInfo;
@@ -3082,7 +3086,7 @@ type IframeToParentMessage = {
3082
3086
  order_number: string;
3083
3087
  status: string;
3084
3088
  total: string;
3085
- currency: string;
3089
+ currency: CurrencyCode;
3086
3090
  };
3087
3091
  error?: {
3088
3092
  code: string;
@@ -3117,6 +3121,7 @@ declare class CimplifyElements {
3117
3121
  private paymentData;
3118
3122
  private checkoutInProgress;
3119
3123
  private activeCheckoutAbort;
3124
+ private hasWarnedMissingAuthElement;
3120
3125
  private boundHandleMessage;
3121
3126
  private businessIdResolvePromise;
3122
3127
  constructor(client: CimplifyClient, businessId?: string, options?: ElementsOptions);
@@ -3208,6 +3213,7 @@ declare class CimplifyClient {
3208
3213
  setSessionToken(token: string | null): void;
3209
3214
  getAccessToken(): string | null;
3210
3215
  getPublicKey(): string;
3216
+ isTestMode(): boolean;
3211
3217
  setAccessToken(token: string | null): void;
3212
3218
  clearSession(): void;
3213
3219
  /** Set the active location/branch for all subsequent requests */
@@ -1,4 +1,4 @@
1
- import { M as Money, c as CimplifyError, h as AuthorizationType, k as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, n as PaymentStatusResponse } from './payment-D-u3asA8.js';
1
+ import { M as Money, C as CurrencyCode, h as CimplifyError, q as AuthorizationType, s as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, v as PaymentStatusResponse } from './payment-Cu75tmUc.mjs';
2
2
 
3
3
  /**
4
4
  * Observability hooks for monitoring SDK behavior.
@@ -50,6 +50,8 @@ interface RequestSuccessEvent extends RequestContext {
50
50
  interface RequestErrorEvent extends RequestContext {
51
51
  /** The error that occurred */
52
52
  error: Error;
53
+ /** HTTP status code (when available) */
54
+ status?: number;
53
55
  /** Duration in milliseconds */
54
56
  durationMs: number;
55
57
  /** Number of retries attempted before giving up */
@@ -84,7 +86,7 @@ interface ObservabilityHooks {
84
86
  onRequestStart?: (event: RequestStartEvent) => void;
85
87
  /** Called when a request completes successfully */
86
88
  onRequestSuccess?: (event: RequestSuccessEvent) => void;
87
- /** Called when a request fails (after all retries exhausted) */
89
+ /** Called when a request fails (4xx/5xx responses or network errors after retries) */
88
90
  onRequestError?: (event: RequestErrorEvent) => void;
89
91
  /** Called before each retry attempt */
90
92
  onRetry?: (event: RetryEvent) => void;
@@ -152,7 +154,7 @@ interface Product {
152
154
  access_duration_days?: number;
153
155
  code_type?: string;
154
156
  code_value?: Money;
155
- code_currency?: string;
157
+ code_currency?: CurrencyCode;
156
158
  duration_minutes?: number;
157
159
  preparation_time_minutes?: number;
158
160
  staff_required_count?: number;
@@ -613,7 +615,7 @@ interface ChosenPrice {
613
615
  markup_amount: Money;
614
616
  markup_discount_percentage: Money;
615
617
  markup_discount_amount: Money;
616
- currency?: string;
618
+ currency?: CurrencyCode;
617
619
  custom_fields?: Record<string, unknown>;
618
620
  decision_path?: PriceDecisionPath;
619
621
  tax_info?: PricePathTaxInfo;
@@ -758,7 +760,7 @@ interface Cart {
758
760
  applied_discount_ids: string[];
759
761
  applied_discount_codes: string[];
760
762
  discount_details?: DiscountDetails;
761
- currency: string;
763
+ currency: CurrencyCode;
762
764
  customer_name?: string;
763
765
  customer_email?: string;
764
766
  customer_phone?: string;
@@ -813,7 +815,7 @@ interface DisplayCart {
813
815
  total_items: number;
814
816
  tax_rate?: Money;
815
817
  service_charge_rate?: Money;
816
- currency: string;
818
+ currency: CurrencyCode;
817
819
  channel: string;
818
820
  status: string;
819
821
  business_name: string;
@@ -888,7 +890,7 @@ interface UICartPricing {
888
890
  total_price: Money;
889
891
  tax_rate?: Money;
890
892
  service_charge_rate?: Money;
891
- currency: string;
893
+ currency: CurrencyCode;
892
894
  }
893
895
  interface AddOnOptionDetails {
894
896
  id: string;
@@ -1015,7 +1017,7 @@ interface CartSummary {
1015
1017
  discount_amount: Money;
1016
1018
  tax_amount: Money;
1017
1019
  total: Money;
1018
- currency: string;
1020
+ currency: CurrencyCode;
1019
1021
  }
1020
1022
 
1021
1023
  /**
@@ -1442,7 +1444,7 @@ interface Order {
1442
1444
  service_charge?: Money;
1443
1445
  tax?: Money;
1444
1446
  price_info: ChosenPrice;
1445
- currency: string;
1447
+ currency: CurrencyCode;
1446
1448
  bill_token?: string;
1447
1449
  order_group_id?: string;
1448
1450
  paid_via_group: boolean;
@@ -1490,7 +1492,7 @@ interface OrderGroup {
1490
1492
  payment_status: OrderGroupPaymentState;
1491
1493
  split_method?: string;
1492
1494
  max_orders?: number;
1493
- currency?: string;
1495
+ currency?: CurrencyCode;
1494
1496
  amount_to_pay: AmountToPay;
1495
1497
  metadata?: Record<string, unknown>;
1496
1498
  }
@@ -2004,7 +2006,7 @@ interface CheckoutFormData {
2004
2006
  idempotency_key?: string;
2005
2007
  /** Optional metadata passed through to the payment provider (e.g. success_url, cancel_url) */
2006
2008
  metadata?: Record<string, unknown>;
2007
- pay_currency?: string;
2009
+ pay_currency?: CurrencyCode;
2008
2010
  fx_quote_id?: string;
2009
2011
  }
2010
2012
  interface CheckoutResult {
@@ -2020,10 +2022,10 @@ interface CheckoutResult {
2020
2022
  client_secret?: string;
2021
2023
  public_key?: string;
2022
2024
  fx?: {
2023
- base_currency: string;
2024
- base_amount: number;
2025
- pay_currency: string;
2026
- pay_amount: number;
2025
+ base_currency: CurrencyCode;
2026
+ base_amount: Money;
2027
+ pay_currency: CurrencyCode;
2028
+ pay_amount: Money;
2027
2029
  rate: number;
2028
2030
  quote_id: string;
2029
2031
  };
@@ -2046,7 +2048,7 @@ interface ProcessCheckoutOptions {
2046
2048
  scheduled_time?: string;
2047
2049
  tip_amount?: number;
2048
2050
  enroll_in_link?: boolean;
2049
- pay_currency?: string;
2051
+ pay_currency?: CurrencyCode;
2050
2052
  timeout_ms?: number;
2051
2053
  on_status_change?: (status: CheckoutStatus, context: CheckoutStatusContext) => void;
2052
2054
  }
@@ -2057,12 +2059,14 @@ interface ProcessCheckoutResult {
2057
2059
  order_number: string;
2058
2060
  status: string;
2059
2061
  total: string;
2060
- currency: string;
2062
+ currency: CurrencyCode;
2061
2063
  };
2062
2064
  error?: {
2063
2065
  code: string;
2064
2066
  message: string;
2065
2067
  recoverable: boolean;
2068
+ docs_url?: string;
2069
+ suggestion?: string;
2066
2070
  };
2067
2071
  enrolled_in_link?: boolean;
2068
2072
  }
@@ -2216,7 +2220,7 @@ interface Business {
2216
2220
  handle: string;
2217
2221
  business_type: BusinessType;
2218
2222
  email: string;
2219
- default_currency: string;
2223
+ default_currency: CurrencyCode;
2220
2224
  default_phone?: string;
2221
2225
  default_address?: string;
2222
2226
  default_offers_table_service: boolean;
@@ -2254,7 +2258,7 @@ interface Location {
2254
2258
  phone?: string;
2255
2259
  address?: string;
2256
2260
  service_charge_rate?: number;
2257
- currency: string;
2261
+ currency: CurrencyCode;
2258
2262
  capacity: number;
2259
2263
  status: string;
2260
2264
  enabled_payment_types?: string[];
@@ -2321,7 +2325,7 @@ interface StorefrontBootstrap {
2321
2325
  location?: Location;
2322
2326
  locations: Location[];
2323
2327
  categories: CategoryInfo[];
2324
- currency: string;
2328
+ currency: CurrencyCode;
2325
2329
  is_open: boolean;
2326
2330
  accepts_orders: boolean;
2327
2331
  time_profiles?: LocationTimeProfile[];
@@ -2651,7 +2655,7 @@ interface Service {
2651
2655
  buffer_after_minutes: number;
2652
2656
  max_participants: number;
2653
2657
  price: Money;
2654
- currency: string;
2658
+ currency: CurrencyCode;
2655
2659
  requires_staff: boolean;
2656
2660
  is_active: boolean;
2657
2661
  image_url?: string;
@@ -2871,24 +2875,24 @@ declare class LiteService {
2871
2875
  }
2872
2876
 
2873
2877
  interface FxQuoteRequest {
2874
- from: string;
2875
- to: string;
2876
- amount: number;
2878
+ from: CurrencyCode;
2879
+ to: CurrencyCode;
2880
+ amount: Money;
2877
2881
  }
2878
2882
  interface FxQuote {
2879
2883
  id: string;
2880
- base_currency: string;
2881
- pay_currency: string;
2884
+ base_currency: CurrencyCode;
2885
+ pay_currency: CurrencyCode;
2882
2886
  rate: number;
2883
2887
  inverse_rate: number;
2884
- base_amount: number;
2885
- converted_amount: number;
2888
+ base_amount: Money;
2889
+ converted_amount: Money;
2886
2890
  quoted_at: string;
2887
2891
  valid_until: string;
2888
2892
  }
2889
2893
  interface FxRateResponse {
2890
- from: string;
2891
- to: string;
2894
+ from: CurrencyCode;
2895
+ to: CurrencyCode;
2892
2896
  rate: number;
2893
2897
  inverse_rate: number;
2894
2898
  quoted_at: string;
@@ -2898,7 +2902,7 @@ interface FxRateResponse {
2898
2902
  declare class FxService {
2899
2903
  private client;
2900
2904
  constructor(client: CimplifyClient);
2901
- getRate(from: string, to: string): Promise<Result<FxRateResponse, CimplifyError>>;
2905
+ getRate(from: CurrencyCode, to: CurrencyCode): Promise<Result<FxRateResponse, CimplifyError>>;
2902
2906
  lockQuote(request: FxQuoteRequest): Promise<Result<FxQuote, CimplifyError>>;
2903
2907
  }
2904
2908
 
@@ -2945,7 +2949,7 @@ interface ElementOptions {
2945
2949
  mode?: "shipping" | "billing";
2946
2950
  prefillEmail?: string;
2947
2951
  amount?: number;
2948
- currency?: string;
2952
+ currency?: CurrencyCode;
2949
2953
  }
2950
2954
  interface AddressInfo {
2951
2955
  id?: string;
@@ -3026,7 +3030,7 @@ type ParentToIframeMessage = {
3026
3030
  notes?: string;
3027
3031
  scheduled_time?: string;
3028
3032
  tip_amount?: number;
3029
- pay_currency?: string;
3033
+ pay_currency?: CurrencyCode;
3030
3034
  enroll_in_link?: boolean;
3031
3035
  address?: AddressInfo;
3032
3036
  customer: ElementsCustomerInfo;
@@ -3082,7 +3086,7 @@ type IframeToParentMessage = {
3082
3086
  order_number: string;
3083
3087
  status: string;
3084
3088
  total: string;
3085
- currency: string;
3089
+ currency: CurrencyCode;
3086
3090
  };
3087
3091
  error?: {
3088
3092
  code: string;
@@ -3117,6 +3121,7 @@ declare class CimplifyElements {
3117
3121
  private paymentData;
3118
3122
  private checkoutInProgress;
3119
3123
  private activeCheckoutAbort;
3124
+ private hasWarnedMissingAuthElement;
3120
3125
  private boundHandleMessage;
3121
3126
  private businessIdResolvePromise;
3122
3127
  constructor(client: CimplifyClient, businessId?: string, options?: ElementsOptions);
@@ -3208,6 +3213,7 @@ declare class CimplifyClient {
3208
3213
  setSessionToken(token: string | null): void;
3209
3214
  getAccessToken(): string | null;
3210
3215
  getPublicKey(): string;
3216
+ isTestMode(): boolean;
3211
3217
  setAccessToken(token: string | null): void;
3212
3218
  clearSession(): void;
3213
3219
  /** Set the active location/branch for all subsequent requests */
@@ -1,10 +1,11 @@
1
- import { o as PaymentErrorDetails, m as PaymentResponse, n as PaymentStatusResponse } from './payment-D-u3asA8.mjs';
1
+ import { C as CurrencyCode, M as Money, w as PaymentErrorDetails, u as PaymentResponse, v as PaymentStatusResponse } from './payment-Cu75tmUc.mjs';
2
2
 
3
3
  /**
4
4
  * Price Types
5
5
  *
6
6
  * Types for price parsing, formatting, and display utilities.
7
7
  */
8
+
8
9
  /**
9
10
  * Individual tax component (e.g., VAT, NHIL, GETFund)
10
11
  */
@@ -41,7 +42,7 @@ interface PriceInfo {
41
42
  /** Markup amount if applicable */
42
43
  markup_amount?: number;
43
44
  /** Currency code (e.g., "GHS", "USD") */
44
- currency?: string;
45
+ currency?: CurrencyCode;
45
46
  /** Tax information */
46
47
  tax_info?: TaxInfo;
47
48
  /** Decision path showing pricing adjustments */
@@ -61,14 +62,14 @@ interface ProductWithPrice {
61
62
  /** Default/indicative price in plain field form */
62
63
  default_price?: number | string | null;
63
64
  /** Currency in plain field form */
64
- currency?: string | null;
65
+ currency?: CurrencyCode | null;
65
66
  }
66
67
  /**
67
68
  * Options for price formatting functions
68
69
  */
69
70
  interface FormatPriceOptions {
70
71
  /** Currency code (default: "GHS") */
71
- currency?: string;
72
+ currency?: CurrencyCode;
72
73
  /** Locale for Intl.NumberFormat (default: "en-US") */
73
74
  locale?: string;
74
75
  /** Minimum fraction digits (default: 2) */
@@ -81,7 +82,7 @@ interface FormatPriceOptions {
81
82
  */
82
83
  interface FormatCompactOptions {
83
84
  /** Currency code (default: "GHS") */
84
- currency?: string;
85
+ currency?: CurrencyCode;
85
86
  /** Number of decimal places for compact notation (default: 1) */
86
87
  decimals?: number;
87
88
  }
@@ -128,7 +129,7 @@ declare const CURRENCY_SYMBOLS: Record<string, string>;
128
129
  * getCurrencySymbol('GHS') // "GH₵"
129
130
  * getCurrencySymbol('XYZ') // "XYZ"
130
131
  */
131
- declare function getCurrencySymbol(currencyCode: string): string;
132
+ declare function getCurrencySymbol(currencyCode: CurrencyCode): string;
132
133
  /**
133
134
  * Format a number compactly with K/M/B suffixes
134
135
  * @param value - Number to format
@@ -156,7 +157,7 @@ declare function formatNumberCompact(value: number, decimals?: number): string;
156
157
  * formatPrice('29.99', 'EUR') // "€29.99"
157
158
  * formatPrice(1234.56, 'USD', 'de-DE') // "1.234,56 $"
158
159
  */
159
- declare function formatPrice(amount: number | string, currency?: string, locale?: string): string;
160
+ declare function formatPrice(amount: number | Money, currency?: CurrencyCode, locale?: string): string;
160
161
  /**
161
162
  * Format a price with +/- sign for adjustments
162
163
  * Useful for showing price changes, modifiers, or discounts
@@ -171,7 +172,7 @@ declare function formatPrice(amount: number | string, currency?: string, locale?
171
172
  * formatPriceAdjustment(-3.50, 'GHS') // "-GH₵3.50"
172
173
  * formatPriceAdjustment(0, 'EUR') // "€0.00"
173
174
  */
174
- declare function formatPriceAdjustment(amount: number, currency?: string, locale?: string): string;
175
+ declare function formatPriceAdjustment(amount: number, currency?: CurrencyCode, locale?: string): string;
175
176
  /**
176
177
  * Format a price compactly for large numbers
177
178
  * Uses K/M/B suffixes for thousands, millions, billions
@@ -187,7 +188,7 @@ declare function formatPriceAdjustment(amount: number, currency?: string, locale
187
188
  * formatPriceCompact(2500000, 'USD') // "$2.5M"
188
189
  * formatPriceCompact(1200000000, 'EUR') // "€1.2B"
189
190
  */
190
- declare function formatPriceCompact(amount: number | string, currency?: string, decimals?: number): string;
191
+ declare function formatPriceCompact(amount: number | Money, currency?: CurrencyCode, decimals?: number): string;
191
192
  /**
192
193
  * Simple currency symbol + amount format
193
194
  * Lighter alternative to formatPrice without Intl
@@ -200,7 +201,7 @@ declare function formatPriceCompact(amount: number | string, currency?: string,
200
201
  * formatMoney(29.99, 'USD') // "$29.99"
201
202
  * formatMoney('15.00', 'GHS') // "GH₵15.00"
202
203
  */
203
- declare function formatMoney(amount: string | number, currency?: string): string;
204
+ declare function formatMoney(amount: Money | number, currency?: CurrencyCode): string;
204
205
  /**
205
206
  * Parse a price string or number to a numeric value
206
207
  * Handles various input formats gracefully
@@ -215,7 +216,7 @@ declare function formatMoney(amount: string | number, currency?: string): string
215
216
  * parsePrice(undefined) // 0
216
217
  * parsePrice('invalid') // 0
217
218
  */
218
- declare function parsePrice(value: string | number | undefined | null): number;
219
+ declare function parsePrice(value: Money | string | number | undefined | null): number;
219
220
  /**
220
221
  * Get the display price from a product.
221
222
  * Prefers quote-aware price_info, then plain price fields.
@@ -273,7 +274,7 @@ declare function getMarkupPercentage(product: ProductWithPrice): number;
273
274
  * @param product - Product with price data
274
275
  * @returns Currency code (default: "GHS")
275
276
  */
276
- declare function getProductCurrency(product: ProductWithPrice): string;
277
+ declare function getProductCurrency(product: ProductWithPrice): CurrencyCode;
277
278
  /**
278
279
  * Format a product's display price
279
280
  * Convenience function combining getDisplayPrice and formatPrice