@reevit/react 0.4.8 → 0.5.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/README.md CHANGED
@@ -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
 
@@ -199,8 +274,8 @@ function MpesaPayment() {
199
274
 
200
275
  | Provider | Countries | Payment Methods |
201
276
  |----------|-----------|-----------------|
202
- | Paystack | NG, GH, ZA, KE | Card, Mobile Money, Bank |
203
- | Flutterwave | NG, GH, KE, ZA + | Card, Mobile Money, Bank |
277
+ | Paystack | NG, GH, ZA, KE | Card, Mobile Money, Bank Transfer |
278
+ | Flutterwave | NG, GH, KE, ZA + | Card, Mobile Money, Bank Transfer |
204
279
  | Hubtel | GH | Mobile Money |
205
280
  | Stripe | Global (50+) | Card, Apple Pay, Google Pay |
206
281
  | Monnify | NG | Card, Bank Transfer, USSD |
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ 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';
6
+ type PaymentMethod = 'card' | 'mobile_money' | 'bank_transfer' | 'apple_pay' | 'google_pay';
7
7
  type MobileMoneyNetwork = 'mtn' | 'vodafone' | 'airteltigo';
8
8
  /** Payment source type - indicates where the payment originated from */
9
9
  type PaymentSource = 'payment_link' | 'api' | 'subscription';
@@ -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 {
@@ -97,22 +99,16 @@ interface PaymentError {
97
99
  details?: Record<string, unknown>;
98
100
  }
99
101
  interface ReevitTheme {
100
- /** Primary brand color */
102
+ /** Primary color (main text, headings, important elements) */
101
103
  primaryColor?: string;
102
- /** Primary text color on brand surfaces */
104
+ /** Primary foreground color (sub text, descriptions, muted elements) */
103
105
  primaryForegroundColor?: string;
104
- /** Background color */
106
+ /** Background color (applies to entire checkout: header, body, footer) */
105
107
  backgroundColor?: string;
106
- /** Surface color for cards/panels */
107
- surfaceColor?: string;
108
- /** Text color */
109
- textColor?: string;
110
- /** Muted text color */
111
- mutedTextColor?: string;
108
+ /** Border color (borders, dividers) */
109
+ borderColor?: string;
112
110
  /** Border radius for inputs and buttons */
113
111
  borderRadius?: string;
114
- /** Font family to use */
115
- fontFamily?: string;
116
112
  /** Whether to use dark mode */
117
113
  darkMode?: boolean;
118
114
  /** Custom logo URL to display in checkout header */
@@ -127,12 +123,29 @@ interface ReevitTheme {
127
123
  pspSelectorBorderColor?: string;
128
124
  /** Use border-only style for PSP selector (no filled background) */
129
125
  pspSelectorUseBorder?: boolean;
126
+ /** Selected PSP background color */
127
+ selectedBackgroundColor?: string;
128
+ /** Selected PSP primary text color */
129
+ selectedTextColor?: string;
130
+ /** Selected PSP description/muted text color */
131
+ selectedDescriptionColor?: string;
132
+ /** Selected PSP border color */
133
+ selectedBorderColor?: string;
130
134
  }
131
135
  interface CheckoutProviderOption {
132
136
  provider: string;
133
137
  name: string;
134
138
  methods: PaymentMethod[];
135
139
  countries?: string[];
140
+ /** Brand colors for selected state styling */
141
+ branding?: {
142
+ /** Background color when selected */
143
+ backgroundColor?: string;
144
+ /** Primary/accent color */
145
+ primaryColor?: string;
146
+ /** Text color on primary background */
147
+ primaryForegroundColor?: string;
148
+ };
136
149
  }
137
150
  interface MobileMoneyFormData {
138
151
  phone: string;
@@ -159,7 +172,7 @@ interface PaymentIntent {
159
172
  /** Currency code */
160
173
  currency: string;
161
174
  /** Payment status */
162
- status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'cancelled';
175
+ status: 'pending' | 'requires_action' | 'processing' | 'succeeded' | 'failed' | 'canceled' | 'cancelled';
163
176
  /** Recommended PSP based on routing rules */
164
177
  recommendedPsp: 'paystack' | 'hubtel' | 'flutterwave' | 'monnify' | 'mpesa' | 'stripe';
165
178
  /** Available payment methods for this intent */
@@ -190,7 +203,7 @@ interface ReevitContextValue {
190
203
  currency: string;
191
204
  }
192
205
  declare function useReevitContext(): ReevitContextValue;
193
- 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;
194
207
 
195
208
  interface PaymentMethodSelectorProps {
196
209
  methods: PaymentMethod[];
@@ -200,8 +213,17 @@ interface PaymentMethodSelectorProps {
200
213
  provider?: string;
201
214
  layout?: 'grid' | 'list';
202
215
  showLabel?: boolean;
216
+ /** Country code for dynamic logos (e.g., 'GH', 'NG', 'KE') */
217
+ country?: string;
218
+ /** Selected theme colors for method items */
219
+ selectedTheme?: {
220
+ backgroundColor?: string;
221
+ textColor?: string;
222
+ descriptionColor?: string;
223
+ borderColor?: string;
224
+ };
203
225
  }
204
- declare function PaymentMethodSelector({ methods, selectedMethod, onSelect, disabled, provider, layout, showLabel, }: PaymentMethodSelectorProps): react_jsx_runtime.JSX.Element;
226
+ declare function PaymentMethodSelector({ methods, selectedMethod, onSelect, disabled, provider, layout, showLabel, country, selectedTheme, }: PaymentMethodSelectorProps): react_jsx_runtime.JSX.Element;
205
227
 
206
228
  interface MobileMoneyFormProps {
207
229
  onSubmit: (data: MobileMoneyFormData) => void;
@@ -595,6 +617,11 @@ interface PaymentIntentResponse {
595
617
  status: string;
596
618
  client_secret: string;
597
619
  psp_public_key?: string;
620
+ psp_credentials?: {
621
+ merchantAccount?: string | number;
622
+ basicAuth?: string;
623
+ [key: string]: unknown;
624
+ };
598
625
  amount: number;
599
626
  currency: string;
600
627
  fee_amount: number;
@@ -729,9 +756,6 @@ declare class ReevitAPIClient {
729
756
  */
730
757
  declare function createReevitClient(config: ReevitAPIClientConfig): ReevitAPIClient;
731
758
 
732
- /**
733
- * Utility functions for the Reevit React SDK
734
- */
735
759
  /**
736
760
  * Format amount for display
737
761
  */
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ 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';
6
+ type PaymentMethod = 'card' | 'mobile_money' | 'bank_transfer' | 'apple_pay' | 'google_pay';
7
7
  type MobileMoneyNetwork = 'mtn' | 'vodafone' | 'airteltigo';
8
8
  /** Payment source type - indicates where the payment originated from */
9
9
  type PaymentSource = 'payment_link' | 'api' | 'subscription';
@@ -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 {
@@ -97,22 +99,16 @@ interface PaymentError {
97
99
  details?: Record<string, unknown>;
98
100
  }
99
101
  interface ReevitTheme {
100
- /** Primary brand color */
102
+ /** Primary color (main text, headings, important elements) */
101
103
  primaryColor?: string;
102
- /** Primary text color on brand surfaces */
104
+ /** Primary foreground color (sub text, descriptions, muted elements) */
103
105
  primaryForegroundColor?: string;
104
- /** Background color */
106
+ /** Background color (applies to entire checkout: header, body, footer) */
105
107
  backgroundColor?: string;
106
- /** Surface color for cards/panels */
107
- surfaceColor?: string;
108
- /** Text color */
109
- textColor?: string;
110
- /** Muted text color */
111
- mutedTextColor?: string;
108
+ /** Border color (borders, dividers) */
109
+ borderColor?: string;
112
110
  /** Border radius for inputs and buttons */
113
111
  borderRadius?: string;
114
- /** Font family to use */
115
- fontFamily?: string;
116
112
  /** Whether to use dark mode */
117
113
  darkMode?: boolean;
118
114
  /** Custom logo URL to display in checkout header */
@@ -127,12 +123,29 @@ interface ReevitTheme {
127
123
  pspSelectorBorderColor?: string;
128
124
  /** Use border-only style for PSP selector (no filled background) */
129
125
  pspSelectorUseBorder?: boolean;
126
+ /** Selected PSP background color */
127
+ selectedBackgroundColor?: string;
128
+ /** Selected PSP primary text color */
129
+ selectedTextColor?: string;
130
+ /** Selected PSP description/muted text color */
131
+ selectedDescriptionColor?: string;
132
+ /** Selected PSP border color */
133
+ selectedBorderColor?: string;
130
134
  }
131
135
  interface CheckoutProviderOption {
132
136
  provider: string;
133
137
  name: string;
134
138
  methods: PaymentMethod[];
135
139
  countries?: string[];
140
+ /** Brand colors for selected state styling */
141
+ branding?: {
142
+ /** Background color when selected */
143
+ backgroundColor?: string;
144
+ /** Primary/accent color */
145
+ primaryColor?: string;
146
+ /** Text color on primary background */
147
+ primaryForegroundColor?: string;
148
+ };
136
149
  }
137
150
  interface MobileMoneyFormData {
138
151
  phone: string;
@@ -159,7 +172,7 @@ interface PaymentIntent {
159
172
  /** Currency code */
160
173
  currency: string;
161
174
  /** Payment status */
162
- status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'cancelled';
175
+ status: 'pending' | 'requires_action' | 'processing' | 'succeeded' | 'failed' | 'canceled' | 'cancelled';
163
176
  /** Recommended PSP based on routing rules */
164
177
  recommendedPsp: 'paystack' | 'hubtel' | 'flutterwave' | 'monnify' | 'mpesa' | 'stripe';
165
178
  /** Available payment methods for this intent */
@@ -190,7 +203,7 @@ interface ReevitContextValue {
190
203
  currency: string;
191
204
  }
192
205
  declare function useReevitContext(): ReevitContextValue;
193
- 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;
194
207
 
195
208
  interface PaymentMethodSelectorProps {
196
209
  methods: PaymentMethod[];
@@ -200,8 +213,17 @@ interface PaymentMethodSelectorProps {
200
213
  provider?: string;
201
214
  layout?: 'grid' | 'list';
202
215
  showLabel?: boolean;
216
+ /** Country code for dynamic logos (e.g., 'GH', 'NG', 'KE') */
217
+ country?: string;
218
+ /** Selected theme colors for method items */
219
+ selectedTheme?: {
220
+ backgroundColor?: string;
221
+ textColor?: string;
222
+ descriptionColor?: string;
223
+ borderColor?: string;
224
+ };
203
225
  }
204
- declare function PaymentMethodSelector({ methods, selectedMethod, onSelect, disabled, provider, layout, showLabel, }: PaymentMethodSelectorProps): react_jsx_runtime.JSX.Element;
226
+ declare function PaymentMethodSelector({ methods, selectedMethod, onSelect, disabled, provider, layout, showLabel, country, selectedTheme, }: PaymentMethodSelectorProps): react_jsx_runtime.JSX.Element;
205
227
 
206
228
  interface MobileMoneyFormProps {
207
229
  onSubmit: (data: MobileMoneyFormData) => void;
@@ -595,6 +617,11 @@ interface PaymentIntentResponse {
595
617
  status: string;
596
618
  client_secret: string;
597
619
  psp_public_key?: string;
620
+ psp_credentials?: {
621
+ merchantAccount?: string | number;
622
+ basicAuth?: string;
623
+ [key: string]: unknown;
624
+ };
598
625
  amount: number;
599
626
  currency: string;
600
627
  fee_amount: number;
@@ -729,9 +756,6 @@ declare class ReevitAPIClient {
729
756
  */
730
757
  declare function createReevitClient(config: ReevitAPIClientConfig): ReevitAPIClient;
731
758
 
732
- /**
733
- * Utility functions for the Reevit React SDK
734
- */
735
759
  /**
736
760
  * Format amount for display
737
761
  */