@reevit/react 0.4.9 → 0.5.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.
package/README.md CHANGED
@@ -5,7 +5,7 @@ Unified Payment Widget for React Applications. Accept card and mobile money paym
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @reevit/react
8
+ npm install @reevit/react@0.5.0
9
9
  ```
10
10
 
11
11
  ## Quick Start
@@ -37,6 +37,44 @@ function App() {
37
37
  }
38
38
  ```
39
39
 
40
+ ## Payment Links
41
+
42
+ If you have a hosted payment link, pass the link code. The widget will create the payment intent from the public link endpoint.
43
+
44
+ ```tsx
45
+ <ReevitCheckout
46
+ paymentLinkCode="plink_123"
47
+ amount={25000}
48
+ currency="GHS"
49
+ email="customer@example.com"
50
+ customerName="Ada Lovelace"
51
+ />
52
+ ```
53
+
54
+ ## Controlled Modal
55
+
56
+ You can control the open state yourself.
57
+
58
+ ```tsx
59
+ const [open, setOpen] = useState(false);
60
+
61
+ <ReevitCheckout
62
+ publicKey="pk_test_your_key"
63
+ amount={10000}
64
+ currency="GHS"
65
+ isOpen={open}
66
+ onOpenChange={setOpen}
67
+ />
68
+ ```
69
+
70
+ ## Success Screen Delay
71
+
72
+ By default, the checkout shows a success screen for 5 seconds before calling `onSuccess` and closing. Override with `successDelayMs` (set to `0` for immediate close).
73
+
74
+ ```tsx
75
+ <ReevitCheckout successDelayMs={0} /* ... */ />
76
+ ```
77
+
40
78
  ## Custom Theme
41
79
 
42
80
  You can customize the look and feel of the checkout widget to match your brand.
@@ -44,12 +82,17 @@ You can customize the look and feel of the checkout widget to match your brand.
44
82
  ```tsx
45
83
  <ReevitCheckout
46
84
  theme={{
47
- primaryColor: '#6200EE',
48
- backgroundColor: '#F5F5F5',
49
- textColor: '#000000',
85
+ primaryColor: '#0EA5E9',
86
+ primaryForegroundColor: '#FFFFFF',
87
+ backgroundColor: '#F8FAFC',
88
+ borderColor: '#E2E8F0',
50
89
  borderRadius: '12px',
51
- fontFamily: "'Segoe UI', Roboto, sans-serif",
52
- darkMode: true,
90
+ companyName: 'Acme',
91
+ logoUrl: 'https://example.com/logo.png',
92
+ selectedBackgroundColor: '#E8F5F0',
93
+ selectedTextColor: '#0B1120',
94
+ selectedDescriptionColor: '#64748B',
95
+ selectedBorderColor: '#E2E8F0',
53
96
  }}
54
97
  // ...other props
55
98
  >
@@ -106,18 +149,50 @@ function CustomCheckout() {
106
149
 
107
150
  | Prop | Type | Description |
108
151
  |------|------|-------------|
109
- | `publicKey` | `string` | **Required**. Your project's public key (pk_test_... or pk_live_...) |
152
+ | `publicKey` | `string` | Your project's public key (required for API-created intents; optional when using `paymentLinkCode`) |
110
153
  | `amount` | `number` | **Required**. Amount in the smallest unit (e.g., 500 for 5.00) |
111
154
  | `currency` | `string` | **Required**. 3-letter ISO currency code (GHS, NGN, USD, etc.) |
112
155
  | `email` | `string` | Customer's email address |
113
156
  | `phone` | `string` | Customer's phone number (recommended for Mobile Money) |
157
+ | `customerName` | `string` | Customer name (used in payment links and some PSPs) |
114
158
  | `reference` | `string` | Your own unique transaction reference |
115
159
  | `metadata` | `object` | Key-value pairs to store with the transaction |
116
- | `paymentMethods` | `string[]` | List of enabled methods: `['card', 'mobile_money', 'bank_transfer']` |
160
+ | `customFields` | `object` | Custom fields for payment links |
161
+ | `paymentLinkCode` | `string` | Hosted payment link code (uses the public link checkout flow) |
162
+ | `paymentMethods` | `PaymentMethod[]` | Enabled methods: `card`, `mobile_money`, `bank_transfer`, `apple_pay`, `google_pay` (PSP/country dependent) |
163
+ | `initialPaymentIntent` | `PaymentIntent` | Use an existing intent instead of creating a new one |
164
+ | `children` | `ReactNode` | Custom trigger element |
165
+ | `autoOpen` | `boolean` | Open automatically on mount |
166
+ | `isOpen` | `boolean` | Controlled open state |
167
+ | `onOpenChange` | `(open: boolean) => void` | Controlled open state handler |
117
168
  | `theme` | `ReevitTheme` | Customization options for the widget |
169
+ | `apiBaseUrl` | `string` | Override API base URL (self-hosted/testing) |
170
+ | `successDelayMs` | `number` | Delay before calling `onSuccess` and closing (default `5000`) |
118
171
  | `onSuccess` | `function` | Called when the payment is successfully processed |
119
172
  | `onError` | `function` | Called when an error occurs |
120
173
  | `onClose` | `function` | Called when the user dismisses the widget |
174
+ | `onStateChange` | `function` | Called when checkout state changes |
175
+
176
+ ## Theme Reference
177
+
178
+ | Field | Description |
179
+ |-------|-------------|
180
+ | `primaryColor` | Primary text/brand color |
181
+ | `primaryForegroundColor` | Text color on primary brand surfaces |
182
+ | `backgroundColor` | Background color for the modal |
183
+ | `borderColor` | Border and divider color |
184
+ | `borderRadius` | Border radius for inputs and buttons |
185
+ | `darkMode` | Force dark mode when `true` |
186
+ | `logoUrl` | Logo URL shown in the header |
187
+ | `companyName` | Brand name shown in the header |
188
+ | `selectedBackgroundColor` | Background color for selected provider/methods |
189
+ | `selectedTextColor` | Primary text color for selected items |
190
+ | `selectedDescriptionColor` | Description/muted text color for selected items |
191
+ | `selectedBorderColor` | Border color for selected items |
192
+ | `pspSelectorBgColor` | PSP selector background color (where supported) |
193
+ | `pspSelectorTextColor` | PSP selector text color (where supported) |
194
+ | `pspSelectorBorderColor` | PSP selector border color (where supported) |
195
+ | `pspSelectorUseBorder` | Use border-only PSP selector styling |
121
196
 
122
197
  ## PSP Bridges
123
198
 
@@ -197,10 +272,8 @@ function MpesaPayment() {
197
272
 
198
273
  ## Supported PSPs
199
274
 
200
- | Provider | Countries | Payment Methods |
201
- |----------|-----------|-----------------|
202
- | Paystack | NG, GH, ZA, KE | Card, Mobile Money, Bank |
203
- | Flutterwave | NG, GH, KE, ZA + | Card, Mobile Money, Bank |
275
+ | Paystack | NG, GH, ZA, KE | Card, Mobile Money, Bank Transfer |
276
+ | Flutterwave | NG, GH, KE, ZA + | Card, Mobile Money, Bank Transfer |
204
277
  | Hubtel | GH | Mobile Money |
205
278
  | Stripe | Global (50+) | Card, Apple Pay, Google Pay |
206
279
  | Monnify | NG | Card, Bank Transfer, USSD |
package/dist/index.d.mts CHANGED
@@ -3,8 +3,8 @@ import { ReactNode } from 'react';
3
3
 
4
4
  /** Minimal ReactNode-compatible type to avoid hard dependency on @types/react */
5
5
  type ReevitReactNode = ReactNode;
6
- type PaymentMethod = 'card' | 'mobile_money' | 'bank_transfer';
7
- type MobileMoneyNetwork = 'mtn' | 'vodafone' | 'airteltigo';
6
+ type PaymentMethod = 'card' | 'mobile_money' | 'bank_transfer' | 'apple_pay' | 'google_pay';
7
+ type MobileMoneyNetwork = 'mtn' | 'telecel' | 'airteltigo';
8
8
  /** Payment source type - indicates where the payment originated from */
9
9
  type PaymentSource = 'payment_link' | 'api' | 'subscription';
10
10
  interface ReevitCheckoutConfig {
@@ -56,6 +56,8 @@ interface ReevitCheckoutProps extends ReevitCheckoutConfig, ReevitCheckoutCallba
56
56
  theme?: ReevitTheme;
57
57
  /** Custom API base URL (for testing or self-hosted deployments) */
58
58
  apiBaseUrl?: string;
59
+ /** Delay (ms) before calling onSuccess and closing after a successful payment */
60
+ successDelayMs?: number;
59
61
  }
60
62
  type CheckoutState = 'idle' | 'loading' | 'ready' | 'method_selected' | 'processing' | 'success' | 'failed' | 'closed';
61
63
  interface PaymentResult {
@@ -201,7 +203,7 @@ interface ReevitContextValue {
201
203
  currency: string;
202
204
  }
203
205
  declare function useReevitContext(): ReevitContextValue;
204
- declare function ReevitCheckout({ publicKey, amount, currency, email, phone, customerName, reference, metadata, customFields, paymentLinkCode, paymentMethods, initialPaymentIntent, onSuccess, onError, onClose, onStateChange, children, autoOpen, isOpen: controlledIsOpen, onOpenChange, theme, apiBaseUrl, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
206
+ declare function ReevitCheckout({ publicKey, amount, currency, email, phone, customerName, reference, metadata, customFields, paymentLinkCode, paymentMethods, initialPaymentIntent, onSuccess, onError, onClose, onStateChange, children, autoOpen, isOpen: controlledIsOpen, onOpenChange, theme, apiBaseUrl, successDelayMs, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
205
207
 
206
208
  interface PaymentMethodSelectorProps {
207
209
  methods: PaymentMethod[];
@@ -754,9 +756,6 @@ declare class ReevitAPIClient {
754
756
  */
755
757
  declare function createReevitClient(config: ReevitAPIClientConfig): ReevitAPIClient;
756
758
 
757
- /**
758
- * Utility functions for the Reevit React SDK
759
- */
760
759
  /**
761
760
  * Format amount for display
762
761
  */
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@ import { ReactNode } from 'react';
3
3
 
4
4
  /** Minimal ReactNode-compatible type to avoid hard dependency on @types/react */
5
5
  type ReevitReactNode = ReactNode;
6
- type PaymentMethod = 'card' | 'mobile_money' | 'bank_transfer';
7
- type MobileMoneyNetwork = 'mtn' | 'vodafone' | 'airteltigo';
6
+ type PaymentMethod = 'card' | 'mobile_money' | 'bank_transfer' | 'apple_pay' | 'google_pay';
7
+ type MobileMoneyNetwork = 'mtn' | 'telecel' | 'airteltigo';
8
8
  /** Payment source type - indicates where the payment originated from */
9
9
  type PaymentSource = 'payment_link' | 'api' | 'subscription';
10
10
  interface ReevitCheckoutConfig {
@@ -56,6 +56,8 @@ interface ReevitCheckoutProps extends ReevitCheckoutConfig, ReevitCheckoutCallba
56
56
  theme?: ReevitTheme;
57
57
  /** Custom API base URL (for testing or self-hosted deployments) */
58
58
  apiBaseUrl?: string;
59
+ /** Delay (ms) before calling onSuccess and closing after a successful payment */
60
+ successDelayMs?: number;
59
61
  }
60
62
  type CheckoutState = 'idle' | 'loading' | 'ready' | 'method_selected' | 'processing' | 'success' | 'failed' | 'closed';
61
63
  interface PaymentResult {
@@ -201,7 +203,7 @@ interface ReevitContextValue {
201
203
  currency: string;
202
204
  }
203
205
  declare function useReevitContext(): ReevitContextValue;
204
- declare function ReevitCheckout({ publicKey, amount, currency, email, phone, customerName, reference, metadata, customFields, paymentLinkCode, paymentMethods, initialPaymentIntent, onSuccess, onError, onClose, onStateChange, children, autoOpen, isOpen: controlledIsOpen, onOpenChange, theme, apiBaseUrl, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
206
+ declare function ReevitCheckout({ publicKey, amount, currency, email, phone, customerName, reference, metadata, customFields, paymentLinkCode, paymentMethods, initialPaymentIntent, onSuccess, onError, onClose, onStateChange, children, autoOpen, isOpen: controlledIsOpen, onOpenChange, theme, apiBaseUrl, successDelayMs, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
205
207
 
206
208
  interface PaymentMethodSelectorProps {
207
209
  methods: PaymentMethod[];
@@ -754,9 +756,6 @@ declare class ReevitAPIClient {
754
756
  */
755
757
  declare function createReevitClient(config: ReevitAPIClientConfig): ReevitAPIClient;
756
758
 
757
- /**
758
- * Utility functions for the Reevit React SDK
759
- */
760
759
  /**
761
760
  * Format amount for display
762
761
  */