@reevit/react 0.1.0
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/LICENSE +21 -0
- package/README.md +211 -0
- package/dist/index.d.mts +628 -0
- package/dist/index.d.ts +628 -0
- package/dist/index.js +1636 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1612 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +526 -0
- package/package.json +59 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reevit React SDK Types
|
|
5
|
+
* Core type definitions for the unified payment widget
|
|
6
|
+
*/
|
|
7
|
+
type PaymentMethod = 'card' | 'mobile_money' | 'bank_transfer';
|
|
8
|
+
type MobileMoneyNetwork = 'mtn' | 'vodafone' | 'airteltigo';
|
|
9
|
+
interface ReevitCheckoutConfig {
|
|
10
|
+
/** Your Reevit public key (pk_live_xxx or pk_test_xxx) */
|
|
11
|
+
publicKey: string;
|
|
12
|
+
/** Amount in the smallest currency unit (e.g., pesewas for GHS) */
|
|
13
|
+
amount: number;
|
|
14
|
+
/** Currency code (e.g., 'GHS', 'NGN', 'USD') */
|
|
15
|
+
currency: string;
|
|
16
|
+
/** Customer email address */
|
|
17
|
+
email?: string;
|
|
18
|
+
/** Customer phone number (required for mobile money) */
|
|
19
|
+
phone?: string;
|
|
20
|
+
/** Unique reference for this transaction */
|
|
21
|
+
reference?: string;
|
|
22
|
+
/** Additional metadata to attach to the payment */
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
/** Payment methods to display */
|
|
25
|
+
paymentMethods?: PaymentMethod[];
|
|
26
|
+
}
|
|
27
|
+
interface ReevitCheckoutCallbacks {
|
|
28
|
+
/** Called when payment is successful */
|
|
29
|
+
onSuccess?: (result: PaymentResult) => void;
|
|
30
|
+
/** Called when payment fails */
|
|
31
|
+
onError?: (error: PaymentError) => void;
|
|
32
|
+
/** Called when user closes the checkout */
|
|
33
|
+
onClose?: () => void;
|
|
34
|
+
/** Called when checkout state changes */
|
|
35
|
+
onStateChange?: (state: CheckoutState) => void;
|
|
36
|
+
}
|
|
37
|
+
interface ReevitCheckoutProps extends ReevitCheckoutConfig, ReevitCheckoutCallbacks {
|
|
38
|
+
/** Custom trigger element */
|
|
39
|
+
children?: React.ReactNode;
|
|
40
|
+
/** Whether to open automatically */
|
|
41
|
+
autoOpen?: boolean;
|
|
42
|
+
/** Custom theme */
|
|
43
|
+
theme?: ReevitTheme;
|
|
44
|
+
}
|
|
45
|
+
type CheckoutState = 'idle' | 'loading' | 'ready' | 'method_selected' | 'processing' | 'success' | 'failed' | 'closed';
|
|
46
|
+
interface PaymentResult {
|
|
47
|
+
/** Unique payment ID from Reevit */
|
|
48
|
+
paymentId: string;
|
|
49
|
+
/** Reference provided or generated */
|
|
50
|
+
reference: string;
|
|
51
|
+
/** Amount paid in smallest currency unit */
|
|
52
|
+
amount: number;
|
|
53
|
+
/** Currency code */
|
|
54
|
+
currency: string;
|
|
55
|
+
/** Payment method used */
|
|
56
|
+
paymentMethod: PaymentMethod;
|
|
57
|
+
/** PSP that processed the payment */
|
|
58
|
+
psp: string;
|
|
59
|
+
/** PSP's transaction reference */
|
|
60
|
+
pspReference: string;
|
|
61
|
+
/** Payment status */
|
|
62
|
+
status: 'success' | 'pending';
|
|
63
|
+
/** Any additional data from the PSP */
|
|
64
|
+
metadata?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
interface PaymentError {
|
|
67
|
+
/** Error code */
|
|
68
|
+
code: string;
|
|
69
|
+
/** Human-readable error message */
|
|
70
|
+
message: string;
|
|
71
|
+
/** Whether the error is recoverable (user can retry) */
|
|
72
|
+
recoverable?: boolean;
|
|
73
|
+
/** Original error from PSP if available */
|
|
74
|
+
originalError?: unknown;
|
|
75
|
+
/** Additional error details */
|
|
76
|
+
details?: Record<string, unknown>;
|
|
77
|
+
}
|
|
78
|
+
interface ReevitTheme {
|
|
79
|
+
/** Primary brand color */
|
|
80
|
+
primaryColor?: string;
|
|
81
|
+
/** Background color */
|
|
82
|
+
backgroundColor?: string;
|
|
83
|
+
/** Text color */
|
|
84
|
+
textColor?: string;
|
|
85
|
+
/** Border radius for inputs and buttons */
|
|
86
|
+
borderRadius?: string;
|
|
87
|
+
/** Font family to use */
|
|
88
|
+
fontFamily?: string;
|
|
89
|
+
/** Whether to use dark mode */
|
|
90
|
+
darkMode?: boolean;
|
|
91
|
+
}
|
|
92
|
+
interface MobileMoneyFormData {
|
|
93
|
+
phone: string;
|
|
94
|
+
network: MobileMoneyNetwork;
|
|
95
|
+
}
|
|
96
|
+
interface PaymentIntent {
|
|
97
|
+
/** Unique payment intent ID */
|
|
98
|
+
id: string;
|
|
99
|
+
/** Client secret for authenticating client-side operations */
|
|
100
|
+
clientSecret: string;
|
|
101
|
+
/** Amount in smallest currency unit */
|
|
102
|
+
amount: number;
|
|
103
|
+
/** Currency code */
|
|
104
|
+
currency: string;
|
|
105
|
+
/** Payment status */
|
|
106
|
+
status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'cancelled';
|
|
107
|
+
/** Recommended PSP based on routing rules */
|
|
108
|
+
recommendedPsp: 'paystack' | 'hubtel' | 'flutterwave';
|
|
109
|
+
/** Available payment methods for this intent */
|
|
110
|
+
availableMethods: PaymentMethod[];
|
|
111
|
+
/** Connection ID (from Reevit backend) */
|
|
112
|
+
connectionId?: string;
|
|
113
|
+
/** Provider name (from backend) */
|
|
114
|
+
provider?: string;
|
|
115
|
+
/** Fee amount charged by PSP */
|
|
116
|
+
feeAmount?: number;
|
|
117
|
+
/** Fee currency */
|
|
118
|
+
feeCurrency?: string;
|
|
119
|
+
/** Net amount after fees */
|
|
120
|
+
netAmount?: number;
|
|
121
|
+
/** Additional metadata */
|
|
122
|
+
metadata?: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface ReevitContextValue {
|
|
126
|
+
publicKey: string;
|
|
127
|
+
amount: number;
|
|
128
|
+
currency: string;
|
|
129
|
+
}
|
|
130
|
+
declare function useReevitContext(): ReevitContextValue;
|
|
131
|
+
declare function ReevitCheckout({ publicKey, amount, currency, email, phone, reference, metadata, paymentMethods, onSuccess, onError, onClose, onStateChange, children, autoOpen, theme, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
|
|
132
|
+
|
|
133
|
+
interface PaymentMethodSelectorProps {
|
|
134
|
+
methods: PaymentMethod[];
|
|
135
|
+
selectedMethod: PaymentMethod | null;
|
|
136
|
+
onSelect: (method: PaymentMethod) => void;
|
|
137
|
+
disabled?: boolean;
|
|
138
|
+
}
|
|
139
|
+
declare function PaymentMethodSelector({ methods, selectedMethod, onSelect, disabled, }: PaymentMethodSelectorProps): react_jsx_runtime.JSX.Element;
|
|
140
|
+
|
|
141
|
+
interface MobileMoneyFormProps {
|
|
142
|
+
onSubmit: (data: MobileMoneyFormData) => void;
|
|
143
|
+
onCancel: () => void;
|
|
144
|
+
isLoading?: boolean;
|
|
145
|
+
initialPhone?: string;
|
|
146
|
+
}
|
|
147
|
+
declare function MobileMoneyForm({ onSubmit, onCancel, isLoading, initialPhone, }: MobileMoneyFormProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* useReevit hook
|
|
151
|
+
* Core hook for managing Reevit checkout state and API interactions
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
interface UseReevitOptions {
|
|
155
|
+
config: ReevitCheckoutConfig;
|
|
156
|
+
onSuccess?: (result: PaymentResult) => void;
|
|
157
|
+
onError?: (error: PaymentError) => void;
|
|
158
|
+
onClose?: () => void;
|
|
159
|
+
onStateChange?: (state: CheckoutState) => void;
|
|
160
|
+
/** Custom API base URL (for testing or self-hosted deployments) */
|
|
161
|
+
apiBaseUrl?: string;
|
|
162
|
+
}
|
|
163
|
+
declare function useReevit(options: UseReevitOptions): {
|
|
164
|
+
status: CheckoutState;
|
|
165
|
+
paymentIntent: PaymentIntent | null;
|
|
166
|
+
selectedMethod: PaymentMethod | null;
|
|
167
|
+
error: PaymentError | null;
|
|
168
|
+
result: PaymentResult | null;
|
|
169
|
+
initialize: (method?: PaymentMethod) => Promise<void>;
|
|
170
|
+
selectMethod: (method: PaymentMethod) => void;
|
|
171
|
+
processPayment: (paymentData: Record<string, unknown>) => Promise<void>;
|
|
172
|
+
handlePspSuccess: (pspData: Record<string, unknown>) => Promise<void>;
|
|
173
|
+
handlePspError: (error: PaymentError) => void;
|
|
174
|
+
reset: () => void;
|
|
175
|
+
close: () => Promise<void>;
|
|
176
|
+
isLoading: boolean;
|
|
177
|
+
isReady: boolean;
|
|
178
|
+
isComplete: boolean;
|
|
179
|
+
canRetry: boolean;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
declare global {
|
|
183
|
+
interface Window {
|
|
184
|
+
PaystackPop?: PaystackPopupInterface;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
interface PaystackPopupInterface {
|
|
188
|
+
setup: (config: PaystackConfig) => {
|
|
189
|
+
openIframe: () => void;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
interface PaystackConfig {
|
|
193
|
+
key: string;
|
|
194
|
+
email: string;
|
|
195
|
+
amount: number;
|
|
196
|
+
currency?: string;
|
|
197
|
+
ref?: string;
|
|
198
|
+
metadata?: Record<string, unknown>;
|
|
199
|
+
channels?: string[];
|
|
200
|
+
callback: (response: PaystackResponse) => void;
|
|
201
|
+
onClose: () => void;
|
|
202
|
+
}
|
|
203
|
+
interface PaystackResponse {
|
|
204
|
+
reference: string;
|
|
205
|
+
trans: string;
|
|
206
|
+
status: string;
|
|
207
|
+
message: string;
|
|
208
|
+
transaction: string;
|
|
209
|
+
trxref: string;
|
|
210
|
+
}
|
|
211
|
+
interface PaystackBridgeProps {
|
|
212
|
+
publicKey: string;
|
|
213
|
+
email: string;
|
|
214
|
+
amount: number;
|
|
215
|
+
currency?: string;
|
|
216
|
+
reference?: string;
|
|
217
|
+
metadata?: Record<string, unknown>;
|
|
218
|
+
channels?: ('card' | 'bank' | 'ussd' | 'qr' | 'mobile_money' | 'bank_transfer')[];
|
|
219
|
+
onSuccess: (result: PaymentResult) => void;
|
|
220
|
+
onError: (error: PaymentError) => void;
|
|
221
|
+
onClose: () => void;
|
|
222
|
+
autoStart?: boolean;
|
|
223
|
+
}
|
|
224
|
+
declare function loadPaystackScript(): Promise<void>;
|
|
225
|
+
declare function PaystackBridge({ publicKey, email, amount, currency, reference, metadata, channels, onSuccess, onError, onClose, autoStart, }: PaystackBridgeProps): react_jsx_runtime.JSX.Element;
|
|
226
|
+
|
|
227
|
+
declare global {
|
|
228
|
+
interface Window {
|
|
229
|
+
HubtelCheckout?: HubtelCheckoutInterface;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
interface HubtelCheckoutInterface {
|
|
233
|
+
initPayment: (config: HubtelConfig) => void;
|
|
234
|
+
}
|
|
235
|
+
interface HubtelConfig {
|
|
236
|
+
merchantAccount: string;
|
|
237
|
+
basicDescription: string;
|
|
238
|
+
totalAmount: number;
|
|
239
|
+
currency: string;
|
|
240
|
+
clientReference: string;
|
|
241
|
+
customerEmail?: string;
|
|
242
|
+
customerMsisdn?: string;
|
|
243
|
+
callbackUrl?: string;
|
|
244
|
+
onComplete?: (response: HubtelResponse) => void;
|
|
245
|
+
onCancel?: () => void;
|
|
246
|
+
}
|
|
247
|
+
interface HubtelResponse {
|
|
248
|
+
status: 'Success' | 'Failed' | 'Cancelled';
|
|
249
|
+
transactionId: string;
|
|
250
|
+
clientReference: string;
|
|
251
|
+
amount: number;
|
|
252
|
+
currency: string;
|
|
253
|
+
message?: string;
|
|
254
|
+
}
|
|
255
|
+
interface HubtelBridgeProps {
|
|
256
|
+
merchantAccount: string;
|
|
257
|
+
amount: number;
|
|
258
|
+
currency?: string;
|
|
259
|
+
reference?: string;
|
|
260
|
+
email?: string;
|
|
261
|
+
phone?: string;
|
|
262
|
+
description?: string;
|
|
263
|
+
onSuccess: (result: PaymentResult) => void;
|
|
264
|
+
onError: (error: PaymentError) => void;
|
|
265
|
+
onClose: () => void;
|
|
266
|
+
autoStart?: boolean;
|
|
267
|
+
}
|
|
268
|
+
declare function loadHubtelScript(): Promise<void>;
|
|
269
|
+
declare function HubtelBridge({ merchantAccount, amount, currency, reference, email, phone, description, onSuccess, onError, onClose, autoStart, }: HubtelBridgeProps): react_jsx_runtime.JSX.Element;
|
|
270
|
+
|
|
271
|
+
declare global {
|
|
272
|
+
interface Window {
|
|
273
|
+
FlutterwaveCheckout?: (config: FlutterwaveConfig) => void;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
interface FlutterwaveConfig {
|
|
277
|
+
public_key: string;
|
|
278
|
+
tx_ref: string;
|
|
279
|
+
amount: number;
|
|
280
|
+
currency: string;
|
|
281
|
+
payment_options?: string;
|
|
282
|
+
customer: {
|
|
283
|
+
email: string;
|
|
284
|
+
phone_number?: string;
|
|
285
|
+
name?: string;
|
|
286
|
+
};
|
|
287
|
+
customizations?: {
|
|
288
|
+
title?: string;
|
|
289
|
+
description?: string;
|
|
290
|
+
logo?: string;
|
|
291
|
+
};
|
|
292
|
+
meta?: Record<string, unknown>;
|
|
293
|
+
callback: (response: FlutterwaveResponse) => void;
|
|
294
|
+
onclose: () => void;
|
|
295
|
+
}
|
|
296
|
+
interface FlutterwaveResponse {
|
|
297
|
+
status: 'successful' | 'failed' | 'cancelled';
|
|
298
|
+
transaction_id: number;
|
|
299
|
+
tx_ref: string;
|
|
300
|
+
flw_ref: string;
|
|
301
|
+
amount: number;
|
|
302
|
+
currency: string;
|
|
303
|
+
charged_amount: number;
|
|
304
|
+
payment_type: string;
|
|
305
|
+
}
|
|
306
|
+
interface FlutterwaveBridgeProps {
|
|
307
|
+
publicKey: string;
|
|
308
|
+
amount: number;
|
|
309
|
+
currency?: string;
|
|
310
|
+
reference?: string;
|
|
311
|
+
email: string;
|
|
312
|
+
phone?: string;
|
|
313
|
+
name?: string;
|
|
314
|
+
paymentOptions?: string;
|
|
315
|
+
title?: string;
|
|
316
|
+
description?: string;
|
|
317
|
+
logo?: string;
|
|
318
|
+
metadata?: Record<string, unknown>;
|
|
319
|
+
onSuccess: (result: PaymentResult) => void;
|
|
320
|
+
onError: (error: PaymentError) => void;
|
|
321
|
+
onClose: () => void;
|
|
322
|
+
autoStart?: boolean;
|
|
323
|
+
}
|
|
324
|
+
declare function loadFlutterwaveScript(): Promise<void>;
|
|
325
|
+
declare function FlutterwaveBridge({ publicKey, amount, currency, reference, email, phone, name, paymentOptions, title, description, logo, metadata, onSuccess, onError, onClose, autoStart, }: FlutterwaveBridgeProps): react_jsx_runtime.JSX.Element;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* StripeBridge.tsx
|
|
329
|
+
* React component for Stripe payment integration
|
|
330
|
+
*/
|
|
331
|
+
declare global {
|
|
332
|
+
interface Window {
|
|
333
|
+
Stripe?: (publishableKey: string) => StripeInstance;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
interface StripeInstance {
|
|
337
|
+
elements: (options?: {
|
|
338
|
+
clientSecret: string;
|
|
339
|
+
appearance?: StripeAppearance;
|
|
340
|
+
}) => StripeElements;
|
|
341
|
+
confirmPayment: (options: {
|
|
342
|
+
elements: StripeElements;
|
|
343
|
+
confirmParams?: {
|
|
344
|
+
return_url?: string;
|
|
345
|
+
};
|
|
346
|
+
redirect?: 'if_required';
|
|
347
|
+
}) => Promise<{
|
|
348
|
+
error?: StripeError;
|
|
349
|
+
paymentIntent?: {
|
|
350
|
+
id: string;
|
|
351
|
+
status: string;
|
|
352
|
+
};
|
|
353
|
+
}>;
|
|
354
|
+
}
|
|
355
|
+
interface StripeElements {
|
|
356
|
+
create: (type: 'payment' | 'card', options?: Record<string, unknown>) => StripeElement;
|
|
357
|
+
getElement: (type: string) => StripeElement | null;
|
|
358
|
+
submit: () => Promise<{
|
|
359
|
+
error?: StripeError;
|
|
360
|
+
}>;
|
|
361
|
+
}
|
|
362
|
+
interface StripeElement {
|
|
363
|
+
mount: (selector: string | HTMLElement) => void;
|
|
364
|
+
unmount: () => void;
|
|
365
|
+
on: (event: string, handler: (e: any) => void) => void;
|
|
366
|
+
destroy: () => void;
|
|
367
|
+
}
|
|
368
|
+
interface StripeError {
|
|
369
|
+
type: string;
|
|
370
|
+
message: string;
|
|
371
|
+
code?: string;
|
|
372
|
+
}
|
|
373
|
+
interface StripeAppearance {
|
|
374
|
+
theme?: 'stripe' | 'night' | 'flat';
|
|
375
|
+
variables?: Record<string, string>;
|
|
376
|
+
rules?: Record<string, Record<string, string>>;
|
|
377
|
+
}
|
|
378
|
+
interface StripeBridgeProps {
|
|
379
|
+
publishableKey: string;
|
|
380
|
+
clientSecret: string;
|
|
381
|
+
amount: number;
|
|
382
|
+
currency: string;
|
|
383
|
+
appearance?: StripeAppearance;
|
|
384
|
+
onSuccess: (result: {
|
|
385
|
+
paymentIntentId: string;
|
|
386
|
+
status: string;
|
|
387
|
+
}) => void;
|
|
388
|
+
onError: (error: {
|
|
389
|
+
code: string;
|
|
390
|
+
message: string;
|
|
391
|
+
}) => void;
|
|
392
|
+
onReady?: () => void;
|
|
393
|
+
onCancel?: () => void;
|
|
394
|
+
}
|
|
395
|
+
declare function loadStripeScript(): Promise<void>;
|
|
396
|
+
declare function StripeBridge({ publishableKey, clientSecret, amount, currency, appearance, onSuccess, onError, onReady, onCancel, }: StripeBridgeProps): react_jsx_runtime.JSX.Element;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* MonnifyBridge.tsx
|
|
400
|
+
* React component for Monnify payment integration (Nigeria)
|
|
401
|
+
*/
|
|
402
|
+
declare global {
|
|
403
|
+
interface Window {
|
|
404
|
+
MonnifySDK?: {
|
|
405
|
+
initialize: (config: MonnifyConfig) => void;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
interface MonnifyConfig {
|
|
410
|
+
amount: number;
|
|
411
|
+
currency: string;
|
|
412
|
+
reference: string;
|
|
413
|
+
customerName: string;
|
|
414
|
+
customerEmail: string;
|
|
415
|
+
customerMobileNumber?: string;
|
|
416
|
+
apiKey: string;
|
|
417
|
+
contractCode: string;
|
|
418
|
+
paymentDescription?: string;
|
|
419
|
+
isTestMode?: boolean;
|
|
420
|
+
metadata?: Record<string, unknown>;
|
|
421
|
+
onComplete: (response: MonnifyResponse) => void;
|
|
422
|
+
onClose: () => void;
|
|
423
|
+
}
|
|
424
|
+
interface MonnifyResponse {
|
|
425
|
+
status: 'SUCCESS' | 'FAILED' | 'PENDING';
|
|
426
|
+
message: string;
|
|
427
|
+
transactionReference: string;
|
|
428
|
+
paymentReference: string;
|
|
429
|
+
authorizedAmount?: number;
|
|
430
|
+
paymentStatus?: string;
|
|
431
|
+
}
|
|
432
|
+
interface MonnifyBridgeProps {
|
|
433
|
+
apiKey: string;
|
|
434
|
+
contractCode: string;
|
|
435
|
+
amount: number;
|
|
436
|
+
currency: string;
|
|
437
|
+
reference: string;
|
|
438
|
+
customerName: string;
|
|
439
|
+
customerEmail: string;
|
|
440
|
+
customerPhone?: string;
|
|
441
|
+
paymentDescription?: string;
|
|
442
|
+
isTestMode?: boolean;
|
|
443
|
+
metadata?: Record<string, unknown>;
|
|
444
|
+
autoOpen?: boolean;
|
|
445
|
+
onSuccess: (result: {
|
|
446
|
+
transactionReference: string;
|
|
447
|
+
paymentReference: string;
|
|
448
|
+
amount: number;
|
|
449
|
+
}) => void;
|
|
450
|
+
onError: (error: {
|
|
451
|
+
code: string;
|
|
452
|
+
message: string;
|
|
453
|
+
}) => void;
|
|
454
|
+
onClose?: () => void;
|
|
455
|
+
}
|
|
456
|
+
declare function loadMonnifyScript(): Promise<void>;
|
|
457
|
+
declare function MonnifyBridge({ apiKey, contractCode, amount, currency, reference, customerName, customerEmail, customerPhone, paymentDescription, isTestMode, metadata, autoOpen, onSuccess, onError, onClose, }: MonnifyBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* MPesaBridge.tsx
|
|
461
|
+
* React component for M-Pesa STK Push integration (Kenya/Tanzania)
|
|
462
|
+
*
|
|
463
|
+
* Note: M-Pesa uses server-to-server STK Push initiated by the backend.
|
|
464
|
+
* This component handles the UI flow while the customer approves on their phone.
|
|
465
|
+
*/
|
|
466
|
+
interface MPesaBridgeProps {
|
|
467
|
+
/** API endpoint to initiate STK Push (your backend) */
|
|
468
|
+
apiEndpoint: string;
|
|
469
|
+
/** Customer phone number in format 254XXXXXXXXX */
|
|
470
|
+
phoneNumber: string;
|
|
471
|
+
/** Amount to charge */
|
|
472
|
+
amount: number;
|
|
473
|
+
/** Currency (KES or TZS) */
|
|
474
|
+
currency: string;
|
|
475
|
+
/** Unique transaction reference */
|
|
476
|
+
reference: string;
|
|
477
|
+
/** Payment description */
|
|
478
|
+
description?: string;
|
|
479
|
+
/** Called when STK Push is successfully sent */
|
|
480
|
+
onInitiated?: (checkoutRequestId: string) => void;
|
|
481
|
+
/** Called when payment is confirmed (via webhook/polling) */
|
|
482
|
+
onSuccess: (result: {
|
|
483
|
+
transactionId: string;
|
|
484
|
+
reference: string;
|
|
485
|
+
}) => void;
|
|
486
|
+
/** Called on error */
|
|
487
|
+
onError: (error: {
|
|
488
|
+
code: string;
|
|
489
|
+
message: string;
|
|
490
|
+
}) => void;
|
|
491
|
+
/** Custom headers for API calls (e.g., authorization) */
|
|
492
|
+
headers?: Record<string, string>;
|
|
493
|
+
}
|
|
494
|
+
declare function MPesaBridge({ apiEndpoint, phoneNumber, amount, currency, reference, description, onInitiated, onSuccess, onError, headers, }: MPesaBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
495
|
+
/**
|
|
496
|
+
* Hook for M-Pesa payment status polling
|
|
497
|
+
* Use this to check payment status after STK Push is initiated
|
|
498
|
+
*/
|
|
499
|
+
declare function useMPesaStatusPolling(statusEndpoint: string, checkoutRequestId: string | null, options: {
|
|
500
|
+
interval?: number;
|
|
501
|
+
maxAttempts?: number;
|
|
502
|
+
headers?: Record<string, string>;
|
|
503
|
+
onSuccess: (result: {
|
|
504
|
+
transactionId: string;
|
|
505
|
+
}) => void;
|
|
506
|
+
onFailed: (error: {
|
|
507
|
+
message: string;
|
|
508
|
+
}) => void;
|
|
509
|
+
onTimeout: () => void;
|
|
510
|
+
}): {
|
|
511
|
+
startPolling: () => Promise<void>;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Reevit API Client
|
|
516
|
+
*
|
|
517
|
+
* Handles communication with the Reevit backend for payment operations.
|
|
518
|
+
*/
|
|
519
|
+
|
|
520
|
+
interface PaymentIntentResponse {
|
|
521
|
+
id: string;
|
|
522
|
+
connection_id: string;
|
|
523
|
+
provider: string;
|
|
524
|
+
status: string;
|
|
525
|
+
client_secret: string;
|
|
526
|
+
amount: number;
|
|
527
|
+
currency: string;
|
|
528
|
+
fee_amount: number;
|
|
529
|
+
fee_currency: string;
|
|
530
|
+
net_amount: number;
|
|
531
|
+
}
|
|
532
|
+
interface PaymentDetailResponse {
|
|
533
|
+
id: string;
|
|
534
|
+
connection_id: string;
|
|
535
|
+
provider: string;
|
|
536
|
+
method: string;
|
|
537
|
+
status: string;
|
|
538
|
+
amount: number;
|
|
539
|
+
currency: string;
|
|
540
|
+
fee_amount: number;
|
|
541
|
+
fee_currency: string;
|
|
542
|
+
net_amount: number;
|
|
543
|
+
customer_id?: string;
|
|
544
|
+
client_secret: string;
|
|
545
|
+
provider_ref_id?: string;
|
|
546
|
+
metadata?: Record<string, unknown>;
|
|
547
|
+
created_at: string;
|
|
548
|
+
updated_at: string;
|
|
549
|
+
}
|
|
550
|
+
interface ReevitAPIClientConfig {
|
|
551
|
+
/** Your Reevit public key */
|
|
552
|
+
publicKey: string;
|
|
553
|
+
/** Base URL for the Reevit API (defaults to production) */
|
|
554
|
+
baseUrl?: string;
|
|
555
|
+
/** Request timeout in milliseconds */
|
|
556
|
+
timeout?: number;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Reevit API Client
|
|
560
|
+
*/
|
|
561
|
+
declare class ReevitAPIClient {
|
|
562
|
+
private readonly publicKey;
|
|
563
|
+
private readonly baseUrl;
|
|
564
|
+
private readonly timeout;
|
|
565
|
+
constructor(config: ReevitAPIClientConfig);
|
|
566
|
+
/**
|
|
567
|
+
* Makes an authenticated API request
|
|
568
|
+
*/
|
|
569
|
+
private request;
|
|
570
|
+
/**
|
|
571
|
+
* Creates a payment intent
|
|
572
|
+
*/
|
|
573
|
+
createPaymentIntent(config: ReevitCheckoutConfig, method: PaymentMethod, country?: string): Promise<{
|
|
574
|
+
data?: PaymentIntentResponse;
|
|
575
|
+
error?: PaymentError;
|
|
576
|
+
}>;
|
|
577
|
+
/**
|
|
578
|
+
* Retrieves a payment intent by ID
|
|
579
|
+
*/
|
|
580
|
+
getPaymentIntent(paymentId: string): Promise<{
|
|
581
|
+
data?: PaymentDetailResponse;
|
|
582
|
+
error?: PaymentError;
|
|
583
|
+
}>;
|
|
584
|
+
/**
|
|
585
|
+
* Confirms a payment after PSP callback
|
|
586
|
+
*/
|
|
587
|
+
confirmPayment(paymentId: string): Promise<{
|
|
588
|
+
data?: PaymentDetailResponse;
|
|
589
|
+
error?: PaymentError;
|
|
590
|
+
}>;
|
|
591
|
+
/**
|
|
592
|
+
* Cancels a payment intent
|
|
593
|
+
*/
|
|
594
|
+
cancelPaymentIntent(paymentId: string): Promise<{
|
|
595
|
+
data?: PaymentDetailResponse;
|
|
596
|
+
error?: PaymentError;
|
|
597
|
+
}>;
|
|
598
|
+
/**
|
|
599
|
+
* Maps SDK payment method to backend format
|
|
600
|
+
*/
|
|
601
|
+
private mapPaymentMethod;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Creates a new Reevit API client instance
|
|
605
|
+
*/
|
|
606
|
+
declare function createReevitClient(config: ReevitAPIClientConfig): ReevitAPIClient;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Utility functions for the Reevit React SDK
|
|
610
|
+
*/
|
|
611
|
+
/**
|
|
612
|
+
* Format amount for display
|
|
613
|
+
*/
|
|
614
|
+
declare function formatAmount(amount: number, currency: string): string;
|
|
615
|
+
/**
|
|
616
|
+
* Validate phone number for mobile money
|
|
617
|
+
*/
|
|
618
|
+
declare function validatePhone(phone: string, network?: string): boolean;
|
|
619
|
+
/**
|
|
620
|
+
* Format phone number for display
|
|
621
|
+
*/
|
|
622
|
+
declare function formatPhone(phone: string): string;
|
|
623
|
+
/**
|
|
624
|
+
* Detect mobile money network from phone number
|
|
625
|
+
*/
|
|
626
|
+
declare function detectNetwork(phone: string): string | null;
|
|
627
|
+
|
|
628
|
+
export { type CheckoutState, FlutterwaveBridge, HubtelBridge, MPesaBridge, type MPesaBridgeProps, MobileMoneyForm, type MobileMoneyFormData, type MobileMoneyNetwork, MonnifyBridge, type MonnifyBridgeProps, type PaymentDetailResponse, type PaymentError, type PaymentIntent, type PaymentIntentResponse, type PaymentMethod, PaymentMethodSelector, type PaymentResult, PaystackBridge, ReevitAPIClient, type ReevitAPIClientConfig, ReevitCheckout, type ReevitCheckoutCallbacks, type ReevitCheckoutConfig, type ReevitCheckoutProps, type ReevitTheme, StripeBridge, type StripeBridgeProps, createReevitClient, detectNetwork, formatAmount, formatPhone, loadFlutterwaveScript, loadHubtelScript, loadMonnifyScript, loadPaystackScript, loadStripeScript, useMPesaStatusPolling, useReevit, useReevitContext, validatePhone };
|