@reevit/vue 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Reevit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,183 @@
1
+ # @reevit/vue
2
+
3
+ Vue 3 SDK for integrating Reevit unified payments into your application.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @reevit/vue @reevit/core
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ The simplest way to integrate Reevit is using the `ReevitCheckout` component.
14
+
15
+ ```vue
16
+ <script setup lang="ts">
17
+ import { ReevitCheckout } from '@reevit/vue';
18
+ import '@reevit/vue/styles.css';
19
+
20
+ const handleSuccess = (result: any) => {
21
+ console.log('Payment success!', result);
22
+ };
23
+
24
+ const handleError = (error: any) => {
25
+ console.error('Payment failed:', error);
26
+ };
27
+ </script>
28
+
29
+ <template>
30
+ <ReevitCheckout
31
+ publicKey="pk_test_xxx"
32
+ :amount="10000"
33
+ currency="GHS"
34
+ email="customer@example.com"
35
+ @success="handleSuccess"
36
+ @error="handleError"
37
+ >
38
+ <template #default="{ open, isLoading }">
39
+ <button
40
+ class="my-pay-button"
41
+ :disabled="isLoading"
42
+ @click="open"
43
+ >
44
+ {{ isLoading ? 'Loading...' : 'Pay GHS 100.00' }}
45
+ </button>
46
+ </template>
47
+ </ReevitCheckout>
48
+ </template>
49
+ ```
50
+
51
+ ## Custom Theme
52
+
53
+ ```vue
54
+ <ReevitCheckout
55
+ :theme="{
56
+ primaryColor: '#00D1B2',
57
+ backgroundColor: '#FFFFFF',
58
+ darkMode: false,
59
+ borderRadius: '4px'
60
+ }"
61
+ publicKey="pk_test_xxx"
62
+ :amount="5000"
63
+ currency="GHS"
64
+ >
65
+ <button>Pay Now</button>
66
+ </ReevitCheckout>
67
+ ```
68
+
69
+ ## Advanced Usage: useReevit Composable
70
+
71
+ For full control over the payment flow, use the `useReevit` composable.
72
+
73
+ ```vue
74
+ <script setup lang="ts">
75
+ import { useReevit } from '@reevit/vue';
76
+
77
+ const {
78
+ status,
79
+ initialize,
80
+ selectMethod,
81
+ isLoading
82
+ } = useReevit({
83
+ config: {
84
+ publicKey: 'pk_test_xxx',
85
+ amount: 5000,
86
+ currency: 'GHS',
87
+ },
88
+ onSuccess: (res) => console.log('Payment done!', res),
89
+ });
90
+ </script>
91
+
92
+ <template>
93
+ <button @click="initialize">Start Payment</button>
94
+ <div v-if="status === 'ready'">
95
+ <button @click="selectMethod('card')">Card</button>
96
+ <button @click="selectMethod('mobile_money')">Mobile Money</button>
97
+ </div>
98
+ </template>
99
+ ```
100
+
101
+ ## Props Reference
102
+
103
+ | Prop | Type | Description |
104
+ |------|------|-------------|
105
+ | `publicKey` | `string` | Your project's public key |
106
+ | `amount` | `number` | Amount in smallest unit |
107
+ | `currency` | `string` | 3-letter currency code |
108
+ | `email` | `string` | Customer's email |
109
+ | `theme` | `ReevitTheme` | Customization options |
110
+ | `isOpen` | `boolean` | Control modal visibility manually |
111
+
112
+ ## Events
113
+
114
+ | Event | Payload | Description |
115
+ |-------|---------|-------------|
116
+ | `@success` | `PaymentResult` | Called on successful payment |
117
+ | `@error` | `PaymentError` | Called on error |
118
+ | `@close` | `void` | Called when widget is closed |
119
+
120
+ ## PSP Bridge Functions
121
+
122
+ For advanced use cases, you can use PSP bridge functions directly to open payment modals.
123
+
124
+ ### Stripe
125
+
126
+ ```ts
127
+ import { createStripeInstance, confirmStripePayment } from '@reevit/vue';
128
+
129
+ // Create Stripe instance
130
+ const stripe = await createStripeInstance('pk_test_xxx');
131
+ const elements = stripe.elements({ clientSecret: 'pi_xxx_secret_xxx' });
132
+ const paymentElement = elements.create('payment');
133
+ paymentElement.mount('#payment-element');
134
+
135
+ // Later, confirm the payment
136
+ await confirmStripePayment({
137
+ publishableKey: 'pk_test_xxx',
138
+ clientSecret: 'pi_xxx_secret_xxx',
139
+ elements,
140
+ onSuccess: (result) => console.log('Paid:', result.paymentIntentId),
141
+ onError: (err) => console.error(err.message),
142
+ });
143
+ ```
144
+
145
+ ### Monnify (Nigeria)
146
+
147
+ ```ts
148
+ import { openMonnifyModal } from '@reevit/vue';
149
+
150
+ await openMonnifyModal({
151
+ apiKey: 'MK_TEST_xxx',
152
+ contractCode: '1234567890',
153
+ amount: 5000,
154
+ currency: 'NGN',
155
+ reference: 'TXN_12345',
156
+ customerName: 'John Doe',
157
+ customerEmail: 'john@example.com',
158
+ onSuccess: (result) => console.log('Paid:', result.transactionReference),
159
+ onClose: () => console.log('Closed'),
160
+ });
161
+ ```
162
+
163
+ ### M-Pesa (Kenya/Tanzania)
164
+
165
+ ```ts
166
+ import { initiateMPesaSTKPush } from '@reevit/vue';
167
+
168
+ const result = await initiateMPesaSTKPush(
169
+ {
170
+ phoneNumber: '254712345678',
171
+ amount: 500,
172
+ reference: 'TXN_12345',
173
+ onInitiated: () => console.log('STK Push sent'),
174
+ onSuccess: (result) => console.log('Paid:', result.transactionId),
175
+ onError: (err) => console.error(err.message),
176
+ },
177
+ '/api/mpesa/stk-push' // Your backend endpoint
178
+ );
179
+ ```
180
+
181
+ ## License
182
+
183
+ MIT © Reevit
@@ -0,0 +1,2 @@
1
+ export { loadPaystackScript, loadHubtelScript, loadFlutterwaveScript, loadStripeScript, loadMonnifyScript, openPaystackPopup, openHubtelPopup, openFlutterwaveModal, createStripeInstance, confirmStripePayment, openMonnifyModal, initiateMPesaSTKPush, type PaystackConfig, type HubtelConfig, type FlutterwaveConfig, type StripeConfig, type MonnifyConfig, type MPesaConfig, type MPesaSTKPushResult, } from './loaders';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EAGpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
@@ -0,0 +1,224 @@
1
+ /**
2
+ * PSP Script Loaders
3
+ * Dynamic script loading for PSP popups
4
+ */
5
+ declare global {
6
+ interface Window {
7
+ PaystackPop?: {
8
+ setup: (config: Record<string, unknown>) => {
9
+ openIframe: () => void;
10
+ };
11
+ };
12
+ HubtelCheckout?: {
13
+ initPay: (config: Record<string, unknown>) => void;
14
+ };
15
+ FlutterwaveCheckout?: (config: Record<string, unknown>) => void;
16
+ Stripe?: (publishableKey: string) => StripeInstance;
17
+ MonnifySDK?: {
18
+ initialize: (config: Record<string, unknown>) => void;
19
+ };
20
+ }
21
+ }
22
+ interface StripeInstance {
23
+ elements: () => StripeElements;
24
+ confirmCardPayment: (clientSecret: string, data?: {
25
+ payment_method?: string | {
26
+ card: StripeCardElement;
27
+ };
28
+ }) => Promise<{
29
+ error?: {
30
+ message: string;
31
+ };
32
+ paymentIntent?: {
33
+ id: string;
34
+ status: string;
35
+ };
36
+ }>;
37
+ confirmPayment: (options: {
38
+ elements: StripeElements;
39
+ clientSecret: string;
40
+ confirmParams?: {
41
+ return_url?: string;
42
+ };
43
+ redirect?: 'if_required';
44
+ }) => Promise<{
45
+ error?: {
46
+ message: string;
47
+ };
48
+ paymentIntent?: {
49
+ id: string;
50
+ status: string;
51
+ };
52
+ }>;
53
+ }
54
+ interface StripeElements {
55
+ create: (type: string, options?: Record<string, unknown>) => StripeCardElement;
56
+ getElement: (type: string) => StripeCardElement | null;
57
+ }
58
+ interface StripeCardElement {
59
+ mount: (selector: string | HTMLElement) => void;
60
+ unmount: () => void;
61
+ on: (event: string, handler: (e: any) => void) => void;
62
+ destroy: () => void;
63
+ }
64
+ /**
65
+ * Loads the Paystack inline script
66
+ */
67
+ export declare function loadPaystackScript(): Promise<void>;
68
+ /**
69
+ * Loads the Hubtel checkout script
70
+ */
71
+ export declare function loadHubtelScript(): Promise<void>;
72
+ /**
73
+ * Loads the Flutterwave checkout script
74
+ */
75
+ export declare function loadFlutterwaveScript(): Promise<void>;
76
+ /**
77
+ * Loads the Stripe.js script
78
+ */
79
+ export declare function loadStripeScript(): Promise<void>;
80
+ /**
81
+ * Loads the Monnify SDK script
82
+ */
83
+ export declare function loadMonnifyScript(): Promise<void>;
84
+ export interface PaystackConfig {
85
+ key: string;
86
+ email: string;
87
+ amount: number;
88
+ currency: string;
89
+ ref: string;
90
+ metadata?: Record<string, unknown>;
91
+ onSuccess: (response: {
92
+ reference: string;
93
+ [key: string]: unknown;
94
+ }) => void;
95
+ onClose: () => void;
96
+ }
97
+ export interface HubtelConfig {
98
+ clientId: string;
99
+ purchaseDescription: string;
100
+ amount: number;
101
+ callbackUrl?: string;
102
+ customerPhone?: string;
103
+ customerEmail?: string;
104
+ onSuccess: (response: Record<string, unknown>) => void;
105
+ onClose: () => void;
106
+ }
107
+ export interface FlutterwaveConfig {
108
+ public_key: string;
109
+ tx_ref: string;
110
+ amount: number;
111
+ currency: string;
112
+ customer: {
113
+ email: string;
114
+ phone_number?: string;
115
+ name?: string;
116
+ };
117
+ payment_options?: string;
118
+ customizations?: {
119
+ title?: string;
120
+ description?: string;
121
+ logo?: string;
122
+ };
123
+ callback: (response: {
124
+ transaction_id: number;
125
+ tx_ref: string;
126
+ [key: string]: unknown;
127
+ }) => void;
128
+ onclose: () => void;
129
+ }
130
+ export interface StripeConfig {
131
+ publishableKey: string;
132
+ clientSecret: string;
133
+ appearance?: {
134
+ theme?: 'stripe' | 'night' | 'flat';
135
+ variables?: Record<string, string>;
136
+ };
137
+ onSuccess: (response: {
138
+ paymentIntentId: string;
139
+ status: string;
140
+ }) => void;
141
+ onError: (error: {
142
+ message: string;
143
+ }) => void;
144
+ }
145
+ export interface MonnifyConfig {
146
+ apiKey: string;
147
+ contractCode: string;
148
+ amount: number;
149
+ currency: string;
150
+ reference: string;
151
+ customerName: string;
152
+ customerEmail: string;
153
+ customerPhone?: string;
154
+ paymentDescription?: string;
155
+ isTestMode?: boolean;
156
+ metadata?: Record<string, unknown>;
157
+ onSuccess: (response: {
158
+ transactionReference: string;
159
+ paymentReference: string;
160
+ [key: string]: unknown;
161
+ }) => void;
162
+ onClose: () => void;
163
+ onError?: (error: {
164
+ message: string;
165
+ }) => void;
166
+ }
167
+ export interface MPesaConfig {
168
+ phoneNumber: string;
169
+ amount: number;
170
+ reference: string;
171
+ description?: string;
172
+ onInitiated: () => void;
173
+ onSuccess: (response: {
174
+ transactionId: string;
175
+ [key: string]: unknown;
176
+ }) => void;
177
+ onError: (error: {
178
+ message: string;
179
+ }) => void;
180
+ }
181
+ /**
182
+ * Opens Paystack popup
183
+ */
184
+ export declare function openPaystackPopup(config: PaystackConfig): Promise<void>;
185
+ /**
186
+ * Opens Hubtel popup
187
+ */
188
+ export declare function openHubtelPopup(config: HubtelConfig): Promise<void>;
189
+ /**
190
+ * Opens Flutterwave modal
191
+ */
192
+ export declare function openFlutterwaveModal(config: FlutterwaveConfig): Promise<void>;
193
+ /**
194
+ * Creates a Stripe instance for payment processing
195
+ * Returns the Stripe instance for use with Elements
196
+ */
197
+ export declare function createStripeInstance(publishableKey: string): Promise<StripeInstance>;
198
+ /**
199
+ * Confirms a Stripe PaymentIntent using Elements
200
+ */
201
+ export declare function confirmStripePayment(config: StripeConfig & {
202
+ elements: StripeElements;
203
+ }): Promise<void>;
204
+ /**
205
+ * Opens Monnify payment modal
206
+ */
207
+ export declare function openMonnifyModal(config: MonnifyConfig): Promise<void>;
208
+ /**
209
+ * M-Pesa STK Push
210
+ * Note: M-Pesa uses server-to-server STK Push, the customer receives a prompt on their phone.
211
+ * This function handles the UI state while waiting for the push to be accepted.
212
+ */
213
+ export interface MPesaSTKPushResult {
214
+ status: 'initiated' | 'success' | 'failed' | 'cancelled';
215
+ message?: string;
216
+ transactionId?: string;
217
+ }
218
+ /**
219
+ * Initiates M-Pesa STK Push via your backend
220
+ * The actual push is server-side; this handles the UI flow.
221
+ */
222
+ export declare function initiateMPesaSTKPush(config: MPesaConfig, apiEndpoint: string): Promise<MPesaSTKPushResult>;
223
+ export {};
224
+ //# sourceMappingURL=loaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../../src/bridges/loaders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,WAAW,CAAC,EAAE;YACZ,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;gBAC1C,UAAU,EAAE,MAAM,IAAI,CAAC;aACxB,CA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 initialPhone?: string;
3
+ loading?: boolean;
4
+ };
5
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
6
+ submit: (data: MobileMoneyFormData) => any;
7
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onSubmit?: ((data: MobileMoneyFormData) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLFormElement>;
10
+ export default _default;
11
+ //# sourceMappingURL=MobileMoneyForm.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MobileMoneyForm.vue.d.ts","sourceRoot":"","sources":["../../src/components/MobileMoneyForm.vue"],"names":[],"mappings":"AA+GA,KAAK,WAAW,GAAG;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;;;;;;AA6JF,wBAQG"}
@@ -0,0 +1,14 @@
1
+ import { PaymentMethod } from '../../../core/dist/index.d.ts';
2
+ type __VLS_Props = {
3
+ methods: PaymentMethod[];
4
+ selected: PaymentMethod | null;
5
+ amount: number;
6
+ currency: string;
7
+ };
8
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
9
+ select: (method: PaymentMethod) => any;
10
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ onSelect?: ((method: PaymentMethod) => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
13
+ export default _default;
14
+ //# sourceMappingURL=PaymentMethodSelector.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaymentMethodSelector.vue.d.ts","sourceRoot":"","sources":["../../src/components/PaymentMethodSelector.vue"],"names":[],"mappings":"AAuEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;;;;;;AAoHF,wBAQG"}
@@ -0,0 +1,43 @@
1
+ import { ReevitTheme } from '../../../core/dist/index.d.ts';
2
+ type __VLS_Props = {
3
+ publicKey: string;
4
+ amount: number;
5
+ currency: string;
6
+ email?: string;
7
+ phone?: string;
8
+ reference?: string;
9
+ metadata?: Record<string, unknown>;
10
+ paymentMethods?: ('card' | 'mobile_money' | 'bank_transfer')[];
11
+ theme?: ReevitTheme;
12
+ isOpen?: boolean;
13
+ };
14
+ declare function __VLS_template(): {
15
+ attrs: Partial<{}>;
16
+ slots: {
17
+ default?(_: {
18
+ open: () => void;
19
+ isLoading: boolean;
20
+ }): any;
21
+ 'button-text'?(_: {}): any;
22
+ };
23
+ refs: {};
24
+ rootEl: HTMLDivElement;
25
+ };
26
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
27
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
28
+ success: (result: any) => any;
29
+ error: (error: any) => any;
30
+ close: () => any;
31
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
32
+ onSuccess?: ((result: any) => any) | undefined;
33
+ onError?: ((error: any) => any) | undefined;
34
+ onClose?: (() => any) | undefined;
35
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
36
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
37
+ export default _default;
38
+ type __VLS_WithTemplateSlots<T, S> = T & {
39
+ new (): {
40
+ $slots: S;
41
+ };
42
+ };
43
+ //# sourceMappingURL=ReevitCheckout.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReevitCheckout.vue.d.ts","sourceRoot":"","sources":["../../src/components/ReevitCheckout.vue"],"names":[],"mappings":"AAoPA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,cAAc,GAAG,eAAe,CAAC,EAAE,CAAC;IAC/D,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAoIF,iBAAS,cAAc;WAsNT,OAAO,IAA6B;;;;;YAXrB,GAAG;+BACG,GAAG;;;;EAerC;AAuBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;6FAQnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { useReevit } from './useReevit';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { ReevitCheckoutConfig, CheckoutState, PaymentMethod, PaymentResult, PaymentError } from '../../../core/dist/index.d.ts';
2
+ interface UseReevitOptions {
3
+ config: ReevitCheckoutConfig;
4
+ onSuccess?: (result: PaymentResult) => void;
5
+ onError?: (error: PaymentError) => void;
6
+ onClose?: () => void;
7
+ onStateChange?: (state: CheckoutState) => void;
8
+ apiBaseUrl?: string;
9
+ }
10
+ export declare function useReevit(options: UseReevitOptions): {
11
+ status: Readonly<import('vue').Ref<any, any>>;
12
+ paymentIntent: Readonly<import('vue').Ref<any, any>>;
13
+ selectedMethod: Readonly<import('vue').Ref<any, any>>;
14
+ error: Readonly<import('vue').Ref<any, any>>;
15
+ result: Readonly<import('vue').Ref<any, any>>;
16
+ initialize: (method?: PaymentMethod) => Promise<void>;
17
+ selectMethod: (method: PaymentMethod) => void;
18
+ processPayment: (paymentData: Record<string, unknown>) => Promise<void>;
19
+ handlePspSuccess: (pspData: Record<string, unknown>) => Promise<void>;
20
+ handlePspError: (error: PaymentError) => void;
21
+ reset: () => void;
22
+ close: () => Promise<void>;
23
+ isLoading: Readonly<import('vue').Ref<boolean, boolean>>;
24
+ isReady: Readonly<import('vue').Ref<boolean, boolean>>;
25
+ isComplete: Readonly<import('vue').Ref<boolean, boolean>>;
26
+ canRetry: Readonly<import('vue').Ref<any, any>>;
27
+ };
28
+ export {};
29
+ //# sourceMappingURL=useReevit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReevit.d.ts","sourceRoot":"","sources":["../../src/composables/useReevit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EAMlB,MAAM,cAAc,CAAC;AAEtB,UAAU,gBAAgB;IACxB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAqCD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB;;;;;;0BA0Bd,aAAa;2BA8ClB,aAAa;kCAKA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gCA6CzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;4BAKjC,YAAY;;;;;;;EAgE5C"}
@@ -0,0 +1,8 @@
1
+ export { default as ReevitCheckout } from './components/ReevitCheckout.vue';
2
+ export { default as PaymentMethodSelector } from './components/PaymentMethodSelector.vue';
3
+ export { default as MobileMoneyForm } from './components/MobileMoneyForm.vue';
4
+ export { useReevit } from './composables';
5
+ export type { PaymentMethod, MobileMoneyNetwork, ReevitCheckoutConfig, ReevitCheckoutCallbacks, CheckoutState, PaymentResult, PaymentError, ReevitTheme, MobileMoneyFormData, PaymentIntent, PSPType, } from '../../core/dist/index.d.ts';
6
+ export { formatAmount, validatePhone, detectNetwork, formatPhone, detectCountryFromCurrency, cn, ReevitAPIClient, createReevitClient, } from '../../core/dist/index.d.ts';
7
+ export { loadPaystackScript, loadHubtelScript, loadFlutterwaveScript, loadStripeScript, loadMonnifyScript, openPaystackPopup, openHubtelPopup, openFlutterwaveModal, createStripeInstance, confirmStripePayment, openMonnifyModal, initiateMPesaSTKPush, type PaystackConfig, type HubtelConfig, type FlutterwaveConfig, type StripeConfig, type MonnifyConfig, type MPesaConfig, type MPesaSTKPushResult, } from './bridges';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,cAAc,CAAC;AAGtB,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,OAAO,GACR,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,yBAAyB,EACzB,EAAE,EACF,eAAe,EACf,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EAGpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),u=require("@reevit/core");function Q(t){const a=t.toLowerCase();return a.includes("paystack")?"paystack":a.includes("hubtel")?"hubtel":a.includes("flutterwave")?"flutterwave":"paystack"}function W(t,a){return{id:t.id,clientSecret:t.client_secret,amount:t.amount,currency:t.currency,status:t.status,recommendedPsp:Q(t.provider),availableMethods:a.paymentMethods||["card","mobile_money"],connectionId:t.connection_id,provider:t.provider,feeAmount:t.fee_amount,feeCurrency:t.fee_currency,netAmount:t.net_amount,metadata:a.metadata}}function D(t){const{config:a,onSuccess:n,onError:l,onClose:p,onStateChange:c,apiBaseUrl:i}=t,o=e.ref(u.createInitialState()),k=new u.ReevitAPIClient({publicKey:a.publicKey,baseUrl:i}),m=s=>{o.value=u.reevitReducer(o.value,s)};e.watch(()=>o.value.status,s=>{c?.(s)});const y=async s=>{m({type:"INIT_START"});try{const r=a.reference||u.generateReference(),d=u.detectCountryFromCurrency(a.currency),M=s||a.paymentMethods?.[0]||"card",{data:O,error:T}=await k.createPaymentIntent({...a,reference:r},M,d);if(T){m({type:"INIT_ERROR",payload:T}),l?.(T);return}if(!O){const $={code:"INIT_FAILED",message:"No data received from API",recoverable:!0};m({type:"INIT_ERROR",payload:$}),l?.($);return}const J=W(O,{...a,reference:r});m({type:"INIT_SUCCESS",payload:J})}catch(r){const d={code:"INIT_FAILED",message:r instanceof Error?r.message:"Failed to initialize checkout",recoverable:!0,originalError:r};m({type:"INIT_ERROR",payload:d}),l?.(d)}},h=s=>{m({type:"SELECT_METHOD",payload:s})},b=async s=>{if(!(!o.value.paymentIntent||!o.value.selectedMethod)){m({type:"PROCESS_START"});try{const{data:r,error:d}=await k.confirmPayment(o.value.paymentIntent.id);if(d){m({type:"PROCESS_ERROR",payload:d}),l?.(d);return}const M={paymentId:o.value.paymentIntent.id,reference:s.reference||o.value.paymentIntent.metadata?.reference||"",amount:o.value.paymentIntent.amount,currency:o.value.paymentIntent.currency,paymentMethod:o.value.selectedMethod,psp:o.value.paymentIntent.recommendedPsp,pspReference:s.pspReference||r?.provider_ref_id||"",status:"success",metadata:s};m({type:"PROCESS_SUCCESS",payload:M}),n?.(M)}catch(r){const d={code:"PAYMENT_FAILED",message:r instanceof Error?r.message:"Payment failed",recoverable:!0,originalError:r};m({type:"PROCESS_ERROR",payload:d}),l?.(d)}}},I=async s=>{await b(s)},V=s=>{m({type:"PROCESS_ERROR",payload:s}),l?.(s)},f=()=>{m({type:"RESET"})},C=async()=>{if(o.value.paymentIntent&&o.value.status!=="success")try{await k.cancelPaymentIntent(o.value.paymentIntent.id)}catch{}m({type:"CLOSE"}),p?.()},E=e.computed(()=>o.value.status),R=e.computed(()=>o.value.paymentIntent),N=e.computed(()=>o.value.selectedMethod),B=e.computed(()=>o.value.error),v=e.computed(()=>o.value.result),_=e.computed(()=>o.value.status==="loading"||o.value.status==="processing"),S=e.computed(()=>o.value.status==="ready"||o.value.status==="method_selected"||o.value.status==="processing"),w=e.computed(()=>o.value.status==="success"),g=e.computed(()=>o.value.error?.recoverable??!1);return{status:e.readonly(E),paymentIntent:e.readonly(R),selectedMethod:e.readonly(N),error:e.readonly(B),result:e.readonly(v),initialize:y,selectMethod:h,processPayment:b,handlePspSuccess:I,handlePspError:V,reset:f,close:C,isLoading:e.readonly(_),isReady:e.readonly(S),isComplete:e.readonly(w),canRetry:e.readonly(g)}}const X={class:"reevit-method-selector"},Z={class:"reevit-amount-display"},ee={class:"reevit-methods-grid"},te=["onClick"],ne={class:"reevit-method-icon"},oe={class:"reevit-method-info"},re={class:"reevit-method-name"},ae={class:"reevit-method-description"},se={class:"reevit-method-radio"},le={key:0,class:"reevit-radio-inner"},j=e.defineComponent({__name:"PaymentMethodSelector",props:{methods:{},selected:{},amount:{},currency:{}},emits:["select"],setup(t,{emit:a}){const n=t,l=a,p=e.computed(()=>[{id:"card",name:"Card",description:"Visa, Mastercard, Maestro",icon:"💳"},{id:"mobile_money",name:"Mobile Money",description:"MTN, Vodafone, AirtelTigo",icon:"📱"},{id:"bank_transfer",name:"Bank Transfer",description:"Transfer directly from your bank",icon:"🏦"}].filter(c=>n.methods.includes(c.id)));return(c,i)=>(e.openBlock(),e.createElementBlock("div",X,[i[0]||(i[0]=e.createElementVNode("h3",{class:"reevit-section-title"},"Select Payment Method",-1)),e.createElementVNode("p",Z," Pay "+e.toDisplayString(e.unref(u.formatAmount)(t.amount,t.currency)),1),e.createElementVNode("div",ee,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,o=>(e.openBlock(),e.createElementBlock("button",{key:o.id,type:"button",class:e.normalizeClass(e.unref(u.cn)("reevit-method-card",t.selected===o.id&&"reevit-method-card--selected")),onClick:k=>l("select",o.id)},[e.createElementVNode("span",ne,e.toDisplayString(o.icon),1),e.createElementVNode("div",oe,[e.createElementVNode("span",re,e.toDisplayString(o.name),1),e.createElementVNode("span",ae,e.toDisplayString(o.description),1)]),e.createElementVNode("div",se,[t.selected===o.id?(e.openBlock(),e.createElementBlock("div",le)):e.createCommentVNode("",!0)])],10,te))),128))])]))}}),ce={class:"reevit-form-group"},ie=["disabled"],de={class:"reevit-network-selector"},ue={class:"reevit-networks-grid"},me=["onClick","disabled"],pe={key:0,class:"reevit-error-message"},ye=["disabled"],ve={key:0,class:"reevit-spinner"},he={key:1},A=e.defineComponent({__name:"MobileMoneyForm",props:{initialPhone:{},loading:{type:Boolean}},emits:["submit"],setup(t,{emit:a}){const n=t,l=a,p=e.ref(n.initialPhone||""),c=e.ref(null),i=e.ref(null);e.watch(p,m=>{const y=u.detectNetwork(m);y&&(c.value=y),i.value&&(i.value=null)});const o=()=>{if(!u.validatePhone(p.value)){i.value="Please enter a valid phone number";return}if(!c.value){i.value="Please select your mobile network";return}l("submit",{phone:p.value,network:c.value})},k=[{id:"mtn",name:"MTN",color:"#FFCC00"},{id:"vodafone",name:"Vodafone",color:"#E60000"},{id:"airteltigo",name:"AirtelTigo",color:"#005596"}];return(m,y)=>(e.openBlock(),e.createElementBlock("form",{class:"reevit-momo-form",onSubmit:e.withModifiers(o,["prevent"])},[e.createElementVNode("div",ce,[y[1]||(y[1]=e.createElementVNode("label",{class:"reevit-label",for:"reevit-phone"},"Phone Number",-1)),e.withDirectives(e.createElementVNode("input",{id:"reevit-phone","onUpdate:modelValue":y[0]||(y[0]=h=>p.value=h),type:"tel",class:e.normalizeClass(["reevit-input",{"reevit-input--error":i.value&&!e.unref(u.validatePhone)(p.value)}]),placeholder:"e.g. 024 123 4567",disabled:t.loading,autocomplete:"tel"},null,10,ie),[[e.vModelText,p.value]])]),e.createElementVNode("div",de,[y[2]||(y[2]=e.createElementVNode("label",{class:"reevit-label"},"Select Network",-1)),e.createElementVNode("div",ue,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(k,h=>e.createElementVNode("button",{key:h.id,type:"button",class:e.normalizeClass(e.unref(u.cn)("reevit-network-btn",c.value===h.id&&"reevit-network-btn--selected")),onClick:b=>c.value=h.id,disabled:t.loading},[e.createElementVNode("div",{class:"reevit-network-dot",style:e.normalizeStyle({backgroundColor:h.color})},null,4),e.createTextVNode(" "+e.toDisplayString(h.name),1)],10,me)),64))])]),i.value?(e.openBlock(),e.createElementBlock("p",pe,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"submit",class:"reevit-submit-btn",disabled:t.loading||!p.value},[t.loading?(e.openBlock(),e.createElementBlock("span",ve)):(e.openBlock(),e.createElementBlock("span",he,"Continue"))],8,ye),y[3]||(y[3]=e.createElementVNode("p",{class:"reevit-secure-text"}," 🔒 Secure mobile money payment via Reevit ",-1))],32))}}),F=new Map;function P(t,a){const n=F.get(a);if(n)return n;const l=new Promise((p,c)=>{if(document.getElementById(a)){p();return}const i=document.createElement("script");i.id=a,i.src=t,i.async=!0,i.onload=()=>p(),i.onerror=()=>c(new Error(`Failed to load ${a} script`)),document.head.appendChild(i)});return F.set(a,l),l}function K(){return P("https://js.paystack.co/v1/inline.js","paystack-script")}function L(){return P("https://checkout.hubtel.com/js/hubtel-checkout.js","hubtel-script")}function z(){return P("https://checkout.flutterwave.com/v3.js","flutterwave-script")}function x(){return P("https://js.stripe.com/v3/","stripe-script")}function U(){return P("https://sdk.monnify.com/plugin/monnify.js","monnify-script")}async function H(t){if(await K(),!window.PaystackPop)throw new Error("Paystack script not loaded");window.PaystackPop.setup({key:t.key,email:t.email,amount:t.amount,currency:t.currency,ref:t.ref,metadata:t.metadata,callback:t.onSuccess,onClose:t.onClose}).openIframe()}async function q(t){if(await L(),!window.HubtelCheckout)throw new Error("Hubtel script not loaded");window.HubtelCheckout.initPay({clientId:t.clientId,purchaseDescription:t.purchaseDescription,amount:t.amount,callbackUrl:t.callbackUrl,customerPhone:t.customerPhone,customerEmail:t.customerEmail,onSuccess:t.onSuccess,onClose:t.onClose})}async function Y(t){if(await z(),!window.FlutterwaveCheckout)throw new Error("Flutterwave script not loaded");window.FlutterwaveCheckout({public_key:t.public_key,tx_ref:t.tx_ref,amount:t.amount,currency:t.currency,customer:t.customer,payment_options:t.payment_options,customizations:t.customizations,callback:t.callback,onclose:t.onclose})}async function G(t){if(await x(),!window.Stripe)throw new Error("Stripe.js not loaded");return window.Stripe(t)}async function ke(t){const n=await(await G(t.publishableKey)).confirmPayment({elements:t.elements,clientSecret:t.clientSecret,redirect:"if_required"});n.error?t.onError({message:n.error.message||"Payment failed"}):n.paymentIntent&&t.onSuccess({paymentIntentId:n.paymentIntent.id,status:n.paymentIntent.status})}async function be(t){if(await U(),!window.MonnifySDK)throw new Error("Monnify SDK not loaded");window.MonnifySDK.initialize({amount:t.amount,currency:t.currency,reference:t.reference,customerName:t.customerName,customerEmail:t.customerEmail,customerMobileNumber:t.customerPhone,apiKey:t.apiKey,contractCode:t.contractCode,paymentDescription:t.paymentDescription||"Payment",isTestMode:t.isTestMode??!1,metadata:t.metadata,onComplete:a=>{a.status==="SUCCESS"?t.onSuccess({transactionReference:a.transactionReference,paymentReference:a.paymentReference,...a}):t.onError?.({message:a.message||"Payment failed"})},onClose:t.onClose})}async function fe(t,a){t.onInitiated();try{const n=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phone_number:t.phoneNumber,amount:t.amount,reference:t.reference,description:t.description})});if(!n.ok){const c=(await n.json().catch(()=>({}))).message||"Failed to initiate M-Pesa payment";return t.onError({message:c}),{status:"failed",message:c}}const l=await n.json();return{status:"initiated",message:"Please check your phone and enter your M-Pesa PIN to complete the payment.",transactionId:l.checkout_request_id||l.transaction_id}}catch(n){const l=n instanceof Error?n.message:"Network error";return t.onError({message:l}),{status:"failed",message:l}}}const Ee=["disabled"],Se={key:0,class:"reevit-spinner"},we={class:"reevit-modal-body"},Pe={key:0,class:"reevit-loading-state"},Ce={key:1,class:"reevit-error-state"},Ne={key:2,class:"reevit-success-state"},_e={key:1,class:"reevit-method-form-container"},Me={key:2,class:"reevit-card-info"},Ie=["disabled"],Ve={key:0,class:"reevit-spinner"},Re={key:1},Be=e.defineComponent({__name:"ReevitCheckout",props:{publicKey:{},amount:{},currency:{},email:{},phone:{},reference:{},metadata:{},paymentMethods:{},theme:{},isOpen:{type:Boolean}},emits:["success","error","close"],setup(t,{emit:a}){const n=t,l=a,{status:p,paymentIntent:c,selectedMethod:i,error:o,isLoading:k,isReady:m,initialize:y,selectMethod:h,handlePspSuccess:b,handlePspError:I,close:V}=D({config:{publicKey:n.publicKey,amount:n.amount,currency:n.currency,email:n.email,phone:n.phone,reference:n.reference,metadata:n.metadata,paymentMethods:n.paymentMethods},onSuccess:s=>l("success",s),onError:s=>l("error",s),onClose:()=>l("close")}),f=e.ref(n.isOpen??!1);e.watch(()=>n.isOpen,s=>{s!==void 0&&(f.value=s)});const C=()=>{f.value=!0,c.value||y()},E=()=>{f.value=!1,V()},R=s=>{h(s)},N=async s=>{if(!c.value)return;const r=c.value.recommendedPsp;try{r==="paystack"?await H({key:n.publicKey,email:n.email||"",amount:n.amount,currency:n.currency,ref:c.value.id,onSuccess:d=>b(d),onClose:()=>{}}):r==="hubtel"?await q({clientId:n.publicKey,purchaseDescription:`Payment for ${n.amount} ${n.currency}`,amount:n.amount,customerPhone:s?.phone||n.phone,customerEmail:n.email,onSuccess:d=>b(d),onClose:()=>{}}):r==="flutterwave"&&await Y({public_key:n.publicKey,tx_ref:c.value.id,amount:n.amount,currency:n.currency,customer:{email:n.email||"",phone_number:s?.phone||n.phone},callback:d=>b(d),onclose:()=>{}})}catch(d){I({code:"BRIDGE_ERROR",message:d instanceof Error?d.message:"Failed to open payment gateway"})}},B=e.computed(()=>u.createThemeVariables(n.theme||{}));e.watch(f,s=>{s?document.body.style.overflow="hidden":document.body.style.overflow=""}),e.onUnmounted(()=>{document.body.style.overflow=""});const v=e.computed(()=>p.value),_=e.computed(()=>o.value),S=e.computed(()=>i.value),w=e.computed(()=>k.value),g=e.computed(()=>m.value);return(s,r)=>(e.openBlock(),e.createElementBlock("div",{class:"reevit-sdk-container",style:e.normalizeStyle(B.value)},[e.renderSlot(s.$slots,"default",{open:C,isLoading:w.value},()=>[e.createElementVNode("button",{type:"button",class:"reevit-pay-button",onClick:C,disabled:w.value},[w.value?(e.openBlock(),e.createElementBlock("span",Se)):e.renderSlot(s.$slots,"button-text",{key:1},()=>[r[1]||(r[1]=e.createTextVNode("Pay Now",-1))])],8,Ee)]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[f.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"reevit-modal-overlay",onClick:e.withModifiers(E,["self"])},[e.createElementVNode("div",{class:e.normalizeClass(["reevit-modal-content",{"reevit-modal--dark":n.theme?.darkMode}])},[e.createElementVNode("button",{class:"reevit-modal-close",onClick:E,"aria-label":"Close"}," × "),r[9]||(r[9]=e.createElementVNode("div",{class:"reevit-modal-header"},[e.createElementVNode("h2",{class:"reevit-modal-title"},"Reevit Checkout"),e.createElementVNode("p",{class:"reevit-modal-subtitle"},"Secure payment powered by Reevit")],-1)),e.createElementVNode("div",we,[v.value==="loading"?(e.openBlock(),e.createElementBlock("div",Pe,[...r[2]||(r[2]=[e.createElementVNode("div",{class:"reevit-spinner reevit-spinner--large"},null,-1),e.createElementVNode("p",null,"Initializing payment...",-1)])])):v.value==="failed"&&_.value?(e.openBlock(),e.createElementBlock("div",Ce,[r[3]||(r[3]=e.createElementVNode("div",{class:"reevit-error-icon"},"⚠️",-1)),r[4]||(r[4]=e.createElementVNode("h3",null,"Payment Failed",-1)),e.createElementVNode("p",null,e.toDisplayString(_.value.message),1),e.createElementVNode("button",{class:"reevit-retry-btn",onClick:r[0]||(r[0]=d=>e.unref(y)())},"Retry")])):v.value==="success"?(e.openBlock(),e.createElementBlock("div",Ne,[r[5]||(r[5]=e.createElementVNode("div",{class:"reevit-success-icon"},"✅",-1)),r[6]||(r[6]=e.createElementVNode("h3",null,"Payment Successful",-1)),r[7]||(r[7]=e.createElementVNode("p",null,"Thank you for your payment.",-1)),e.createElementVNode("button",{class:"reevit-done-btn",onClick:E},"Done")])):g.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[v.value==="ready"||v.value==="method_selected"||v.value==="processing"?(e.openBlock(),e.createBlock(j,{key:0,methods:n.paymentMethods||["card","mobile_money"],selected:S.value,amount:n.amount,currency:n.currency,onSelect:R},null,8,["methods","selected","amount","currency"])):e.createCommentVNode("",!0),(v.value==="method_selected"||v.value==="processing")&&S.value==="mobile_money"?(e.openBlock(),e.createElementBlock("div",_e,[e.createVNode(A,{"initial-phone":n.phone,loading:v.value==="processing",onSubmit:N},null,8,["initial-phone","loading"])])):e.createCommentVNode("",!0),(v.value==="method_selected"||v.value==="processing")&&S.value==="card"?(e.openBlock(),e.createElementBlock("div",Me,[r[8]||(r[8]=e.createElementVNode("p",{class:"reevit-info-text"},"You will be redirected to our secure payment partner to complete your card payment.",-1)),e.createElementVNode("button",{class:"reevit-submit-btn",onClick:N,disabled:v.value==="processing"},[v.value==="processing"?(e.openBlock(),e.createElementBlock("span",Ve)):(e.openBlock(),e.createElementBlock("span",Re,"Proceed to Card Payment"))],8,Ie)])):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)]),r[10]||(r[10]=e.createElementVNode("div",{class:"reevit-modal-footer"},[e.createElementVNode("div",{class:"reevit-trust-badges"},[e.createElementVNode("span",null,"PCI DSS Compliant"),e.createElementVNode("span",null,"•"),e.createElementVNode("span",null,"SSL Secure")])],-1))],2)])):e.createCommentVNode("",!0)]))],4))}});Object.defineProperty(exports,"ReevitAPIClient",{enumerable:!0,get:()=>u.ReevitAPIClient});Object.defineProperty(exports,"cn",{enumerable:!0,get:()=>u.cn});Object.defineProperty(exports,"createReevitClient",{enumerable:!0,get:()=>u.createReevitClient});Object.defineProperty(exports,"detectCountryFromCurrency",{enumerable:!0,get:()=>u.detectCountryFromCurrency});Object.defineProperty(exports,"detectNetwork",{enumerable:!0,get:()=>u.detectNetwork});Object.defineProperty(exports,"formatAmount",{enumerable:!0,get:()=>u.formatAmount});Object.defineProperty(exports,"formatPhone",{enumerable:!0,get:()=>u.formatPhone});Object.defineProperty(exports,"validatePhone",{enumerable:!0,get:()=>u.validatePhone});exports.MobileMoneyForm=A;exports.PaymentMethodSelector=j;exports.ReevitCheckout=Be;exports.confirmStripePayment=ke;exports.createStripeInstance=G;exports.initiateMPesaSTKPush=fe;exports.loadFlutterwaveScript=z;exports.loadHubtelScript=L;exports.loadMonnifyScript=U;exports.loadPaystackScript=K;exports.loadStripeScript=x;exports.openFlutterwaveModal=Y;exports.openHubtelPopup=q;exports.openMonnifyModal=be;exports.openPaystackPopup=H;exports.useReevit=D;