@umituz/web-payment 0.0.0-stage → 1.0.1

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.
Files changed (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -2
  3. package/dist/billing-adapter.interface-CDkeeowZ.d.mts +94 -0
  4. package/dist/billing-adapter.interface-m7yE50I0.d.ts +94 -0
  5. package/dist/billing-cycle.enum--hJRYlgP.d.mts +10 -0
  6. package/dist/billing-cycle.enum--hJRYlgP.d.ts +10 -0
  7. package/dist/billing-env-D4YjvA3M.d.mts +8 -0
  8. package/dist/billing-env-D4YjvA3M.d.ts +8 -0
  9. package/dist/checkout-metadata-D7Wp_DAD.d.mts +27 -0
  10. package/dist/checkout-metadata-D7Wp_DAD.d.ts +27 -0
  11. package/dist/chunk-2KV7JFYF.mjs +61 -0
  12. package/dist/chunk-2NH5DOLT.mjs +101 -0
  13. package/dist/chunk-3AXPZOCV.mjs +106 -0
  14. package/dist/chunk-4N3BASZ6.mjs +51 -0
  15. package/dist/chunk-NHKK3ENU.mjs +1128 -0
  16. package/dist/chunk-PIWNUAKW.mjs +30 -0
  17. package/dist/chunk-QFB7AOSQ.mjs +33 -0
  18. package/dist/chunk-RQTMBR74.mjs +30 -0
  19. package/dist/chunk-U45FS4FF.mjs +110 -0
  20. package/dist/chunk-X6R76FZT.mjs +0 -0
  21. package/dist/chunk-XQ2HJTTA.mjs +252 -0
  22. package/dist/core.d.mts +17 -0
  23. package/dist/core.d.ts +17 -0
  24. package/dist/core.js +425 -0
  25. package/dist/core.mjs +66 -0
  26. package/dist/http.d.mts +12 -0
  27. package/dist/http.d.ts +12 -0
  28. package/dist/http.js +115 -0
  29. package/dist/http.mjs +88 -0
  30. package/dist/index.d.mts +17 -0
  31. package/dist/index.d.ts +17 -0
  32. package/dist/index.js +1929 -0
  33. package/dist/index.mjs +153 -0
  34. package/dist/memory.d.mts +14 -0
  35. package/dist/memory.d.ts +14 -0
  36. package/dist/memory.js +130 -0
  37. package/dist/memory.mjs +6 -0
  38. package/dist/portal.d.mts +445 -0
  39. package/dist/portal.d.ts +445 -0
  40. package/dist/portal.js +2927 -0
  41. package/dist/portal.mjs +2737 -0
  42. package/dist/product.mapper-CnY1ISOp.d.ts +97 -0
  43. package/dist/product.mapper-noVl-sel.d.mts +97 -0
  44. package/dist/products.d.mts +64 -0
  45. package/dist/products.d.ts +64 -0
  46. package/dist/products.js +370 -0
  47. package/dist/products.mjs +21 -0
  48. package/dist/react.d.mts +182 -0
  49. package/dist/react.d.ts +182 -0
  50. package/dist/react.js +1874 -0
  51. package/dist/react.mjs +105 -0
  52. package/dist/server.d.mts +177 -0
  53. package/dist/server.d.ts +177 -0
  54. package/dist/server.js +622 -0
  55. package/dist/server.mjs +417 -0
  56. package/dist/visual-tokens-BCLVR85G.d.mts +94 -0
  57. package/dist/visual-tokens-BCLVR85G.d.ts +94 -0
  58. package/package.json +122 -4
  59. package/src/core.ts +81 -0
  60. package/src/domain/entities/cancellation.entity.ts +28 -0
  61. package/src/domain/entities/checkout.entity.ts +21 -0
  62. package/src/domain/entities/index.ts +10 -0
  63. package/src/domain/entities/order.entity.ts +15 -0
  64. package/src/domain/entities/product.entity.ts +16 -0
  65. package/src/domain/entities/subscription.entity.ts +24 -0
  66. package/src/domain/entities/sync.entity.ts +4 -0
  67. package/src/domain/enums/amount-type.enum.ts +10 -0
  68. package/src/domain/enums/billing-cycle.enum.ts +30 -0
  69. package/src/domain/enums/index.ts +5 -0
  70. package/src/domain/enums/payment-provider.enum.ts +14 -0
  71. package/src/domain/enums/subscription-status.enum.ts +32 -0
  72. package/src/domain/index.ts +5 -0
  73. package/src/domain/interfaces/billing-adapter.interface.ts +18 -0
  74. package/src/domain/interfaces/index.ts +1 -0
  75. package/src/domain/mappers/product.mapper.ts +176 -0
  76. package/src/domain/utils/minor-units.ts +20 -0
  77. package/src/domain/utils/percent-discount.ts +17 -0
  78. package/src/http.ts +3 -0
  79. package/src/index.ts +12 -0
  80. package/src/infrastructure/browser/hosted-checkout.ts +26 -0
  81. package/src/infrastructure/config/billing-env.ts +31 -0
  82. package/src/infrastructure/constants/billing.constants.ts +10 -0
  83. package/src/infrastructure/http/http-client.ts +83 -0
  84. package/src/infrastructure/pagination/page-iterator.ts +43 -0
  85. package/src/infrastructure/query/query-builder.ts +26 -0
  86. package/src/infrastructure/services/billing.client.ts +300 -0
  87. package/src/infrastructure/services/create-billing-client.ts +23 -0
  88. package/src/infrastructure/services/http/create-http-adapter.ts +123 -0
  89. package/src/infrastructure/services/memory/create-memory-adapter.ts +126 -0
  90. package/src/infrastructure/services/product.repository.ts +198 -0
  91. package/src/infrastructure/utils/checkout-metadata.ts +55 -0
  92. package/src/infrastructure/utils/date-renderer.ts +53 -0
  93. package/src/infrastructure/utils/money-formatter.ts +39 -0
  94. package/src/infrastructure/utils/normalization.util.ts +22 -0
  95. package/src/infrastructure/utils/pagination-clamp.ts +11 -0
  96. package/src/infrastructure/utils/receipt.util.ts +6 -0
  97. package/src/infrastructure/utils/security.util.ts +23 -0
  98. package/src/infrastructure/utils/type-guards.util.ts +23 -0
  99. package/src/infrastructure/utils/validation.util.ts +10 -0
  100. package/src/infrastructure/webhook/parse-event.ts +135 -0
  101. package/src/infrastructure/webhook/verify-webhook.ts +124 -0
  102. package/src/memory.ts +3 -0
  103. package/src/portal.ts +2 -0
  104. package/src/presentation/components/BillingHistoryList.tsx +172 -0
  105. package/src/presentation/components/BillingProvider.tsx +179 -0
  106. package/src/presentation/components/CancelSubscriptionButton.tsx +155 -0
  107. package/src/presentation/components/CheckoutButton.tsx +76 -0
  108. package/src/presentation/components/CustomerPortalLink.tsx +71 -0
  109. package/src/presentation/components/PricingTable.tsx +225 -0
  110. package/src/presentation/components/SubscriptionStatusBadge.tsx +102 -0
  111. package/src/presentation/context/billing-context.ts +30 -0
  112. package/src/presentation/hooks/useBilling.ts +3 -0
  113. package/src/presentation/hooks/useCancelSubscription.ts +47 -0
  114. package/src/presentation/hooks/useCheckoutButton.ts +49 -0
  115. package/src/presentation/hooks/useProducts.ts +76 -0
  116. package/src/presentation/navigation/navigation.strategy.ts +16 -0
  117. package/src/presentation/portal/TurnkeyBillingPage.tsx +144 -0
  118. package/src/presentation/portal/components/BillingLayout.tsx +163 -0
  119. package/src/presentation/portal/components/BillingPage.tsx +22 -0
  120. package/src/presentation/portal/components/BillingPortal.tsx +248 -0
  121. package/src/presentation/portal/components/InvoiceCard.tsx +275 -0
  122. package/src/presentation/portal/components/OverviewTab.tsx +137 -0
  123. package/src/presentation/portal/components/PaymentMethodsList.tsx +268 -0
  124. package/src/presentation/portal/components/PlanComparison.tsx +405 -0
  125. package/src/presentation/portal/components/PlanTab.tsx +197 -0
  126. package/src/presentation/portal/components/PortalButton.tsx +89 -0
  127. package/src/presentation/portal/components/PortalSpinner.tsx +30 -0
  128. package/src/presentation/portal/components/UsageCard.tsx +158 -0
  129. package/src/presentation/portal/components/index.ts +11 -0
  130. package/src/presentation/portal/constants.ts +44 -0
  131. package/src/presentation/portal/create-portal-client.ts +202 -0
  132. package/src/presentation/portal/hooks/index.ts +3 -0
  133. package/src/presentation/portal/hooks/useBilling.ts +240 -0
  134. package/src/presentation/portal/index.ts +97 -0
  135. package/src/presentation/portal/labels.tsx +218 -0
  136. package/src/presentation/portal/styles.ts +70 -0
  137. package/src/presentation/portal/types.ts +213 -0
  138. package/src/presentation/portal/utils/billing.ts +193 -0
  139. package/src/presentation/portal/utils/index.ts +27 -0
  140. package/src/presentation/portal/utils/plans.ts +71 -0
  141. package/src/presentation/theme/visual-tokens.ts +103 -0
  142. package/src/presentation/utils/cancellation-reason-catalog.ts +18 -0
  143. package/src/presentation/utils/checkout-button-visual.ts +50 -0
  144. package/src/presentation/utils/inline-error-visual.ts +21 -0
  145. package/src/presentation/utils/product-pricing.ts +33 -0
  146. package/src/presentation/utils/status-label.ts +23 -0
  147. package/src/presentation/utils/status-tone.ts +25 -0
  148. package/src/products.ts +20 -0
  149. package/src/react.tsx +63 -0
  150. package/src/server.ts +79 -0
@@ -0,0 +1,21 @@
1
+ import "./chunk-X6R76FZT.mjs";
2
+ import {
3
+ BillingApiError,
4
+ FetchHttpClient,
5
+ ProductRepository,
6
+ getAllProducts,
7
+ getProductById,
8
+ getProducts,
9
+ isBillingApiError
10
+ } from "./chunk-XQ2HJTTA.mjs";
11
+ import "./chunk-U45FS4FF.mjs";
12
+ import "./chunk-RQTMBR74.mjs";
13
+ export {
14
+ BillingApiError,
15
+ FetchHttpClient,
16
+ ProductRepository,
17
+ getAllProducts,
18
+ getProductById,
19
+ getProducts,
20
+ isBillingApiError
21
+ };
@@ -0,0 +1,182 @@
1
+ export { B as BuildCheckoutMetadataInput, C as CheckoutOrderMetadata, P as PAYMENT_PROVIDER, a as PAYMENT_PROVIDER_VALUES, b as PaymentProvider, c as buildCheckoutMetadata, f as formatReceiptNumber, i as isKnownPaymentProvider, r as readCheckoutMetadata } from './checkout-metadata-D7Wp_DAD.mjs';
2
+ import { B as BillingAdapter, d as CheckoutParams, g as SubscriptionStatus, h as SubscriptionStatusValue, O as OrderItem, c as CancellationReason, i as SyncResult, b as CancelResult } from './billing-adapter.interface-CDkeeowZ.mjs';
3
+ export { C as CANCELLATION_REASON, a as CANCELLATION_REASON_VALUES, e as CheckoutResult, F as FREE_SUBSCRIPTION_STATUS, S as SUBSCRIPTION_STATUS, f as SUBSCRIPTION_STATUS_VALUES, j as isActiveSubscription, k as isKnownSubscriptionStatus } from './billing-adapter.interface-CDkeeowZ.mjs';
4
+ import { b as BillingCycle } from './billing-cycle.enum--hJRYlgP.mjs';
5
+ export { B as BILLING_CYCLE, a as BILLING_CYCLE_VALUES, i as isKnownBillingCycle, p as parseBillingCycle } from './billing-cycle.enum--hJRYlgP.mjs';
6
+ import { a as Product } from './product.mapper-noVl-sel.mjs';
7
+ export { A as AmountType, P as POLAR_AMOUNT_TYPE, b as ProductBenefit, c as ProductBenefitDto, d as ProductDto, e as ProductListParams, f as ProductListResponse, g as ProductListResponseDto, h as ProductPrice, i as ProductPriceDto, m as mapProduct, j as mapProductList } from './product.mapper-noVl-sel.mjs';
8
+ export { PriceType, RecurringInterval, applyPercentDiscount, minorUnitDivisor, normalizeCouponCode, toMajorUnits, toMinorUnits } from './core.mjs';
9
+ export { MemoryAdapterConfig, createMemoryBillingAdapter } from './memory.mjs';
10
+ import * as react from 'react';
11
+ import { ReactNode } from 'react';
12
+ import { N as NavigationStrategy } from './visual-tokens-BCLVR85G.mjs';
13
+ export { a as NoopNavigationStrategy, T as TONE_PAIRS, V as VisualTokens, b as VisualTone, c as VisualTonePair, W as WindowNavigationStrategy } from './visual-tokens-BCLVR85G.mjs';
14
+
15
+ interface BillingProviderProps {
16
+ adapter: BillingAdapter;
17
+ userId?: string;
18
+ navigation?: NavigationStrategy;
19
+ children: ReactNode;
20
+ }
21
+ declare function BillingProvider({ adapter, userId, navigation, children, }: BillingProviderProps): react.JSX.Element;
22
+
23
+ type CheckoutButtonVariant = 'primary' | 'secondary' | 'danger';
24
+ interface CheckoutButtonLabels {
25
+ loading?: string;
26
+ }
27
+ interface CheckoutButtonProps {
28
+ productId: string;
29
+ billingCycle?: CheckoutParams['billingCycle'];
30
+ successUrl?: string;
31
+ planKey?: string;
32
+ label: string;
33
+ variant?: CheckoutButtonVariant;
34
+ disabled?: boolean;
35
+ onError?: (error: Error) => void;
36
+ className?: string;
37
+ labels?: CheckoutButtonLabels;
38
+ }
39
+ declare function CheckoutButton({ productId, billingCycle, successUrl, planKey, label, variant, disabled, onError, className, labels, }: CheckoutButtonProps): react.JSX.Element;
40
+
41
+ interface SubscriptionStatusBadgeProps {
42
+ status?: SubscriptionStatus;
43
+ loading?: boolean;
44
+ locale?: string;
45
+ labels?: SubscriptionStatusBadgeLabels;
46
+ }
47
+ interface SubscriptionStatusBadgeLabels {
48
+ loading?: string;
49
+ endsPrefix?: string;
50
+ statuses?: Partial<Record<SubscriptionStatusValue, string>>;
51
+ }
52
+ declare function SubscriptionStatusBadge({ status: statusOverride, loading: loadingOverride, locale, labels, }: SubscriptionStatusBadgeProps): react.JSX.Element;
53
+
54
+ interface PricingTableProps {
55
+ products?: Product[];
56
+ apiToken?: string;
57
+ organizationId?: string;
58
+ isRecurring?: boolean;
59
+ ctaLabel?: string;
60
+ onError?: (error: Error) => void;
61
+ filterInterval?: BillingCycle | null;
62
+ locale?: string;
63
+ labels?: PricingTableLabels;
64
+ }
65
+ interface PricingTableLabels {
66
+ loading?: string;
67
+ empty?: string;
68
+ errorPrefix?: string;
69
+ retry?: string;
70
+ }
71
+ declare function PricingTable({ products: productsOverride, apiToken, organizationId, isRecurring, ctaLabel, onError, filterInterval, locale, labels, }: PricingTableProps): react.JSX.Element;
72
+
73
+ interface BillingHistoryListProps {
74
+ autoLoad?: boolean;
75
+ orders?: OrderItem[];
76
+ loading?: boolean;
77
+ locale?: string;
78
+ labels?: BillingHistoryListLabels;
79
+ }
80
+ interface BillingHistoryListLabels {
81
+ loading?: string;
82
+ empty?: string;
83
+ refresh?: string;
84
+ retry?: string;
85
+ paid?: string;
86
+ invoiceLink?: string;
87
+ invoiceFallback?: string;
88
+ colDate?: string;
89
+ colProduct?: string;
90
+ colStatus?: string;
91
+ colAmount?: string;
92
+ colInvoice?: string;
93
+ }
94
+ declare function BillingHistoryList({ autoLoad, orders: ordersOverride, loading: loadingOverride, locale, labels, }: BillingHistoryListProps): react.JSX.Element;
95
+
96
+ interface CustomerPortalLinkProps {
97
+ label?: string;
98
+ target?: 'redirect' | 'open';
99
+ className?: string;
100
+ labels?: CustomerPortalLinkLabels;
101
+ }
102
+ interface CustomerPortalLinkLabels {
103
+ loading?: string;
104
+ }
105
+ declare function CustomerPortalLink({ label, target, className, labels, }: CustomerPortalLinkProps): react.JSX.Element;
106
+
107
+ interface CancellationReasonOption {
108
+ readonly value: CancellationReason;
109
+ readonly label: string;
110
+ }
111
+ declare const CANCELLATION_REASON_CATALOG: ReadonlyArray<CancellationReasonOption>;
112
+
113
+ interface CancelSubscriptionButtonProps {
114
+ label?: string;
115
+ renderPrompt?: (confirm: (reason?: CancellationReason) => void) => ReactNode;
116
+ onSuccess?: () => void;
117
+ reasonCatalog?: ReadonlyArray<CancellationReasonOption>;
118
+ labels?: CancelSubscriptionButtonLabels;
119
+ }
120
+ interface CancelSubscriptionButtonLabels {
121
+ action?: string;
122
+ confirm?: string;
123
+ keep?: string;
124
+ canceling?: string;
125
+ promptTitle?: string;
126
+ noReason?: string;
127
+ }
128
+ declare function CancelSubscriptionButton({ label, renderPrompt, onSuccess, reasonCatalog, labels, }: CancelSubscriptionButtonProps): react.JSX.Element;
129
+
130
+ interface BillingContextValue {
131
+ status: SubscriptionStatus;
132
+ loading: boolean;
133
+ refresh: () => Promise<void>;
134
+ startCheckout: (params: CheckoutParams) => Promise<void>;
135
+ syncSubscription: () => Promise<SyncResult>;
136
+ getBillingHistory: () => Promise<OrderItem[]>;
137
+ cancelSubscription: (reason?: CancellationReason) => Promise<CancelResult>;
138
+ getPortalUrl: () => Promise<string>;
139
+ }
140
+ declare const BillingContext: react.Context<BillingContextValue | undefined>;
141
+ declare function useBilling(): BillingContextValue;
142
+
143
+ interface UseCheckoutButtonOptions {
144
+ productId: string;
145
+ billingCycle?: CheckoutParams['billingCycle'];
146
+ successUrl?: string;
147
+ planKey?: string;
148
+ onError?: (error: Error) => void;
149
+ }
150
+ interface UseCheckoutButtonResult {
151
+ start: () => Promise<void>;
152
+ loading: boolean;
153
+ error: Error | null;
154
+ }
155
+ declare function useCheckoutButton(options: UseCheckoutButtonOptions): UseCheckoutButtonResult;
156
+
157
+ interface UseCancelSubscriptionOptions {
158
+ onError?: (error: Error) => void;
159
+ onSuccess?: (result: CancelResult) => void;
160
+ }
161
+ interface UseCancelSubscriptionResult {
162
+ cancel: (reason?: CancellationReason) => Promise<CancelResult | null>;
163
+ loading: boolean;
164
+ error: Error | null;
165
+ }
166
+ declare function useCancelSubscription(options?: UseCancelSubscriptionOptions): UseCancelSubscriptionResult;
167
+
168
+ interface UseProductsOptions {
169
+ apiToken: string;
170
+ organizationId?: string;
171
+ isRecurring?: boolean;
172
+ enabled?: boolean;
173
+ }
174
+ interface UseProductsResult {
175
+ products: Product[];
176
+ loading: boolean;
177
+ error: Error | null;
178
+ refetch: () => Promise<void>;
179
+ }
180
+ declare function useProducts(options: UseProductsOptions): UseProductsResult;
181
+
182
+ export { BillingAdapter, BillingContext, type BillingContextValue, BillingCycle, BillingHistoryList, type BillingHistoryListLabels, type BillingHistoryListProps, BillingProvider, type BillingProviderProps, CANCELLATION_REASON_CATALOG, CancelResult, CancelSubscriptionButton, type CancelSubscriptionButtonLabels, type CancelSubscriptionButtonProps, CancellationReason, type CancellationReasonOption, CheckoutButton, type CheckoutButtonLabels, type CheckoutButtonProps, type CheckoutButtonVariant, CheckoutParams, CustomerPortalLink, type CustomerPortalLinkLabels, type CustomerPortalLinkProps, NavigationStrategy, OrderItem, PricingTable, type PricingTableLabels, type PricingTableProps, Product, SubscriptionStatus, SubscriptionStatusBadge, type SubscriptionStatusBadgeLabels, type SubscriptionStatusBadgeProps, SubscriptionStatusValue, SyncResult, type UseCancelSubscriptionOptions, type UseCancelSubscriptionResult, type UseCheckoutButtonOptions, type UseCheckoutButtonResult, type UseProductsOptions, type UseProductsResult, useBilling, useCancelSubscription, useCheckoutButton, useProducts };
@@ -0,0 +1,182 @@
1
+ export { B as BuildCheckoutMetadataInput, C as CheckoutOrderMetadata, P as PAYMENT_PROVIDER, a as PAYMENT_PROVIDER_VALUES, b as PaymentProvider, c as buildCheckoutMetadata, f as formatReceiptNumber, i as isKnownPaymentProvider, r as readCheckoutMetadata } from './checkout-metadata-D7Wp_DAD.js';
2
+ import { B as BillingAdapter, d as CheckoutParams, g as SubscriptionStatus, h as SubscriptionStatusValue, O as OrderItem, c as CancellationReason, i as SyncResult, b as CancelResult } from './billing-adapter.interface-m7yE50I0.js';
3
+ export { C as CANCELLATION_REASON, a as CANCELLATION_REASON_VALUES, e as CheckoutResult, F as FREE_SUBSCRIPTION_STATUS, S as SUBSCRIPTION_STATUS, f as SUBSCRIPTION_STATUS_VALUES, j as isActiveSubscription, k as isKnownSubscriptionStatus } from './billing-adapter.interface-m7yE50I0.js';
4
+ import { b as BillingCycle } from './billing-cycle.enum--hJRYlgP.js';
5
+ export { B as BILLING_CYCLE, a as BILLING_CYCLE_VALUES, i as isKnownBillingCycle, p as parseBillingCycle } from './billing-cycle.enum--hJRYlgP.js';
6
+ import { a as Product } from './product.mapper-CnY1ISOp.js';
7
+ export { A as AmountType, P as POLAR_AMOUNT_TYPE, b as ProductBenefit, c as ProductBenefitDto, d as ProductDto, e as ProductListParams, f as ProductListResponse, g as ProductListResponseDto, h as ProductPrice, i as ProductPriceDto, m as mapProduct, j as mapProductList } from './product.mapper-CnY1ISOp.js';
8
+ export { PriceType, RecurringInterval, applyPercentDiscount, minorUnitDivisor, normalizeCouponCode, toMajorUnits, toMinorUnits } from './core.js';
9
+ export { MemoryAdapterConfig, createMemoryBillingAdapter } from './memory.js';
10
+ import * as react from 'react';
11
+ import { ReactNode } from 'react';
12
+ import { N as NavigationStrategy } from './visual-tokens-BCLVR85G.js';
13
+ export { a as NoopNavigationStrategy, T as TONE_PAIRS, V as VisualTokens, b as VisualTone, c as VisualTonePair, W as WindowNavigationStrategy } from './visual-tokens-BCLVR85G.js';
14
+
15
+ interface BillingProviderProps {
16
+ adapter: BillingAdapter;
17
+ userId?: string;
18
+ navigation?: NavigationStrategy;
19
+ children: ReactNode;
20
+ }
21
+ declare function BillingProvider({ adapter, userId, navigation, children, }: BillingProviderProps): react.JSX.Element;
22
+
23
+ type CheckoutButtonVariant = 'primary' | 'secondary' | 'danger';
24
+ interface CheckoutButtonLabels {
25
+ loading?: string;
26
+ }
27
+ interface CheckoutButtonProps {
28
+ productId: string;
29
+ billingCycle?: CheckoutParams['billingCycle'];
30
+ successUrl?: string;
31
+ planKey?: string;
32
+ label: string;
33
+ variant?: CheckoutButtonVariant;
34
+ disabled?: boolean;
35
+ onError?: (error: Error) => void;
36
+ className?: string;
37
+ labels?: CheckoutButtonLabels;
38
+ }
39
+ declare function CheckoutButton({ productId, billingCycle, successUrl, planKey, label, variant, disabled, onError, className, labels, }: CheckoutButtonProps): react.JSX.Element;
40
+
41
+ interface SubscriptionStatusBadgeProps {
42
+ status?: SubscriptionStatus;
43
+ loading?: boolean;
44
+ locale?: string;
45
+ labels?: SubscriptionStatusBadgeLabels;
46
+ }
47
+ interface SubscriptionStatusBadgeLabels {
48
+ loading?: string;
49
+ endsPrefix?: string;
50
+ statuses?: Partial<Record<SubscriptionStatusValue, string>>;
51
+ }
52
+ declare function SubscriptionStatusBadge({ status: statusOverride, loading: loadingOverride, locale, labels, }: SubscriptionStatusBadgeProps): react.JSX.Element;
53
+
54
+ interface PricingTableProps {
55
+ products?: Product[];
56
+ apiToken?: string;
57
+ organizationId?: string;
58
+ isRecurring?: boolean;
59
+ ctaLabel?: string;
60
+ onError?: (error: Error) => void;
61
+ filterInterval?: BillingCycle | null;
62
+ locale?: string;
63
+ labels?: PricingTableLabels;
64
+ }
65
+ interface PricingTableLabels {
66
+ loading?: string;
67
+ empty?: string;
68
+ errorPrefix?: string;
69
+ retry?: string;
70
+ }
71
+ declare function PricingTable({ products: productsOverride, apiToken, organizationId, isRecurring, ctaLabel, onError, filterInterval, locale, labels, }: PricingTableProps): react.JSX.Element;
72
+
73
+ interface BillingHistoryListProps {
74
+ autoLoad?: boolean;
75
+ orders?: OrderItem[];
76
+ loading?: boolean;
77
+ locale?: string;
78
+ labels?: BillingHistoryListLabels;
79
+ }
80
+ interface BillingHistoryListLabels {
81
+ loading?: string;
82
+ empty?: string;
83
+ refresh?: string;
84
+ retry?: string;
85
+ paid?: string;
86
+ invoiceLink?: string;
87
+ invoiceFallback?: string;
88
+ colDate?: string;
89
+ colProduct?: string;
90
+ colStatus?: string;
91
+ colAmount?: string;
92
+ colInvoice?: string;
93
+ }
94
+ declare function BillingHistoryList({ autoLoad, orders: ordersOverride, loading: loadingOverride, locale, labels, }: BillingHistoryListProps): react.JSX.Element;
95
+
96
+ interface CustomerPortalLinkProps {
97
+ label?: string;
98
+ target?: 'redirect' | 'open';
99
+ className?: string;
100
+ labels?: CustomerPortalLinkLabels;
101
+ }
102
+ interface CustomerPortalLinkLabels {
103
+ loading?: string;
104
+ }
105
+ declare function CustomerPortalLink({ label, target, className, labels, }: CustomerPortalLinkProps): react.JSX.Element;
106
+
107
+ interface CancellationReasonOption {
108
+ readonly value: CancellationReason;
109
+ readonly label: string;
110
+ }
111
+ declare const CANCELLATION_REASON_CATALOG: ReadonlyArray<CancellationReasonOption>;
112
+
113
+ interface CancelSubscriptionButtonProps {
114
+ label?: string;
115
+ renderPrompt?: (confirm: (reason?: CancellationReason) => void) => ReactNode;
116
+ onSuccess?: () => void;
117
+ reasonCatalog?: ReadonlyArray<CancellationReasonOption>;
118
+ labels?: CancelSubscriptionButtonLabels;
119
+ }
120
+ interface CancelSubscriptionButtonLabels {
121
+ action?: string;
122
+ confirm?: string;
123
+ keep?: string;
124
+ canceling?: string;
125
+ promptTitle?: string;
126
+ noReason?: string;
127
+ }
128
+ declare function CancelSubscriptionButton({ label, renderPrompt, onSuccess, reasonCatalog, labels, }: CancelSubscriptionButtonProps): react.JSX.Element;
129
+
130
+ interface BillingContextValue {
131
+ status: SubscriptionStatus;
132
+ loading: boolean;
133
+ refresh: () => Promise<void>;
134
+ startCheckout: (params: CheckoutParams) => Promise<void>;
135
+ syncSubscription: () => Promise<SyncResult>;
136
+ getBillingHistory: () => Promise<OrderItem[]>;
137
+ cancelSubscription: (reason?: CancellationReason) => Promise<CancelResult>;
138
+ getPortalUrl: () => Promise<string>;
139
+ }
140
+ declare const BillingContext: react.Context<BillingContextValue | undefined>;
141
+ declare function useBilling(): BillingContextValue;
142
+
143
+ interface UseCheckoutButtonOptions {
144
+ productId: string;
145
+ billingCycle?: CheckoutParams['billingCycle'];
146
+ successUrl?: string;
147
+ planKey?: string;
148
+ onError?: (error: Error) => void;
149
+ }
150
+ interface UseCheckoutButtonResult {
151
+ start: () => Promise<void>;
152
+ loading: boolean;
153
+ error: Error | null;
154
+ }
155
+ declare function useCheckoutButton(options: UseCheckoutButtonOptions): UseCheckoutButtonResult;
156
+
157
+ interface UseCancelSubscriptionOptions {
158
+ onError?: (error: Error) => void;
159
+ onSuccess?: (result: CancelResult) => void;
160
+ }
161
+ interface UseCancelSubscriptionResult {
162
+ cancel: (reason?: CancellationReason) => Promise<CancelResult | null>;
163
+ loading: boolean;
164
+ error: Error | null;
165
+ }
166
+ declare function useCancelSubscription(options?: UseCancelSubscriptionOptions): UseCancelSubscriptionResult;
167
+
168
+ interface UseProductsOptions {
169
+ apiToken: string;
170
+ organizationId?: string;
171
+ isRecurring?: boolean;
172
+ enabled?: boolean;
173
+ }
174
+ interface UseProductsResult {
175
+ products: Product[];
176
+ loading: boolean;
177
+ error: Error | null;
178
+ refetch: () => Promise<void>;
179
+ }
180
+ declare function useProducts(options: UseProductsOptions): UseProductsResult;
181
+
182
+ export { BillingAdapter, BillingContext, type BillingContextValue, BillingCycle, BillingHistoryList, type BillingHistoryListLabels, type BillingHistoryListProps, BillingProvider, type BillingProviderProps, CANCELLATION_REASON_CATALOG, CancelResult, CancelSubscriptionButton, type CancelSubscriptionButtonLabels, type CancelSubscriptionButtonProps, CancellationReason, type CancellationReasonOption, CheckoutButton, type CheckoutButtonLabels, type CheckoutButtonProps, type CheckoutButtonVariant, CheckoutParams, CustomerPortalLink, type CustomerPortalLinkLabels, type CustomerPortalLinkProps, NavigationStrategy, OrderItem, PricingTable, type PricingTableLabels, type PricingTableProps, Product, SubscriptionStatus, SubscriptionStatusBadge, type SubscriptionStatusBadgeLabels, type SubscriptionStatusBadgeProps, SubscriptionStatusValue, SyncResult, type UseCancelSubscriptionOptions, type UseCancelSubscriptionResult, type UseCheckoutButtonOptions, type UseCheckoutButtonResult, type UseProductsOptions, type UseProductsResult, useBilling, useCancelSubscription, useCheckoutButton, useProducts };