@solvapay/react 1.0.8-preview.9 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +209 -0
- package/README.md +194 -25
- package/dist/adapters/auth.d.cts +13 -0
- package/dist/adapters/auth.d.ts +13 -0
- package/dist/adapters/auth.js +1 -0
- package/dist/{chunk-MOP3ZBGC.js → chunk-37R5NZGF.js} +1116 -1041
- package/dist/chunk-HWVJL5X6.js +429 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-R2ZPZ7VM.js +597 -0
- package/dist/chunk-ZAV7CQ4G.js +361 -0
- package/dist/index-WBjulQHf.d.cts +3656 -0
- package/dist/index-onWNU7iT.d.ts +3656 -0
- package/dist/index.cjs +1422 -366
- package/dist/index.d.cts +251 -64
- package/dist/index.d.ts +251 -64
- package/dist/index.js +54 -26
- package/dist/mcp/index.cjs +8096 -0
- package/dist/mcp/index.d.cts +1013 -0
- package/dist/mcp/index.d.ts +1013 -0
- package/dist/mcp/index.js +2724 -0
- package/dist/mcp/styles.css +1020 -0
- package/dist/primitives/index.cjs +1177 -115
- package/dist/primitives/index.d.cts +208 -20
- package/dist/primitives/index.d.ts +208 -20
- package/dist/primitives/index.js +66 -21
- package/dist/styles.css +246 -0
- package/dist/useUsage-BmOYXxgG.d.cts +413 -0
- package/dist/useUsage-nD7zwSbG.d.ts +413 -0
- package/dist/webapi-K5XBCEO6.js +3775 -0
- package/package.json +20 -4
- package/dist/CancelPlanButton-CieT9swn.d.cts +0 -1102
- package/dist/CancelPlanButton-f56UlQN-.d.ts +0 -1102
|
@@ -1,1102 +0,0 @@
|
|
|
1
|
-
import React$1 from 'react';
|
|
2
|
-
import { PaymentElement, CardElement } from '@stripe/react-stripe-js';
|
|
3
|
-
import * as _stripe_stripe_js from '@stripe/stripe-js';
|
|
4
|
-
import { PaymentIntent } from '@stripe/stripe-js';
|
|
5
|
-
import { ActivatePlanResult, ProcessPaymentResult } from '@solvapay/server';
|
|
6
|
-
import { AuthAdapter } from './adapters/auth.cjs';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Typed copy bundle surfaced through `<SolvaPayProvider config={{ copy }} />`.
|
|
10
|
-
*
|
|
11
|
-
* Every user-visible string in `@solvapay/react` routes through this bundle via
|
|
12
|
-
* `useCopy()`. Values are either plain templates with `{placeholder}` tokens or
|
|
13
|
-
* function-form resolvers (currently only used for mandate variants) that
|
|
14
|
-
* receive a `MandateContext` and return the final string.
|
|
15
|
-
*/
|
|
16
|
-
type MandateContext = {
|
|
17
|
-
merchant: {
|
|
18
|
-
legalName: string;
|
|
19
|
-
displayName?: string;
|
|
20
|
-
supportEmail?: string;
|
|
21
|
-
termsUrl?: string;
|
|
22
|
-
privacyUrl?: string;
|
|
23
|
-
};
|
|
24
|
-
plan?: {
|
|
25
|
-
name?: string;
|
|
26
|
-
interval?: string;
|
|
27
|
-
intervalCount?: number;
|
|
28
|
-
trialDays?: number;
|
|
29
|
-
measures?: string;
|
|
30
|
-
billingCycle?: string;
|
|
31
|
-
};
|
|
32
|
-
product?: {
|
|
33
|
-
name?: string;
|
|
34
|
-
};
|
|
35
|
-
amountFormatted: string;
|
|
36
|
-
trialDays?: number;
|
|
37
|
-
};
|
|
38
|
-
type MandateTemplate = string | ((ctx: MandateContext) => string);
|
|
39
|
-
interface SolvaPayCopy {
|
|
40
|
-
mandate: {
|
|
41
|
-
recurring: MandateTemplate;
|
|
42
|
-
oneTime: MandateTemplate;
|
|
43
|
-
topup: MandateTemplate;
|
|
44
|
-
usageMetered: MandateTemplate;
|
|
45
|
-
freeTier: MandateTemplate;
|
|
46
|
-
};
|
|
47
|
-
cta: {
|
|
48
|
-
payNow: string;
|
|
49
|
-
topUp: string;
|
|
50
|
-
subscribe: string;
|
|
51
|
-
trialStart: string;
|
|
52
|
-
payAmount: string;
|
|
53
|
-
addAmount: string;
|
|
54
|
-
startUsing: string;
|
|
55
|
-
processing: string;
|
|
56
|
-
};
|
|
57
|
-
interval: {
|
|
58
|
-
day: string;
|
|
59
|
-
week: string;
|
|
60
|
-
month: string;
|
|
61
|
-
year: string;
|
|
62
|
-
every: string;
|
|
63
|
-
free: string;
|
|
64
|
-
trial: string;
|
|
65
|
-
};
|
|
66
|
-
terms: {
|
|
67
|
-
checkboxLabel: string;
|
|
68
|
-
};
|
|
69
|
-
customer: {
|
|
70
|
-
chargingTo: string;
|
|
71
|
-
emailLabel: string;
|
|
72
|
-
nameLabel: string;
|
|
73
|
-
};
|
|
74
|
-
balance: {
|
|
75
|
-
credits: string;
|
|
76
|
-
currencyEquivalent: string;
|
|
77
|
-
};
|
|
78
|
-
product: {
|
|
79
|
-
currentProductLabel: string;
|
|
80
|
-
};
|
|
81
|
-
topup: {
|
|
82
|
-
selectOrEnterAmount: string;
|
|
83
|
-
minAmount: string;
|
|
84
|
-
maxAmount: string;
|
|
85
|
-
};
|
|
86
|
-
activation: {
|
|
87
|
-
paymentRequired: string;
|
|
88
|
-
invalidConfiguration: string;
|
|
89
|
-
unexpectedResponse: string;
|
|
90
|
-
failed: string;
|
|
91
|
-
};
|
|
92
|
-
planSelector: {
|
|
93
|
-
heading: string;
|
|
94
|
-
currentBadge: string;
|
|
95
|
-
popularBadge: string;
|
|
96
|
-
freeBadge: string;
|
|
97
|
-
perIntervalShort: string;
|
|
98
|
-
continueButton: string;
|
|
99
|
-
backButton: string;
|
|
100
|
-
trialBadge: string;
|
|
101
|
-
};
|
|
102
|
-
amountPicker: {
|
|
103
|
-
selectAmountLabel: string;
|
|
104
|
-
customAmountLabel: string;
|
|
105
|
-
creditEstimateExact: string;
|
|
106
|
-
creditEstimateApprox: string;
|
|
107
|
-
};
|
|
108
|
-
activationFlow: {
|
|
109
|
-
heading: string;
|
|
110
|
-
activateButton: string;
|
|
111
|
-
activatingLabel: string;
|
|
112
|
-
topupHeading: string;
|
|
113
|
-
topupSubheading: string;
|
|
114
|
-
continueToPayment: string;
|
|
115
|
-
changeAmountButton: string;
|
|
116
|
-
retryingHeading: string;
|
|
117
|
-
retryingSubheading: string;
|
|
118
|
-
activatedHeading: string;
|
|
119
|
-
activatedSubheading: string;
|
|
120
|
-
tryAgainButton: string;
|
|
121
|
-
backButton: string;
|
|
122
|
-
};
|
|
123
|
-
cancelPlan: {
|
|
124
|
-
button: string;
|
|
125
|
-
buttonLoading: string;
|
|
126
|
-
confirmRecurring: string;
|
|
127
|
-
confirmUsageBased: string;
|
|
128
|
-
};
|
|
129
|
-
cancelledNotice: {
|
|
130
|
-
heading: string;
|
|
131
|
-
expiresLabel: string;
|
|
132
|
-
daysRemaining: string;
|
|
133
|
-
dayRemaining: string;
|
|
134
|
-
accessUntil: string;
|
|
135
|
-
accessEnded: string;
|
|
136
|
-
cancelledOn: string;
|
|
137
|
-
reactivateButton: string;
|
|
138
|
-
reactivateButtonLoading: string;
|
|
139
|
-
};
|
|
140
|
-
creditGate: {
|
|
141
|
-
lowBalanceHeading: string;
|
|
142
|
-
lowBalanceSubheading: string;
|
|
143
|
-
topUpCta: string;
|
|
144
|
-
};
|
|
145
|
-
errors: {
|
|
146
|
-
paymentInitFailed: string;
|
|
147
|
-
topupInitFailed: string;
|
|
148
|
-
configMissingPlanOrProduct: string;
|
|
149
|
-
configMissingAmount: string;
|
|
150
|
-
unknownError: string;
|
|
151
|
-
stripeUnavailable: string;
|
|
152
|
-
paymentIntentUnavailable: string;
|
|
153
|
-
cardElementMissing: string;
|
|
154
|
-
paymentUnexpected: string;
|
|
155
|
-
paymentProcessingFailed: string;
|
|
156
|
-
paymentRequires3ds: string;
|
|
157
|
-
paymentProcessingTimeout: string;
|
|
158
|
-
paymentStatusPrefix: string;
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Deep-partial type for consumer overrides — every nested key is optional so
|
|
163
|
-
* integrators can override only the strings they care about.
|
|
164
|
-
*/
|
|
165
|
-
type PartialSolvaPayCopy = {
|
|
166
|
-
[K in keyof SolvaPayCopy]?: Partial<SolvaPayCopy[K]>;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
interface PurchaseInfo {
|
|
170
|
-
reference: string;
|
|
171
|
-
productName: string;
|
|
172
|
-
productRef?: string;
|
|
173
|
-
status: string;
|
|
174
|
-
startDate: string;
|
|
175
|
-
endDate?: string;
|
|
176
|
-
cancelledAt?: string;
|
|
177
|
-
cancellationReason?: string;
|
|
178
|
-
amount?: number;
|
|
179
|
-
currency?: string;
|
|
180
|
-
planType?: string;
|
|
181
|
-
isRecurring?: boolean;
|
|
182
|
-
nextBillingDate?: string;
|
|
183
|
-
billingCycle?: string;
|
|
184
|
-
planRef?: string;
|
|
185
|
-
planSnapshot?: {
|
|
186
|
-
reference?: string;
|
|
187
|
-
price?: number;
|
|
188
|
-
meterRef?: string;
|
|
189
|
-
limit?: number;
|
|
190
|
-
freeUnits?: number;
|
|
191
|
-
creditsPerUnit?: number;
|
|
192
|
-
planType?: string;
|
|
193
|
-
billingCycle?: string | null;
|
|
194
|
-
features?: Record<string, unknown> | null;
|
|
195
|
-
};
|
|
196
|
-
usage?: {
|
|
197
|
-
used: number;
|
|
198
|
-
overageUnits?: number;
|
|
199
|
-
overageCost?: number;
|
|
200
|
-
periodStart?: string;
|
|
201
|
-
periodEnd?: string;
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
interface CustomerPurchaseData {
|
|
205
|
-
customerRef?: string;
|
|
206
|
-
email?: string;
|
|
207
|
-
name?: string;
|
|
208
|
-
purchases: PurchaseInfo[];
|
|
209
|
-
}
|
|
210
|
-
interface PaymentIntentResult {
|
|
211
|
-
clientSecret: string;
|
|
212
|
-
publishableKey: string;
|
|
213
|
-
accountId?: string;
|
|
214
|
-
customerRef?: string;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Subset of merchant identity surfaced by `GET /v1/sdk/merchant`.
|
|
218
|
-
* Used by `<MandateText>` and customer-facing trust signals.
|
|
219
|
-
*/
|
|
220
|
-
interface Merchant {
|
|
221
|
-
displayName: string;
|
|
222
|
-
legalName: string;
|
|
223
|
-
supportEmail?: string;
|
|
224
|
-
supportUrl?: string;
|
|
225
|
-
termsUrl?: string;
|
|
226
|
-
privacyUrl?: string;
|
|
227
|
-
country?: string;
|
|
228
|
-
defaultCurrency?: string;
|
|
229
|
-
statementDescriptor?: string;
|
|
230
|
-
logoUrl?: string;
|
|
231
|
-
}
|
|
232
|
-
interface UseMerchantReturn {
|
|
233
|
-
merchant: Merchant | null;
|
|
234
|
-
loading: boolean;
|
|
235
|
-
error: Error | null;
|
|
236
|
-
refetch: () => Promise<void>;
|
|
237
|
-
}
|
|
238
|
-
interface Product {
|
|
239
|
-
reference: string;
|
|
240
|
-
name?: string;
|
|
241
|
-
description?: string;
|
|
242
|
-
status?: string;
|
|
243
|
-
[key: string]: unknown;
|
|
244
|
-
}
|
|
245
|
-
interface UseProductReturn {
|
|
246
|
-
product: Product | null;
|
|
247
|
-
loading: boolean;
|
|
248
|
-
error: Error | null;
|
|
249
|
-
refetch: () => Promise<void>;
|
|
250
|
-
}
|
|
251
|
-
interface UsePlanOptions {
|
|
252
|
-
/** Plan reference (e.g. `'pln_premium'`). */
|
|
253
|
-
planRef?: string;
|
|
254
|
-
/**
|
|
255
|
-
* Optional product reference. When provided, the hook reuses the
|
|
256
|
-
* `usePlans` cache instead of fetching a dedicated plan endpoint.
|
|
257
|
-
*/
|
|
258
|
-
productRef?: string;
|
|
259
|
-
/**
|
|
260
|
-
* Fetcher for plan lookup when `productRef` is not provided. Required in
|
|
261
|
-
* that mode so the hook stays dependency-free.
|
|
262
|
-
*/
|
|
263
|
-
fetcher?: (productRef: string) => Promise<Plan[]>;
|
|
264
|
-
}
|
|
265
|
-
interface UsePlanReturn {
|
|
266
|
-
plan: Plan | null;
|
|
267
|
-
loading: boolean;
|
|
268
|
-
error: Error | null;
|
|
269
|
-
refetch: () => Promise<void>;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Optional customer fields forwarded to payment-intent creation so the
|
|
273
|
-
* backend customer record is authoritative. Read back via `useCustomer()`
|
|
274
|
-
* after the intent is created.
|
|
275
|
-
*/
|
|
276
|
-
interface PrefillCustomer {
|
|
277
|
-
name?: string;
|
|
278
|
-
email?: string;
|
|
279
|
-
}
|
|
280
|
-
interface TopupPaymentResult {
|
|
281
|
-
clientSecret: string;
|
|
282
|
-
publishableKey: string;
|
|
283
|
-
accountId?: string;
|
|
284
|
-
customerRef?: string;
|
|
285
|
-
}
|
|
286
|
-
interface UseTopupOptions {
|
|
287
|
-
amount: number;
|
|
288
|
-
currency?: string;
|
|
289
|
-
}
|
|
290
|
-
interface UseTopupReturn {
|
|
291
|
-
loading: boolean;
|
|
292
|
-
error: Error | null;
|
|
293
|
-
stripePromise: Promise<_stripe_stripe_js.Stripe | null> | null;
|
|
294
|
-
clientSecret: string | null;
|
|
295
|
-
startTopup: () => Promise<void>;
|
|
296
|
-
reset: () => void;
|
|
297
|
-
}
|
|
298
|
-
interface TopupFormProps {
|
|
299
|
-
amount: number;
|
|
300
|
-
currency?: string;
|
|
301
|
-
onSuccess?: (paymentIntent: PaymentIntent) => void;
|
|
302
|
-
onError?: (error: Error) => void;
|
|
303
|
-
returnUrl?: string;
|
|
304
|
-
submitButtonText?: string;
|
|
305
|
-
className?: string;
|
|
306
|
-
buttonClassName?: string;
|
|
307
|
-
}
|
|
308
|
-
interface PurchaseStatus {
|
|
309
|
-
loading: boolean;
|
|
310
|
-
/** True when data already exists but a background refetch is in progress */
|
|
311
|
-
isRefetching: boolean;
|
|
312
|
-
/** Last fetch error, or null if the most recent fetch succeeded */
|
|
313
|
-
error: Error | null;
|
|
314
|
-
customerRef?: string;
|
|
315
|
-
email?: string;
|
|
316
|
-
name?: string;
|
|
317
|
-
purchases: PurchaseInfo[];
|
|
318
|
-
hasProduct: (productName: string) => boolean;
|
|
319
|
-
/** @deprecated Use hasProduct instead */
|
|
320
|
-
hasPlan: (productName: string) => boolean;
|
|
321
|
-
/**
|
|
322
|
-
* Primary active purchase (paid or free) - most recent purchase with status === 'active'
|
|
323
|
-
* Backend keeps purchases as 'active' until expiration, even when cancelled.
|
|
324
|
-
* null if no active purchase exists
|
|
325
|
-
*/
|
|
326
|
-
activePurchase: PurchaseInfo | null;
|
|
327
|
-
/**
|
|
328
|
-
* Check if user has any active paid purchase (amount > 0)
|
|
329
|
-
* Checks purchases with status === 'active'.
|
|
330
|
-
* Backend keeps purchases as 'active' until expiration, even when cancelled.
|
|
331
|
-
*/
|
|
332
|
-
hasPaidPurchase: boolean;
|
|
333
|
-
/**
|
|
334
|
-
* Most recent active paid purchase (sorted by startDate)
|
|
335
|
-
* Returns purchase with status === 'active' and amount > 0.
|
|
336
|
-
* null if no active paid purchase exists
|
|
337
|
-
*/
|
|
338
|
-
activePaidPurchase: PurchaseInfo | null;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* SolvaPay Provider Configuration
|
|
342
|
-
* Sensible defaults for minimal code, but fully customizable
|
|
343
|
-
*/
|
|
344
|
-
interface BalanceStatus {
|
|
345
|
-
loading: boolean;
|
|
346
|
-
credits: number | null;
|
|
347
|
-
displayCurrency: string | null;
|
|
348
|
-
creditsPerMinorUnit: number | null;
|
|
349
|
-
displayExchangeRate: number | null;
|
|
350
|
-
refetch: () => Promise<void>;
|
|
351
|
-
adjustBalance: (credits: number) => void;
|
|
352
|
-
}
|
|
353
|
-
interface SolvaPayConfig {
|
|
354
|
-
/**
|
|
355
|
-
* API route configuration
|
|
356
|
-
* Defaults to standard Next.js API routes
|
|
357
|
-
*/
|
|
358
|
-
api?: {
|
|
359
|
-
checkPurchase?: string;
|
|
360
|
-
createPayment?: string;
|
|
361
|
-
processPayment?: string;
|
|
362
|
-
createTopupPayment?: string;
|
|
363
|
-
customerBalance?: string;
|
|
364
|
-
cancelRenewal?: string;
|
|
365
|
-
reactivateRenewal?: string;
|
|
366
|
-
activatePlan?: string;
|
|
367
|
-
listPlans?: string;
|
|
368
|
-
getMerchant?: string;
|
|
369
|
-
getProduct?: string;
|
|
370
|
-
};
|
|
371
|
-
/**
|
|
372
|
-
* BCP-47 locale tag (e.g. 'en', 'sv-SE'). Threaded through every SDK
|
|
373
|
-
* component, `Intl.NumberFormat`, and Stripe Elements. Defaults to the
|
|
374
|
-
* runtime default (typically 'en').
|
|
375
|
-
*/
|
|
376
|
-
locale?: string;
|
|
377
|
-
/**
|
|
378
|
-
* Partial copy overrides. Keys not supplied fall back to the bundled English
|
|
379
|
-
* defaults — consumers only provide the strings they actually want to change.
|
|
380
|
-
*/
|
|
381
|
-
copy?: PartialSolvaPayCopy;
|
|
382
|
-
/**
|
|
383
|
-
* Authentication configuration
|
|
384
|
-
* Uses adapter pattern for flexible auth provider support
|
|
385
|
-
*/
|
|
386
|
-
auth?: {
|
|
387
|
-
/**
|
|
388
|
-
* Auth adapter instance
|
|
389
|
-
* Default: checks localStorage for 'auth_token' key
|
|
390
|
-
*
|
|
391
|
-
* @example
|
|
392
|
-
* ```tsx
|
|
393
|
-
* import { createSupabaseAuthAdapter } from '@solvapay/react-supabase';
|
|
394
|
-
*
|
|
395
|
-
* <SolvaPayProvider
|
|
396
|
-
* config={{
|
|
397
|
-
* auth: {
|
|
398
|
-
* adapter: createSupabaseAuthAdapter({
|
|
399
|
-
* supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
400
|
-
* supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
401
|
-
* })
|
|
402
|
-
* }
|
|
403
|
-
* }}
|
|
404
|
-
* >
|
|
405
|
-
* ```
|
|
406
|
-
*/
|
|
407
|
-
adapter?: AuthAdapter;
|
|
408
|
-
/**
|
|
409
|
-
* @deprecated Use `adapter` instead. Will be removed in a future version.
|
|
410
|
-
* Function to get auth token
|
|
411
|
-
*/
|
|
412
|
-
getToken?: () => Promise<string | null>;
|
|
413
|
-
/**
|
|
414
|
-
* @deprecated Use `adapter` instead. Will be removed in a future version.
|
|
415
|
-
* Function to get user ID (for cache key)
|
|
416
|
-
*/
|
|
417
|
-
getUserId?: () => Promise<string | null>;
|
|
418
|
-
};
|
|
419
|
-
/**
|
|
420
|
-
* Custom fetch implementation
|
|
421
|
-
* Default: uses global fetch
|
|
422
|
-
*/
|
|
423
|
-
fetch?: typeof fetch;
|
|
424
|
-
/**
|
|
425
|
-
* Request headers to include in all API calls
|
|
426
|
-
* Default: empty
|
|
427
|
-
*/
|
|
428
|
-
headers?: HeadersInit | (() => Promise<HeadersInit>);
|
|
429
|
-
/**
|
|
430
|
-
* Custom error handler
|
|
431
|
-
* Default: logs to console
|
|
432
|
-
*/
|
|
433
|
-
onError?: (error: Error, context: string) => void;
|
|
434
|
-
}
|
|
435
|
-
interface CancelResult {
|
|
436
|
-
reference?: string;
|
|
437
|
-
status?: string;
|
|
438
|
-
cancelledAt?: string;
|
|
439
|
-
[key: string]: unknown;
|
|
440
|
-
}
|
|
441
|
-
interface ReactivateResult {
|
|
442
|
-
reference?: string;
|
|
443
|
-
status?: string;
|
|
444
|
-
[key: string]: unknown;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
interface SolvaPayContextValue {
|
|
448
|
-
purchase: PurchaseStatus;
|
|
449
|
-
refetchPurchase: () => Promise<void>;
|
|
450
|
-
createPayment: (params: {
|
|
451
|
-
planRef?: string;
|
|
452
|
-
productRef?: string;
|
|
453
|
-
customer?: PrefillCustomer;
|
|
454
|
-
}) => Promise<PaymentIntentResult>;
|
|
455
|
-
processPayment?: (params: {
|
|
456
|
-
paymentIntentId: string;
|
|
457
|
-
productRef: string;
|
|
458
|
-
planRef?: string;
|
|
459
|
-
}) => Promise<ProcessPaymentResult>;
|
|
460
|
-
createTopupPayment: (params: {
|
|
461
|
-
amount: number;
|
|
462
|
-
currency?: string;
|
|
463
|
-
}) => Promise<TopupPaymentResult>;
|
|
464
|
-
cancelRenewal: (params: {
|
|
465
|
-
purchaseRef: string;
|
|
466
|
-
reason?: string;
|
|
467
|
-
}) => Promise<CancelResult>;
|
|
468
|
-
reactivateRenewal: (params: {
|
|
469
|
-
purchaseRef: string;
|
|
470
|
-
}) => Promise<ReactivateResult>;
|
|
471
|
-
activatePlan: (params: {
|
|
472
|
-
productRef: string;
|
|
473
|
-
planRef: string;
|
|
474
|
-
}) => Promise<ActivatePlanResult>;
|
|
475
|
-
customerRef?: string;
|
|
476
|
-
updateCustomerRef?: (newCustomerRef: string) => void;
|
|
477
|
-
balance: BalanceStatus;
|
|
478
|
-
/** @internal Provider config — used by SDK hooks, not part of public API */
|
|
479
|
-
_config?: SolvaPayConfig;
|
|
480
|
-
}
|
|
481
|
-
interface SolvaPayProviderProps {
|
|
482
|
-
/**
|
|
483
|
-
* Configuration object with sensible defaults
|
|
484
|
-
* If not provided, uses standard Next.js API routes
|
|
485
|
-
*/
|
|
486
|
-
config?: SolvaPayConfig;
|
|
487
|
-
/**
|
|
488
|
-
* Custom API functions (override config defaults)
|
|
489
|
-
* Use only if you need custom logic beyond standard API routes
|
|
490
|
-
*/
|
|
491
|
-
createPayment?: (params: {
|
|
492
|
-
planRef?: string;
|
|
493
|
-
productRef?: string;
|
|
494
|
-
customer?: PrefillCustomer;
|
|
495
|
-
}) => Promise<PaymentIntentResult>;
|
|
496
|
-
checkPurchase?: () => Promise<CustomerPurchaseData>;
|
|
497
|
-
processPayment?: (params: {
|
|
498
|
-
paymentIntentId: string;
|
|
499
|
-
productRef: string;
|
|
500
|
-
planRef?: string;
|
|
501
|
-
}) => Promise<ProcessPaymentResult>;
|
|
502
|
-
createTopupPayment?: (params: {
|
|
503
|
-
amount: number;
|
|
504
|
-
currency?: string;
|
|
505
|
-
}) => Promise<TopupPaymentResult>;
|
|
506
|
-
children: React.ReactNode;
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Error type for payment operations
|
|
510
|
-
*/
|
|
511
|
-
interface PaymentError extends Error {
|
|
512
|
-
code?: string;
|
|
513
|
-
type?: string;
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Plan returned by the SolvaPay API.
|
|
517
|
-
*
|
|
518
|
-
* All fields are optional except `reference` so the type stays compatible
|
|
519
|
-
* with partial JSON responses from custom fetcher functions.
|
|
520
|
-
*/
|
|
521
|
-
interface Plan {
|
|
522
|
-
type?: 'recurring' | 'one-time' | 'usage-based';
|
|
523
|
-
reference: string;
|
|
524
|
-
name?: string;
|
|
525
|
-
description?: string;
|
|
526
|
-
price?: number;
|
|
527
|
-
currency?: string;
|
|
528
|
-
currencySymbol?: string;
|
|
529
|
-
freeUnits?: number;
|
|
530
|
-
setupFee?: number;
|
|
531
|
-
trialDays?: number;
|
|
532
|
-
billingCycle?: string;
|
|
533
|
-
billingModel?: 'pre-paid' | 'post-paid';
|
|
534
|
-
creditsPerUnit?: number;
|
|
535
|
-
measures?: string;
|
|
536
|
-
limit?: number;
|
|
537
|
-
rolloverUnusedUnits?: boolean;
|
|
538
|
-
limits?: Record<string, unknown>;
|
|
539
|
-
features?: Record<string, unknown> | string[];
|
|
540
|
-
requiresPayment?: boolean;
|
|
541
|
-
default?: boolean;
|
|
542
|
-
isActive?: boolean;
|
|
543
|
-
maxActiveUsers?: number;
|
|
544
|
-
accessExpiryDays?: number;
|
|
545
|
-
status?: string;
|
|
546
|
-
createdAt?: string;
|
|
547
|
-
updatedAt?: string;
|
|
548
|
-
interval?: string;
|
|
549
|
-
metadata?: Record<string, unknown>;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Options for usePlans hook
|
|
553
|
-
*/
|
|
554
|
-
interface UsePlansOptions {
|
|
555
|
-
/**
|
|
556
|
-
* Fetcher function to retrieve plans
|
|
557
|
-
*/
|
|
558
|
-
fetcher: (productRef: string) => Promise<Plan[]>;
|
|
559
|
-
/**
|
|
560
|
-
* Product reference to fetch plans for
|
|
561
|
-
*/
|
|
562
|
-
productRef?: string;
|
|
563
|
-
/**
|
|
564
|
-
* Optional filter function to filter plans.
|
|
565
|
-
* Receives plan and its index (after sorting, if sortBy is provided).
|
|
566
|
-
*/
|
|
567
|
-
filter?: (plan: Plan, index: number) => boolean;
|
|
568
|
-
/**
|
|
569
|
-
* Optional sort function to sort plans
|
|
570
|
-
*/
|
|
571
|
-
sortBy?: (a: Plan, b: Plan) => number;
|
|
572
|
-
/**
|
|
573
|
-
* Auto-select first paid plan on load
|
|
574
|
-
*/
|
|
575
|
-
autoSelectFirstPaid?: boolean;
|
|
576
|
-
/**
|
|
577
|
-
* Plan reference to select initially when plans load.
|
|
578
|
-
* Applied at most once when selectionReady is true.
|
|
579
|
-
* Takes priority over autoSelectFirstPaid.
|
|
580
|
-
*/
|
|
581
|
-
initialPlanRef?: string;
|
|
582
|
-
/**
|
|
583
|
-
* When false, plans still fetch but auto-selection is deferred.
|
|
584
|
-
* When it transitions to true, one-shot initial selection fires.
|
|
585
|
-
* Defaults to true.
|
|
586
|
-
*/
|
|
587
|
-
selectionReady?: boolean;
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* Return type for usePlans hook
|
|
591
|
-
*/
|
|
592
|
-
interface UsePlansReturn {
|
|
593
|
-
plans: Plan[];
|
|
594
|
-
loading: boolean;
|
|
595
|
-
error: Error | null;
|
|
596
|
-
selectedPlanIndex: number;
|
|
597
|
-
selectedPlan: Plan | null;
|
|
598
|
-
setSelectedPlanIndex: (index: number) => void;
|
|
599
|
-
selectPlan: (planRef: string) => void;
|
|
600
|
-
refetch: () => Promise<void>;
|
|
601
|
-
/** True after the one-shot initial selection has been applied */
|
|
602
|
-
isSelectionReady: boolean;
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* Return type for usePurchaseStatus hook
|
|
606
|
-
*
|
|
607
|
-
* Provides advanced purchase status helpers and utilities.
|
|
608
|
-
* Focuses on cancelled purchase logic and date formatting.
|
|
609
|
-
* For basic purchase data and paid status, use usePurchase() instead.
|
|
610
|
-
*/
|
|
611
|
-
interface PurchaseStatusReturn {
|
|
612
|
-
/**
|
|
613
|
-
* Most recent cancelled paid purchase (sorted by startDate)
|
|
614
|
-
* null if no cancelled paid purchase exists
|
|
615
|
-
*/
|
|
616
|
-
cancelledPurchase: PurchaseInfo | null;
|
|
617
|
-
/**
|
|
618
|
-
* Whether to show cancelled purchase notice
|
|
619
|
-
* true if cancelledPurchase exists
|
|
620
|
-
*/
|
|
621
|
-
shouldShowCancelledNotice: boolean;
|
|
622
|
-
/**
|
|
623
|
-
* Format a date string to locale format (e.g., "January 15, 2024")
|
|
624
|
-
* Returns null if dateString is not provided
|
|
625
|
-
*/
|
|
626
|
-
formatDate: (dateString?: string) => string | null;
|
|
627
|
-
/**
|
|
628
|
-
* Calculate days until expiration date
|
|
629
|
-
* Returns null if endDate is not provided, otherwise returns days (0 or positive)
|
|
630
|
-
*/
|
|
631
|
-
getDaysUntilExpiration: (endDate?: string) => number | null;
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Payment form props - simplified and minimal
|
|
635
|
-
*/
|
|
636
|
-
/**
|
|
637
|
-
* Discriminated checkout-completion result surfaced by `<PaymentForm>` and
|
|
638
|
-
* `<CheckoutLayout>` via their `onResult` callback. Integrators handling
|
|
639
|
-
* both paid and free plans should use `onResult` to get a single typed
|
|
640
|
-
* callback; paid-only integrators keep using `onSuccess(paymentIntent)`.
|
|
641
|
-
*/
|
|
642
|
-
type PaymentResult = {
|
|
643
|
-
kind: 'paid';
|
|
644
|
-
paymentIntent: PaymentIntent;
|
|
645
|
-
};
|
|
646
|
-
type ActivationResult = {
|
|
647
|
-
kind: 'activated';
|
|
648
|
-
result: ActivatePlanResult;
|
|
649
|
-
};
|
|
650
|
-
type CheckoutResult = PaymentResult | ActivationResult;
|
|
651
|
-
interface PaymentFormProps {
|
|
652
|
-
/**
|
|
653
|
-
* Plan reference to checkout. When omitted, the SDK auto-resolves the plan from
|
|
654
|
-
* productRef (requires exactly one active plan or a default plan). Pass explicitly
|
|
655
|
-
* when the product has multiple plans without a default.
|
|
656
|
-
*/
|
|
657
|
-
planRef?: string;
|
|
658
|
-
/**
|
|
659
|
-
* Product reference. Required when planRef is omitted (for plan resolution)
|
|
660
|
-
* and for processing payment after confirmation.
|
|
661
|
-
*/
|
|
662
|
-
productRef?: string;
|
|
663
|
-
/**
|
|
664
|
-
* Callback when payment succeeds. Fires on paid flows only — preserved
|
|
665
|
-
* exactly for backwards compatibility. Free/activation flows do NOT fire
|
|
666
|
-
* `onSuccess`; use `onResult` to receive both paid and activated results.
|
|
667
|
-
*/
|
|
668
|
-
onSuccess?: (paymentIntent: PaymentIntent) => void;
|
|
669
|
-
/**
|
|
670
|
-
* Unified callback fired on both paid and activated completions with a
|
|
671
|
-
* discriminated result. Safe to provide alongside `onSuccess` — for paid
|
|
672
|
-
* flows both fire (in order: `onSuccess` first, then `onResult`).
|
|
673
|
-
*/
|
|
674
|
-
onResult?: (result: CheckoutResult) => void;
|
|
675
|
-
/**
|
|
676
|
-
* Override the default free-plan activation step. When provided, the form
|
|
677
|
-
* awaits this promise on submit and fires `onResult` when it resolves.
|
|
678
|
-
* When omitted, the default behavior calls `activatePlan` from context.
|
|
679
|
-
*/
|
|
680
|
-
onFreePlan?: (plan: Plan) => Promise<unknown> | void;
|
|
681
|
-
/**
|
|
682
|
-
* Callback when payment fails
|
|
683
|
-
*/
|
|
684
|
-
onError?: (error: Error) => void;
|
|
685
|
-
/**
|
|
686
|
-
* Return URL after payment completion. Defaults to current page URL if not provided.
|
|
687
|
-
*/
|
|
688
|
-
returnUrl?: string;
|
|
689
|
-
/**
|
|
690
|
-
* Text for the submit button. Defaults to "Pay Now"
|
|
691
|
-
*/
|
|
692
|
-
submitButtonText?: string;
|
|
693
|
-
/**
|
|
694
|
-
* Optional className for the form container
|
|
695
|
-
*/
|
|
696
|
-
className?: string;
|
|
697
|
-
/**
|
|
698
|
-
* Optional className for the submit button
|
|
699
|
-
*/
|
|
700
|
-
buttonClassName?: string;
|
|
701
|
-
/**
|
|
702
|
-
* Customer name/email to forward to backend PaymentIntent creation so the
|
|
703
|
-
* server-side customer record is authoritative. Echoed back via
|
|
704
|
-
* `useCustomer()` after the intent is created.
|
|
705
|
-
*/
|
|
706
|
-
prefillCustomer?: PrefillCustomer;
|
|
707
|
-
/**
|
|
708
|
-
* When true, the default tree renders a terms/privacy checkbox and gates
|
|
709
|
-
* the submit button until it is ticked. No-op when custom `children` are
|
|
710
|
-
* passed — compose `<PaymentForm.TermsCheckbox />` yourself.
|
|
711
|
-
*/
|
|
712
|
-
requireTermsAcceptance?: boolean;
|
|
713
|
-
}
|
|
714
|
-
interface UseTopupAmountSelectorOptions {
|
|
715
|
-
currency: string;
|
|
716
|
-
minAmount?: number;
|
|
717
|
-
maxAmount?: number;
|
|
718
|
-
}
|
|
719
|
-
interface UseTopupAmountSelectorReturn {
|
|
720
|
-
quickAmounts: number[];
|
|
721
|
-
selectedAmount: number | null;
|
|
722
|
-
customAmount: string;
|
|
723
|
-
resolvedAmount: number | null;
|
|
724
|
-
selectQuickAmount: (amount: number) => void;
|
|
725
|
-
setCustomAmount: (value: string) => void;
|
|
726
|
-
error: string | null;
|
|
727
|
-
validate: () => boolean;
|
|
728
|
-
reset: () => void;
|
|
729
|
-
currencySymbol: string;
|
|
730
|
-
}
|
|
731
|
-
type PurchaseStatusValue = 'pending' | 'active' | 'trialing' | 'past_due' | 'cancelled' | 'expired' | 'suspended' | 'refunded';
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* Default-tree shim over the `CheckoutSummary` primitive.
|
|
735
|
-
*
|
|
736
|
-
* Renders a product/plan/price line with optional trial + tax-note slots.
|
|
737
|
-
* Full control (ordering, custom elements, Tailwind variants) is available
|
|
738
|
-
* via the primitives at `@solvapay/react/primitives`.
|
|
739
|
-
*/
|
|
740
|
-
|
|
741
|
-
type CheckoutSummaryProps = {
|
|
742
|
-
planRef?: string;
|
|
743
|
-
productRef?: string;
|
|
744
|
-
showTrial?: boolean;
|
|
745
|
-
showTaxNote?: boolean;
|
|
746
|
-
className?: string;
|
|
747
|
-
};
|
|
748
|
-
declare const CheckoutSummary: React$1.FC<CheckoutSummaryProps>;
|
|
749
|
-
|
|
750
|
-
/**
|
|
751
|
-
* Checkout "shape" — drives the mandate variant, the submit-button CTA, and
|
|
752
|
-
* the button `aria-label` in lockstep so those three strings always agree.
|
|
753
|
-
*/
|
|
754
|
-
type CheckoutVariant = 'recurring' | 'oneTime' | 'topup' | 'usageMetered' | 'freeTier';
|
|
755
|
-
/**
|
|
756
|
-
* Derive the variant from the plan's type + billing model. Unknown or missing
|
|
757
|
-
* plans default to `'oneTime'`, which matches the canonical "Pay Now" UX.
|
|
758
|
-
*
|
|
759
|
-
* Free plans (`requiresPayment === false`) that are NOT usage-metered route
|
|
760
|
-
* to the `'freeTier'` variant. Metered free/usage plans stay on
|
|
761
|
-
* `'usageMetered'` because the mandate copy there already covers pay-as-you-go.
|
|
762
|
-
*/
|
|
763
|
-
declare function deriveVariant(plan: Plan | null | undefined, mode?: 'topup'): CheckoutVariant;
|
|
764
|
-
|
|
765
|
-
/**
|
|
766
|
-
* MandateText leaf primitive.
|
|
767
|
-
*
|
|
768
|
-
* Renders SCA-compliant authorization copy derived from the resolved plan,
|
|
769
|
-
* product, and merchant identity. Variant is derived from the plan type +
|
|
770
|
-
* billing model and can be forced via the `variant` or `mode` props (use
|
|
771
|
-
* `mode="topup"` inside `<TopupForm>` where there is no plan). All strings
|
|
772
|
-
* resolve through the localized copy bundle so integrators can override
|
|
773
|
-
* text without forking the component.
|
|
774
|
-
*/
|
|
775
|
-
|
|
776
|
-
type MandateTextProps = {
|
|
777
|
-
planRef?: string;
|
|
778
|
-
productRef?: string;
|
|
779
|
-
variant?: CheckoutVariant;
|
|
780
|
-
mode?: 'topup';
|
|
781
|
-
amountMinor?: number;
|
|
782
|
-
currency?: string;
|
|
783
|
-
asChild?: boolean;
|
|
784
|
-
} & Omit<React$1.HTMLAttributes<HTMLParagraphElement>, 'children'> & {
|
|
785
|
-
children?: React$1.ReactNode;
|
|
786
|
-
};
|
|
787
|
-
declare const MandateText: React$1.ForwardRefExoticComponent<{
|
|
788
|
-
planRef?: string;
|
|
789
|
-
productRef?: string;
|
|
790
|
-
variant?: CheckoutVariant;
|
|
791
|
-
mode?: "topup";
|
|
792
|
-
amountMinor?: number;
|
|
793
|
-
currency?: string;
|
|
794
|
-
asChild?: boolean;
|
|
795
|
-
} & Omit<React$1.HTMLAttributes<HTMLParagraphElement>, "children"> & {
|
|
796
|
-
children?: React$1.ReactNode;
|
|
797
|
-
} & React$1.RefAttributes<HTMLParagraphElement>>;
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* PaymentForm compound primitive.
|
|
801
|
-
*
|
|
802
|
-
* Unstyled, accessible building blocks for running the paid OR free checkout
|
|
803
|
-
* step inside a <SolvaPayProvider>. `Root` detects paid vs free plans via
|
|
804
|
-
* `usePlan`, wires Stripe Elements for paid plans, or falls through to
|
|
805
|
-
* `useActivation` for free plans; both paths expose the same
|
|
806
|
-
* `PaymentFormContext` so the same subcomponents compose identically in
|
|
807
|
-
* either mode.
|
|
808
|
-
*
|
|
809
|
-
* Every leaf accepts `asChild` for Slot-style composition. The `SubmitButton`
|
|
810
|
-
* emits `data-state=idle|processing|disabled` + `data-variant=paid|free|topup|activate`.
|
|
811
|
-
*/
|
|
812
|
-
|
|
813
|
-
type SummaryProps = Omit<React$1.ComponentProps<typeof CheckoutSummary>, 'planRef' | 'productRef'>;
|
|
814
|
-
type MandateTextPrimitiveProps = Omit<React$1.ComponentProps<typeof MandateText>, 'planRef' | 'productRef'>;
|
|
815
|
-
type PaymentElementProps = {
|
|
816
|
-
options?: React$1.ComponentProps<typeof PaymentElement>['options'];
|
|
817
|
-
};
|
|
818
|
-
type CardElementProps = {
|
|
819
|
-
options?: React$1.ComponentProps<typeof CardElement>['options'];
|
|
820
|
-
};
|
|
821
|
-
declare const PaymentFormRoot: React$1.ForwardRefExoticComponent<PaymentFormProps & {
|
|
822
|
-
prefillCustomer?: PrefillCustomer;
|
|
823
|
-
requireTermsAcceptance?: boolean;
|
|
824
|
-
children?: React$1.ReactNode;
|
|
825
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
826
|
-
declare const PaymentFormSummary: React$1.FC<SummaryProps>;
|
|
827
|
-
declare const PaymentFormCustomerFields: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
828
|
-
asChild?: boolean;
|
|
829
|
-
readOnly?: boolean;
|
|
830
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
831
|
-
declare const PaymentFormPaymentElement: React$1.FC<PaymentElementProps>;
|
|
832
|
-
declare const PaymentFormCardElement: React$1.FC<CardElementProps>;
|
|
833
|
-
declare const PaymentFormMandateText: React$1.FC<MandateTextPrimitiveProps>;
|
|
834
|
-
declare const PaymentFormTermsCheckbox: React$1.ForwardRefExoticComponent<React$1.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
835
|
-
asChild?: boolean;
|
|
836
|
-
label?: React$1.ReactNode;
|
|
837
|
-
} & React$1.RefAttributes<HTMLLabelElement>>;
|
|
838
|
-
declare const PaymentFormSubmitButton: React$1.ForwardRefExoticComponent<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
839
|
-
asChild?: boolean;
|
|
840
|
-
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
841
|
-
declare const PaymentFormLoading: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
842
|
-
asChild?: boolean;
|
|
843
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
844
|
-
declare const PaymentFormError: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
845
|
-
asChild?: boolean;
|
|
846
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
847
|
-
declare const PaymentForm: {
|
|
848
|
-
readonly Root: React$1.ForwardRefExoticComponent<PaymentFormProps & {
|
|
849
|
-
prefillCustomer?: PrefillCustomer;
|
|
850
|
-
requireTermsAcceptance?: boolean;
|
|
851
|
-
children?: React$1.ReactNode;
|
|
852
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
853
|
-
readonly Summary: React$1.FC<SummaryProps>;
|
|
854
|
-
readonly CustomerFields: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
855
|
-
asChild?: boolean;
|
|
856
|
-
readOnly?: boolean;
|
|
857
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
858
|
-
readonly PaymentElement: React$1.FC<PaymentElementProps>;
|
|
859
|
-
readonly CardElement: React$1.FC<CardElementProps>;
|
|
860
|
-
readonly MandateText: React$1.FC<MandateTextPrimitiveProps>;
|
|
861
|
-
readonly TermsCheckbox: React$1.ForwardRefExoticComponent<React$1.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
862
|
-
asChild?: boolean;
|
|
863
|
-
label?: React$1.ReactNode;
|
|
864
|
-
} & React$1.RefAttributes<HTMLLabelElement>>;
|
|
865
|
-
readonly SubmitButton: React$1.ForwardRefExoticComponent<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
866
|
-
asChild?: boolean;
|
|
867
|
-
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
868
|
-
readonly Loading: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
869
|
-
asChild?: boolean;
|
|
870
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
871
|
-
readonly Error: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
872
|
-
asChild?: boolean;
|
|
873
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* ProductBadge compound primitive.
|
|
878
|
-
*
|
|
879
|
-
* Single leaf that renders the customer's current product name when an
|
|
880
|
-
* active purchase exists. Emits `data-has-purchase` + `data-has-paid-purchase`
|
|
881
|
-
* flags and forwards an `aria-label` derived from the copy bundle.
|
|
882
|
-
* `PlanBadge` is an alias retained for backwards compatibility with older
|
|
883
|
-
* integrations — both point at the same component.
|
|
884
|
-
*/
|
|
885
|
-
|
|
886
|
-
declare const ProductBadge: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLElement> & {
|
|
887
|
-
asChild?: boolean;
|
|
888
|
-
} & React$1.RefAttributes<HTMLElement>>;
|
|
889
|
-
/** @deprecated Use `ProductBadge` instead. Kept as an alias for existing integrations. */
|
|
890
|
-
declare const PlanBadge: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLElement> & {
|
|
891
|
-
asChild?: boolean;
|
|
892
|
-
} & React$1.RefAttributes<HTMLElement>>;
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* PurchaseGate compound primitive.
|
|
896
|
-
*
|
|
897
|
-
* Controls access to gated content based on whether the customer has an
|
|
898
|
-
* active purchase (optionally scoped to a product). `Root` exposes
|
|
899
|
-
* `data-state=allowed|blocked|loading` and context-drives the
|
|
900
|
-
* `Allowed`, `Blocked`, `Loading`, and `Error` subcomponents.
|
|
901
|
-
*/
|
|
902
|
-
|
|
903
|
-
type GateState = 'allowed' | 'blocked' | 'loading';
|
|
904
|
-
type PurchaseGateContextValue = {
|
|
905
|
-
state: GateState;
|
|
906
|
-
loading: boolean;
|
|
907
|
-
hasAccess: boolean;
|
|
908
|
-
error: Error | null;
|
|
909
|
-
};
|
|
910
|
-
declare const PurchaseGateRoot: React$1.ForwardRefExoticComponent<{
|
|
911
|
-
/** @deprecated Use `requireProduct`. */
|
|
912
|
-
requirePlan?: string;
|
|
913
|
-
requireProduct?: string;
|
|
914
|
-
asChild?: boolean;
|
|
915
|
-
children?: React$1.ReactNode;
|
|
916
|
-
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
917
|
-
declare const PurchaseGateAllowed: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
918
|
-
asChild?: boolean;
|
|
919
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
920
|
-
declare const PurchaseGateBlocked: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
921
|
-
asChild?: boolean;
|
|
922
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
923
|
-
declare const PurchaseGateLoading: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
924
|
-
asChild?: boolean;
|
|
925
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
926
|
-
declare const PurchaseGateError: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
927
|
-
asChild?: boolean;
|
|
928
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
929
|
-
declare const PurchaseGate: {
|
|
930
|
-
readonly Root: React$1.ForwardRefExoticComponent<{
|
|
931
|
-
/** @deprecated Use `requireProduct`. */
|
|
932
|
-
requirePlan?: string;
|
|
933
|
-
requireProduct?: string;
|
|
934
|
-
asChild?: boolean;
|
|
935
|
-
children?: React$1.ReactNode;
|
|
936
|
-
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
937
|
-
readonly Allowed: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
938
|
-
asChild?: boolean;
|
|
939
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
940
|
-
readonly Blocked: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
941
|
-
asChild?: boolean;
|
|
942
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
943
|
-
readonly Loading: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
944
|
-
asChild?: boolean;
|
|
945
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
946
|
-
readonly Error: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
947
|
-
asChild?: boolean;
|
|
948
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
949
|
-
};
|
|
950
|
-
declare function usePurchaseGate(): PurchaseGateContextValue;
|
|
951
|
-
|
|
952
|
-
/**
|
|
953
|
-
* BalanceBadge leaf primitive.
|
|
954
|
-
*
|
|
955
|
-
* Renders the customer's credit balance with an optional currency-equivalent
|
|
956
|
-
* suffix. Emits `data-state=loading|zero|low|ok` plus a `data-credits`
|
|
957
|
-
* attribute for CSS targeting. Low-balance threshold is configurable via the
|
|
958
|
-
* `lowThreshold` prop (defaults to 10).
|
|
959
|
-
*/
|
|
960
|
-
|
|
961
|
-
declare const BalanceBadge: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLSpanElement> & {
|
|
962
|
-
asChild?: boolean;
|
|
963
|
-
/** Hide the trailing " credits" label + currency equivalent. */
|
|
964
|
-
numberOnly?: boolean;
|
|
965
|
-
/** Balance threshold (inclusive) treated as `data-state="low"`. Defaults to 10. */
|
|
966
|
-
lowThreshold?: number;
|
|
967
|
-
} & React$1.RefAttributes<HTMLSpanElement>>;
|
|
968
|
-
|
|
969
|
-
/**
|
|
970
|
-
* ActivationFlow compound primitive.
|
|
971
|
-
*
|
|
972
|
-
* Drives the usage-based plan activation state machine:
|
|
973
|
-
* summary → activating → (topup_required → selectAmount → topupPayment →
|
|
974
|
-
* retrying) → activated | error.
|
|
975
|
-
*
|
|
976
|
-
* `Root` exposes `data-state` set to the current step and publishes the
|
|
977
|
-
* shared context consumed by leaves. Leaves render only during their
|
|
978
|
-
* matching step:
|
|
979
|
-
* - `Summary` — `summary` | `activating`
|
|
980
|
-
* - `ActivateButton` — `summary` | `activating`
|
|
981
|
-
* - `AmountPicker` — `selectAmount`
|
|
982
|
-
* - `ContinueButton` — `selectAmount`
|
|
983
|
-
* - `Retrying` — `retrying`
|
|
984
|
-
* - `Activated` — `activated`
|
|
985
|
-
* - `Loading` — renders when plan is not yet resolved
|
|
986
|
-
* - `Error` — `error`
|
|
987
|
-
*/
|
|
988
|
-
|
|
989
|
-
type ActivationFlowStep = 'summary' | 'activating' | 'selectAmount' | 'topupPayment' | 'retrying' | 'activated' | 'error';
|
|
990
|
-
type ActivationFlowContextValue = {
|
|
991
|
-
step: ActivationFlowStep;
|
|
992
|
-
plan: Plan | null;
|
|
993
|
-
productRef: string;
|
|
994
|
-
planRef: string;
|
|
995
|
-
amountSelector: UseTopupAmountSelectorReturn;
|
|
996
|
-
amountCents: number;
|
|
997
|
-
currency: string;
|
|
998
|
-
activate: () => Promise<void>;
|
|
999
|
-
reset: () => void;
|
|
1000
|
-
goToTopupPayment: () => void;
|
|
1001
|
-
backToSelectAmount: () => void;
|
|
1002
|
-
onTopupSuccess: () => Promise<void>;
|
|
1003
|
-
error: string | null;
|
|
1004
|
-
onError?: (error: Error) => void;
|
|
1005
|
-
};
|
|
1006
|
-
type AmountPickerMountProps = {
|
|
1007
|
-
children?: React$1.ReactNode;
|
|
1008
|
-
};
|
|
1009
|
-
declare const ActivationFlowRoot: React$1.ForwardRefExoticComponent<{
|
|
1010
|
-
productRef?: string;
|
|
1011
|
-
/** Defaults to PlanSelectionContext selection when omitted. */
|
|
1012
|
-
planRef?: string;
|
|
1013
|
-
onSuccess?: (result: ActivationResult) => void;
|
|
1014
|
-
onError?: (error: Error) => void;
|
|
1015
|
-
retryDelayMs?: number;
|
|
1016
|
-
retryBackoffMs?: number;
|
|
1017
|
-
asChild?: boolean;
|
|
1018
|
-
children?: React$1.ReactNode;
|
|
1019
|
-
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, "children" | "onError"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
1020
|
-
declare const ActivationFlowSummary: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1021
|
-
asChild?: boolean;
|
|
1022
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1023
|
-
declare const ActivationFlowActivateButton: React$1.ForwardRefExoticComponent<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
1024
|
-
asChild?: boolean;
|
|
1025
|
-
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
1026
|
-
declare const ActivationFlowAmountPicker: React$1.FC<AmountPickerMountProps>;
|
|
1027
|
-
declare const ActivationFlowContinueButton: React$1.ForwardRefExoticComponent<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
1028
|
-
asChild?: boolean;
|
|
1029
|
-
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
1030
|
-
declare const ActivationFlowRetrying: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1031
|
-
asChild?: boolean;
|
|
1032
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1033
|
-
declare const ActivationFlowActivated: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1034
|
-
asChild?: boolean;
|
|
1035
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1036
|
-
declare const ActivationFlowLoading: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1037
|
-
asChild?: boolean;
|
|
1038
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1039
|
-
declare const ActivationFlowError: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1040
|
-
asChild?: boolean;
|
|
1041
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1042
|
-
declare const ActivationFlow: {
|
|
1043
|
-
readonly Root: React$1.ForwardRefExoticComponent<{
|
|
1044
|
-
productRef?: string;
|
|
1045
|
-
/** Defaults to PlanSelectionContext selection when omitted. */
|
|
1046
|
-
planRef?: string;
|
|
1047
|
-
onSuccess?: (result: ActivationResult) => void;
|
|
1048
|
-
onError?: (error: Error) => void;
|
|
1049
|
-
retryDelayMs?: number;
|
|
1050
|
-
retryBackoffMs?: number;
|
|
1051
|
-
asChild?: boolean;
|
|
1052
|
-
children?: React$1.ReactNode;
|
|
1053
|
-
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, "children" | "onError"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
1054
|
-
readonly Summary: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1055
|
-
asChild?: boolean;
|
|
1056
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1057
|
-
readonly ActivateButton: React$1.ForwardRefExoticComponent<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
1058
|
-
asChild?: boolean;
|
|
1059
|
-
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
1060
|
-
readonly AmountPicker: React$1.FC<AmountPickerMountProps>;
|
|
1061
|
-
readonly ContinueButton: React$1.ForwardRefExoticComponent<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
1062
|
-
asChild?: boolean;
|
|
1063
|
-
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
1064
|
-
readonly Retrying: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1065
|
-
asChild?: boolean;
|
|
1066
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1067
|
-
readonly Activated: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1068
|
-
asChild?: boolean;
|
|
1069
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1070
|
-
readonly Loading: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1071
|
-
asChild?: boolean;
|
|
1072
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1073
|
-
readonly Error: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
1074
|
-
asChild?: boolean;
|
|
1075
|
-
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1076
|
-
};
|
|
1077
|
-
declare function useActivationFlow(): ActivationFlowContextValue;
|
|
1078
|
-
|
|
1079
|
-
/**
|
|
1080
|
-
* CancelPlanButton leaf primitive.
|
|
1081
|
-
*
|
|
1082
|
-
* Cancels the active (or specified) purchase via `usePurchaseActions`.
|
|
1083
|
-
* Emits `data-state=idle|cancelling` and auto-derives the confirm dialog
|
|
1084
|
-
* copy from the plan type (`recurring` vs. `usage-based`) unless overridden
|
|
1085
|
-
* via the `confirm` prop (`false` to skip, string to replace).
|
|
1086
|
-
*/
|
|
1087
|
-
|
|
1088
|
-
declare const CancelPlanButton: React$1.ForwardRefExoticComponent<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
1089
|
-
asChild?: boolean;
|
|
1090
|
-
/** Defaults to the active purchase from `usePurchase()`. */
|
|
1091
|
-
purchaseRef?: string;
|
|
1092
|
-
reason?: string;
|
|
1093
|
-
/**
|
|
1094
|
-
* Built-in confirm dialog. `true` (default) uses plan-type-aware copy;
|
|
1095
|
-
* a string replaces the copy; `false` skips confirmation.
|
|
1096
|
-
*/
|
|
1097
|
-
confirm?: boolean | string;
|
|
1098
|
-
onCancelled?: () => void;
|
|
1099
|
-
onError?: (error: Error) => void;
|
|
1100
|
-
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
1101
|
-
|
|
1102
|
-
export { PurchaseGate as $, type ActivationResult as A, type BalanceStatus as B, type CheckoutResult as C, type PurchaseInfo as D, type CheckoutVariant as E, type Product as F, type ActivationFlowStep as G, BalanceBadge as H, CancelPlanButton as I, CheckoutSummary as J, type CheckoutSummaryProps as K, type CustomerPurchaseData as L, type MandateContext as M, type MandateTemplate as N, MandateText as O, type PaymentFormProps as P, type MandateTextProps as Q, type ReactivateResult as R, type SolvaPayProviderProps as S, type TopupFormProps as T, type UsePlansOptions as U, type Merchant as V, type PaymentError as W, type PaymentIntentResult as X, type PaymentResult as Y, PlanBadge as Z, ProductBadge as _, type PrefillCustomer as a, type PurchaseStatusValue as a0, type SolvaPayConfig as a1, type TopupPaymentResult as a2, deriveVariant as a3, ActivationFlow as a4, ActivationFlowActivateButton as a5, ActivationFlowActivated as a6, ActivationFlowAmountPicker as a7, ActivationFlowContinueButton as a8, ActivationFlowError as a9, ActivationFlowLoading as aa, ActivationFlowRetrying as ab, ActivationFlowRoot as ac, ActivationFlowSummary as ad, PaymentForm as ae, PaymentFormRoot as af, PurchaseGateAllowed as ag, PurchaseGateBlocked as ah, PurchaseGateError as ai, PurchaseGateLoading as aj, PurchaseGateRoot as ak, useActivationFlow as al, usePurchaseGate as am, PaymentFormSummary as b, PaymentFormCustomerFields as c, PaymentFormPaymentElement as d, PaymentFormCardElement as e, PaymentFormMandateText as f, PaymentFormTermsCheckbox as g, PaymentFormSubmitButton as h, PaymentFormLoading as i, PaymentFormError as j, type Plan as k, type PurchaseStatus as l, type SolvaPayContextValue as m, type UsePlansReturn as n, type UsePlanOptions as o, type UsePlanReturn as p, type UseProductReturn as q, type UseMerchantReturn as r, type SolvaPayCopy as s, type PurchaseStatusReturn as t, type CancelResult as u, type UseTopupOptions as v, type UseTopupReturn as w, type UseTopupAmountSelectorOptions as x, type UseTopupAmountSelectorReturn as y, type PartialSolvaPayCopy as z };
|