@reevit/vue 0.4.0 → 0.4.6
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/dist/bridges/loaders.d.ts +2 -0
- package/dist/components/MobileMoneyForm.vue.d.ts +3 -0
- package/dist/components/PaymentMethodSelector.vue.d.ts +2 -2
- package/dist/components/ProviderSelector.vue.d.ts +31 -0
- package/dist/components/ReevitCheckout.vue.d.ts +4 -1
- package/dist/composables/useReevit.d.ts +48 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +917 -594
- package/dist/styles.css +1 -1
- package/dist/vue.css +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,334 +1,517 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { createInitialState as
|
|
3
|
-
import { ReevitAPIClient as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
1
|
+
import { ref as V, watch as j, computed as f, readonly as N, defineComponent as ee, createElementBlock as v, openBlock as m, normalizeClass as z, createCommentVNode as L, createElementVNode as r, unref as q, Fragment as Y, renderList as re, normalizeStyle as Z, toDisplayString as I, renderSlot as ae, createVNode as ie, withModifiers as ue, withDirectives as ye, vModelText as be, createTextVNode as pe, onUnmounted as fe, createBlock as se, Teleport as _e, withCtx as ke } from "vue";
|
|
2
|
+
import { createInitialState as we, ReevitAPIClient as Pe, generateReference as ge, detectCountryFromCurrency as Ce, reevitReducer as Se, cn as me, detectNetwork as Me, validatePhone as le, createReevitClient as Ie, createThemeVariables as Ee } from "@reevit/core";
|
|
3
|
+
import { ReevitAPIClient as Zt, cn as en, createReevitClient as tn, detectCountryFromCurrency as nn, detectNetwork as on, formatAmount as sn, formatPhone as an, validatePhone as rn } from "@reevit/core";
|
|
4
|
+
const Re = "https://api.reevit.io";
|
|
5
|
+
function $e(e, t) {
|
|
6
|
+
return {
|
|
7
|
+
code: t?.code || "payment_link_error",
|
|
8
|
+
message: t?.message || "Payment link request failed",
|
|
9
|
+
recoverable: !0,
|
|
10
|
+
details: {
|
|
11
|
+
httpStatus: e.status,
|
|
12
|
+
...t?.details || {}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
7
15
|
}
|
|
8
|
-
function
|
|
16
|
+
function xe(e) {
|
|
17
|
+
const t = e.toLowerCase();
|
|
18
|
+
return t.includes("paystack") ? "paystack" : t.includes("hubtel") ? "hubtel" : t.includes("flutterwave") ? "flutterwave" : t.includes("stripe") ? "stripe" : t.includes("monnify") ? "monnify" : t.includes("mpesa") || t.includes("m-pesa") ? "mpesa" : "paystack";
|
|
19
|
+
}
|
|
20
|
+
function Le(e) {
|
|
21
|
+
const t = e.toLowerCase().trim();
|
|
22
|
+
return t === "card" ? "card" : t === "mobile_money" || t === "momo" || t === "mobilemoney" ? "mobile_money" : t === "bank" || t === "bank_transfer" || t === "transfer" ? "bank_transfer" : null;
|
|
23
|
+
}
|
|
24
|
+
function Te(e) {
|
|
25
|
+
if (!(!e || e.length === 0))
|
|
26
|
+
return e.map((t) => {
|
|
27
|
+
const n = t.methods.map((d) => Le(d)).filter(Boolean);
|
|
28
|
+
return {
|
|
29
|
+
provider: t.provider,
|
|
30
|
+
name: t.name,
|
|
31
|
+
methods: n,
|
|
32
|
+
countries: t.countries
|
|
33
|
+
};
|
|
34
|
+
}).filter((t) => t.methods.length > 0);
|
|
35
|
+
}
|
|
36
|
+
function Ne(e, t) {
|
|
9
37
|
return {
|
|
10
|
-
id:
|
|
11
|
-
clientSecret:
|
|
12
|
-
pspPublicKey:
|
|
13
|
-
pspCredentials:
|
|
14
|
-
amount:
|
|
15
|
-
currency:
|
|
16
|
-
status:
|
|
17
|
-
recommendedPsp:
|
|
18
|
-
availableMethods:
|
|
19
|
-
reference:
|
|
20
|
-
connectionId:
|
|
21
|
-
provider:
|
|
22
|
-
feeAmount:
|
|
23
|
-
feeCurrency:
|
|
24
|
-
netAmount:
|
|
25
|
-
metadata:
|
|
38
|
+
id: e.id,
|
|
39
|
+
clientSecret: e.client_secret,
|
|
40
|
+
pspPublicKey: e.psp_public_key,
|
|
41
|
+
pspCredentials: e.psp_credentials,
|
|
42
|
+
amount: e.amount,
|
|
43
|
+
currency: e.currency,
|
|
44
|
+
status: e.status,
|
|
45
|
+
recommendedPsp: xe(e.provider),
|
|
46
|
+
availableMethods: t.paymentMethods || ["card", "mobile_money"],
|
|
47
|
+
reference: e.reference || t.reference,
|
|
48
|
+
connectionId: e.connection_id,
|
|
49
|
+
provider: e.provider,
|
|
50
|
+
feeAmount: e.fee_amount,
|
|
51
|
+
feeCurrency: e.fee_currency,
|
|
52
|
+
netAmount: e.net_amount,
|
|
53
|
+
metadata: t.metadata,
|
|
54
|
+
availableProviders: Te(e.available_psps),
|
|
55
|
+
branding: e.branding
|
|
26
56
|
};
|
|
27
57
|
}
|
|
28
|
-
function
|
|
29
|
-
const { config:
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
...
|
|
58
|
+
function Ue(e) {
|
|
59
|
+
const { config: t, onSuccess: n, onError: d, onClose: i, onStateChange: p, apiBaseUrl: u } = e, a = V(we());
|
|
60
|
+
if (t.initialPaymentIntent) {
|
|
61
|
+
const b = t.initialPaymentIntent;
|
|
62
|
+
a.value = {
|
|
63
|
+
...a.value,
|
|
34
64
|
status: "ready",
|
|
35
|
-
paymentIntent:
|
|
36
|
-
selectedMethod:
|
|
65
|
+
paymentIntent: b,
|
|
66
|
+
selectedMethod: b.availableMethods?.length === 1 ? b.availableMethods[0] : null
|
|
37
67
|
};
|
|
38
68
|
}
|
|
39
|
-
const
|
|
40
|
-
publicKey:
|
|
41
|
-
baseUrl:
|
|
42
|
-
}),
|
|
43
|
-
|
|
69
|
+
const h = new Pe({
|
|
70
|
+
publicKey: t.publicKey,
|
|
71
|
+
baseUrl: u
|
|
72
|
+
}), o = (b) => {
|
|
73
|
+
a.value = Se(a.value, b);
|
|
44
74
|
};
|
|
45
|
-
|
|
46
|
-
() =>
|
|
47
|
-
(
|
|
48
|
-
|
|
75
|
+
j(
|
|
76
|
+
() => a.value.status,
|
|
77
|
+
(b) => {
|
|
78
|
+
p?.(b);
|
|
49
79
|
}
|
|
50
80
|
);
|
|
51
|
-
const
|
|
52
|
-
|
|
81
|
+
const l = async (b, w) => {
|
|
82
|
+
o({ type: "INIT_START" });
|
|
53
83
|
try {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
84
|
+
const g = t.reference || ge(), E = Ce(t.currency), $ = t.paymentMethods && t.paymentMethods.length === 1 ? t.paymentMethods[0] : void 0, R = b ?? $;
|
|
85
|
+
let D, C;
|
|
86
|
+
if (t.paymentLinkCode) {
|
|
87
|
+
const x = await fetch(
|
|
88
|
+
`${u || Re}/v1/pay/${t.paymentLinkCode}/pay`,
|
|
89
|
+
{
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
"Idempotency-Key": `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify({
|
|
96
|
+
amount: t.amount,
|
|
97
|
+
email: t.email || "",
|
|
98
|
+
name: t.customerName || "",
|
|
99
|
+
phone: t.phone || "",
|
|
100
|
+
method: R,
|
|
101
|
+
country: E,
|
|
102
|
+
provider: w?.preferredProvider || w?.allowedProviders?.[0],
|
|
103
|
+
custom_fields: t.customFields
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
), c = await x.json().catch(() => ({}));
|
|
107
|
+
x.ok ? D = c : C = $e(x, c);
|
|
108
|
+
} else {
|
|
109
|
+
const x = await h.createPaymentIntent(
|
|
110
|
+
{ ...t, reference: g },
|
|
111
|
+
R,
|
|
112
|
+
E,
|
|
113
|
+
{
|
|
114
|
+
preferredProviders: w?.preferredProvider ? [w.preferredProvider] : void 0,
|
|
115
|
+
allowedProviders: w?.allowedProviders
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
D = x.data, C = x.error;
|
|
119
|
+
}
|
|
120
|
+
if (C) {
|
|
121
|
+
o({ type: "INIT_ERROR", payload: C }), d?.(C);
|
|
61
122
|
return;
|
|
62
123
|
}
|
|
63
|
-
if (!
|
|
64
|
-
const
|
|
124
|
+
if (!D) {
|
|
125
|
+
const x = {
|
|
65
126
|
code: "INIT_FAILED",
|
|
66
127
|
message: "No data received from API",
|
|
67
128
|
recoverable: !0
|
|
68
129
|
};
|
|
69
|
-
|
|
130
|
+
o({ type: "INIT_ERROR", payload: x }), d?.(x);
|
|
70
131
|
return;
|
|
71
132
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
} catch (
|
|
75
|
-
const
|
|
133
|
+
const H = Ne(D, { ...t, reference: g });
|
|
134
|
+
o({ type: "INIT_SUCCESS", payload: H });
|
|
135
|
+
} catch (g) {
|
|
136
|
+
const E = {
|
|
76
137
|
code: "INIT_FAILED",
|
|
77
|
-
message:
|
|
138
|
+
message: g instanceof Error ? g.message : "Failed to initialize checkout",
|
|
78
139
|
recoverable: !0,
|
|
79
|
-
originalError:
|
|
140
|
+
originalError: g
|
|
80
141
|
};
|
|
81
|
-
|
|
142
|
+
o({ type: "INIT_ERROR", payload: E }), d?.(E);
|
|
82
143
|
}
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
if (!(!
|
|
87
|
-
|
|
144
|
+
}, _ = (b) => {
|
|
145
|
+
o({ type: "SELECT_METHOD", payload: b });
|
|
146
|
+
}, T = async (b) => {
|
|
147
|
+
if (!(!a.value.paymentIntent || !a.value.selectedMethod)) {
|
|
148
|
+
o({ type: "PROCESS_START" });
|
|
88
149
|
try {
|
|
89
|
-
let
|
|
90
|
-
if (
|
|
91
|
-
const { data:
|
|
92
|
-
|
|
93
|
-
|
|
150
|
+
let w;
|
|
151
|
+
if (a.value.paymentIntent.clientSecret) {
|
|
152
|
+
const { data: E, error: $ } = await h.confirmPaymentIntent(
|
|
153
|
+
a.value.paymentIntent.id,
|
|
154
|
+
a.value.paymentIntent.clientSecret
|
|
94
155
|
);
|
|
95
|
-
if (
|
|
96
|
-
|
|
156
|
+
if ($) {
|
|
157
|
+
o({ type: "PROCESS_ERROR", payload: $ }), d?.($);
|
|
97
158
|
return;
|
|
98
159
|
}
|
|
99
|
-
|
|
160
|
+
w = E;
|
|
100
161
|
} else {
|
|
101
|
-
const { data:
|
|
102
|
-
if (
|
|
103
|
-
|
|
162
|
+
const { data: E, error: $ } = await h.confirmPayment(a.value.paymentIntent.id);
|
|
163
|
+
if ($) {
|
|
164
|
+
o({ type: "PROCESS_ERROR", payload: $ }), d?.($);
|
|
104
165
|
return;
|
|
105
166
|
}
|
|
106
|
-
|
|
167
|
+
w = E;
|
|
107
168
|
}
|
|
108
|
-
const
|
|
109
|
-
paymentId:
|
|
110
|
-
reference:
|
|
111
|
-
amount:
|
|
112
|
-
currency:
|
|
113
|
-
paymentMethod:
|
|
114
|
-
psp:
|
|
115
|
-
pspReference:
|
|
169
|
+
const g = {
|
|
170
|
+
paymentId: a.value.paymentIntent.id,
|
|
171
|
+
reference: b.reference || a.value.paymentIntent.reference || a.value.paymentIntent.metadata?.reference || "",
|
|
172
|
+
amount: a.value.paymentIntent.amount,
|
|
173
|
+
currency: a.value.paymentIntent.currency,
|
|
174
|
+
paymentMethod: a.value.selectedMethod,
|
|
175
|
+
psp: a.value.paymentIntent.recommendedPsp,
|
|
176
|
+
pspReference: b.pspReference || w?.provider_ref_id || "",
|
|
116
177
|
status: "success",
|
|
117
|
-
metadata:
|
|
178
|
+
metadata: b
|
|
118
179
|
};
|
|
119
|
-
|
|
120
|
-
} catch (
|
|
121
|
-
const
|
|
180
|
+
o({ type: "PROCESS_SUCCESS", payload: g }), n?.(g);
|
|
181
|
+
} catch (w) {
|
|
182
|
+
const g = {
|
|
122
183
|
code: "PAYMENT_FAILED",
|
|
123
|
-
message:
|
|
184
|
+
message: w instanceof Error ? w.message : "Payment failed",
|
|
124
185
|
recoverable: !0,
|
|
125
|
-
originalError:
|
|
186
|
+
originalError: w
|
|
126
187
|
};
|
|
127
|
-
|
|
188
|
+
o({ type: "PROCESS_ERROR", payload: g }), d?.(g);
|
|
128
189
|
}
|
|
129
190
|
}
|
|
130
|
-
},
|
|
131
|
-
await
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
if (
|
|
191
|
+
}, U = async (b) => {
|
|
192
|
+
await T(b);
|
|
193
|
+
}, ne = (b) => {
|
|
194
|
+
o({ type: "PROCESS_ERROR", payload: b }), d?.(b);
|
|
195
|
+
}, W = () => {
|
|
196
|
+
o({ type: "RESET" });
|
|
197
|
+
}, O = async () => {
|
|
198
|
+
if (a.value.paymentIntent && a.value.status !== "success")
|
|
138
199
|
try {
|
|
139
|
-
await
|
|
200
|
+
await h.cancelPaymentIntent(a.value.paymentIntent.id);
|
|
140
201
|
} catch {
|
|
141
202
|
}
|
|
142
|
-
|
|
143
|
-
}, M =
|
|
144
|
-
() =>
|
|
145
|
-
),
|
|
146
|
-
() =>
|
|
147
|
-
),
|
|
203
|
+
o({ type: "CLOSE" }), i?.();
|
|
204
|
+
}, M = f(() => a.value.status), G = f(() => a.value.paymentIntent), Q = f(() => a.value.selectedMethod), J = f(() => a.value.error), F = f(() => a.value.result), A = f(
|
|
205
|
+
() => a.value.status === "loading" || a.value.status === "processing"
|
|
206
|
+
), S = f(
|
|
207
|
+
() => a.value.status === "ready" || a.value.status === "method_selected" || a.value.status === "processing"
|
|
208
|
+
), X = f(() => a.value.status === "success"), oe = f(() => a.value.error?.recoverable ?? !1);
|
|
148
209
|
return {
|
|
149
210
|
// State (readonly refs)
|
|
150
|
-
status:
|
|
151
|
-
paymentIntent:
|
|
152
|
-
selectedMethod:
|
|
153
|
-
error:
|
|
154
|
-
result:
|
|
211
|
+
status: N(M),
|
|
212
|
+
paymentIntent: N(G),
|
|
213
|
+
selectedMethod: N(Q),
|
|
214
|
+
error: N(J),
|
|
215
|
+
result: N(F),
|
|
155
216
|
// Actions
|
|
156
|
-
initialize:
|
|
157
|
-
selectMethod:
|
|
158
|
-
processPayment:
|
|
159
|
-
handlePspSuccess:
|
|
160
|
-
handlePspError:
|
|
161
|
-
reset:
|
|
162
|
-
close:
|
|
217
|
+
initialize: l,
|
|
218
|
+
selectMethod: _,
|
|
219
|
+
processPayment: T,
|
|
220
|
+
handlePspSuccess: U,
|
|
221
|
+
handlePspError: ne,
|
|
222
|
+
reset: W,
|
|
223
|
+
close: O,
|
|
163
224
|
// Computed
|
|
164
|
-
isLoading:
|
|
165
|
-
isReady:
|
|
166
|
-
isComplete:
|
|
167
|
-
canRetry:
|
|
225
|
+
isLoading: N(A),
|
|
226
|
+
isReady: N(S),
|
|
227
|
+
isComplete: N(X),
|
|
228
|
+
canRetry: N(oe)
|
|
168
229
|
};
|
|
169
230
|
}
|
|
170
|
-
const
|
|
231
|
+
const Oe = {
|
|
232
|
+
key: 0,
|
|
233
|
+
class: "reevit-method-selector__label"
|
|
234
|
+
}, Fe = ["onClick"], Ae = { class: "reevit-method-option__icon-wrapper" }, De = { class: "reevit-method-option__icon" }, Ke = { class: "reevit-method-option__content" }, je = { class: "reevit-method-option__label" }, ze = {
|
|
171
235
|
key: 0,
|
|
172
|
-
class: "reevit-
|
|
173
|
-
},
|
|
236
|
+
class: "reevit-method-option__description"
|
|
237
|
+
}, He = {
|
|
238
|
+
key: 0,
|
|
239
|
+
class: "reevit-method-option__check"
|
|
240
|
+
}, Be = {
|
|
241
|
+
key: 1,
|
|
242
|
+
class: "reevit-method-option__chevron"
|
|
243
|
+
}, ve = /* @__PURE__ */ ee({
|
|
174
244
|
__name: "PaymentMethodSelector",
|
|
175
245
|
props: {
|
|
176
246
|
methods: {},
|
|
177
247
|
selected: {},
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
248
|
+
provider: {},
|
|
249
|
+
layout: {},
|
|
250
|
+
showLabel: { type: Boolean }
|
|
181
251
|
},
|
|
182
252
|
emits: ["select"],
|
|
183
|
-
setup(
|
|
184
|
-
const e =
|
|
185
|
-
hubtel: "Hubtel",
|
|
186
|
-
paystack: "Paystack",
|
|
187
|
-
flutterwave: "Flutterwave",
|
|
188
|
-
monnify: "Monnify",
|
|
189
|
-
mpesa: "M-Pesa",
|
|
190
|
-
stripe: "Stripe"
|
|
191
|
-
}, m = (p) => e.provider?.toLowerCase().includes("hubtel") && p === "mobile_money" ? `Pay with ${o[e.provider.toLowerCase()] || "Hubtel"}` : {
|
|
192
|
-
card: "Card",
|
|
193
|
-
mobile_money: "Mobile Money",
|
|
194
|
-
bank_transfer: "Bank Transfer"
|
|
195
|
-
}[p], d = (p) => e.provider?.toLowerCase().includes("hubtel") ? "Card, Mobile Money, and Bank Transfer" : {
|
|
196
|
-
card: "Visa, Mastercard, Maestro",
|
|
197
|
-
mobile_money: "MTN, Vodafone, AirtelTigo",
|
|
198
|
-
bank_transfer: "Transfer directly from your bank"
|
|
199
|
-
}[p], s = w(() => [
|
|
253
|
+
setup(e, { emit: t }) {
|
|
254
|
+
const n = e, { showLabel: d = !0 } = n, i = t, p = f(() => (n.layout || "list") === "grid"), u = f(() => [
|
|
200
255
|
{
|
|
201
256
|
id: "card",
|
|
202
|
-
name:
|
|
203
|
-
|
|
204
|
-
|
|
257
|
+
name: "Card",
|
|
258
|
+
icon: "💳",
|
|
259
|
+
description: "Pay with Visa, Mastercard, or other cards"
|
|
205
260
|
},
|
|
206
261
|
{
|
|
207
262
|
id: "mobile_money",
|
|
208
|
-
name:
|
|
209
|
-
|
|
210
|
-
|
|
263
|
+
name: "Mobile Money",
|
|
264
|
+
icon: "📱",
|
|
265
|
+
description: "MTN, Vodafone Cash, AirtelTigo Money"
|
|
211
266
|
},
|
|
212
267
|
{
|
|
213
268
|
id: "bank_transfer",
|
|
214
|
-
name:
|
|
215
|
-
|
|
216
|
-
|
|
269
|
+
name: "Bank Transfer",
|
|
270
|
+
icon: "🏦",
|
|
271
|
+
description: "Pay directly from your bank account"
|
|
217
272
|
}
|
|
218
|
-
].filter((
|
|
219
|
-
return (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
273
|
+
].filter((a) => n.methods.includes(a.id)));
|
|
274
|
+
return (a, h) => (m(), v("div", {
|
|
275
|
+
class: z(["reevit-method-selector", { "reevit-method-selector--grid": p.value }])
|
|
276
|
+
}, [
|
|
277
|
+
q(d) ? (m(), v("div", Oe, "Select payment method")) : L("", !0),
|
|
278
|
+
r("div", {
|
|
279
|
+
class: z(["reevit-method-selector__options", p.value ? "reevit-method-selector__options--grid" : "reevit-method-selector__options--list"])
|
|
280
|
+
}, [
|
|
281
|
+
(m(!0), v(Y, null, re(u.value, (o, l) => (m(), v("button", {
|
|
282
|
+
key: o.id,
|
|
225
283
|
type: "button",
|
|
226
|
-
class:
|
|
227
|
-
|
|
284
|
+
class: z(["reevit-method-option", [
|
|
285
|
+
p.value ? "reevit-method-option--grid" : "reevit-method-option--list",
|
|
286
|
+
{ "reevit-method-option--selected": e.selected === o.id }
|
|
287
|
+
]]),
|
|
288
|
+
style: Z({ animationDelay: `${l * 0.05}s` }),
|
|
289
|
+
onClick: (_) => i("select", o.id)
|
|
228
290
|
}, [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
c("span", Ee, I(a.name), 1),
|
|
232
|
-
c("span", Ie, I(a.description), 1)
|
|
291
|
+
r("span", Ae, [
|
|
292
|
+
r("span", De, I(o.icon), 1)
|
|
233
293
|
]),
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
294
|
+
r("div", Ke, [
|
|
295
|
+
r("span", je, I(o.name), 1),
|
|
296
|
+
p.value ? L("", !0) : (m(), v("span", ze, I(o.description), 1))
|
|
297
|
+
]),
|
|
298
|
+
p.value ? L("", !0) : (m(), v(Y, { key: 0 }, [
|
|
299
|
+
e.selected === o.id ? (m(), v("span", He, [...h[0] || (h[0] = [
|
|
300
|
+
r("svg", {
|
|
301
|
+
width: "20",
|
|
302
|
+
height: "20",
|
|
303
|
+
viewBox: "0 0 24 24",
|
|
304
|
+
fill: "none",
|
|
305
|
+
stroke: "currentColor",
|
|
306
|
+
"stroke-width": "3",
|
|
307
|
+
"stroke-linecap": "round",
|
|
308
|
+
"stroke-linejoin": "round"
|
|
309
|
+
}, [
|
|
310
|
+
r("polyline", { points: "20 6 9 17 4 12" })
|
|
311
|
+
], -1)
|
|
312
|
+
])])) : (m(), v("span", Be, [...h[1] || (h[1] = [
|
|
313
|
+
r("svg", {
|
|
314
|
+
width: "16",
|
|
315
|
+
height: "16",
|
|
316
|
+
viewBox: "0 0 24 24",
|
|
317
|
+
fill: "none",
|
|
318
|
+
stroke: "currentColor",
|
|
319
|
+
"stroke-width": "2.5",
|
|
320
|
+
"stroke-linecap": "round",
|
|
321
|
+
"stroke-linejoin": "round"
|
|
322
|
+
}, [
|
|
323
|
+
r("polyline", { points: "9 18 15 12 9 6" })
|
|
324
|
+
], -1)
|
|
325
|
+
])]))
|
|
326
|
+
], 64))
|
|
327
|
+
], 14, Fe))), 128))
|
|
328
|
+
], 2)
|
|
329
|
+
], 2));
|
|
330
|
+
}
|
|
331
|
+
}), Ve = { class: "reevit-psp-selector" }, qe = { class: "reevit-psp-selector__options" }, Ye = ["disabled", "aria-expanded", "onClick"], Ge = {
|
|
332
|
+
class: "reevit-psp-option__logo",
|
|
333
|
+
"aria-hidden": "true"
|
|
334
|
+
}, Je = ["src"], We = {
|
|
335
|
+
key: 1,
|
|
336
|
+
class: "reevit-psp-option__logo-fallback"
|
|
337
|
+
}, Qe = { class: "reevit-psp-option__content" }, Xe = { class: "reevit-psp-option__name" }, Ze = { class: "reevit-psp-option__methods" }, et = {
|
|
338
|
+
key: 0,
|
|
339
|
+
class: "reevit-psp-accordion__content reevit-animate-fade-in"
|
|
340
|
+
}, tt = { class: "reevit-psp-methods" }, nt = /* @__PURE__ */ ee({
|
|
341
|
+
__name: "ProviderSelector",
|
|
342
|
+
props: {
|
|
343
|
+
providers: {},
|
|
344
|
+
selectedProvider: {},
|
|
345
|
+
disabled: { type: Boolean },
|
|
346
|
+
theme: {},
|
|
347
|
+
selectedMethod: {}
|
|
348
|
+
},
|
|
349
|
+
emits: ["select", "methodSelect"],
|
|
350
|
+
setup(e, { emit: t }) {
|
|
351
|
+
const n = t, d = {
|
|
352
|
+
paystack: "https://reevit.io/images/providers/paystack.png",
|
|
353
|
+
stripe: "https://reevit.io/images/providers/stripe.png",
|
|
354
|
+
flutterwave: "https://reevit.io/images/providers/flutterwave.png",
|
|
355
|
+
hubtel: "https://reevit.io/images/providers/hubtel.png",
|
|
356
|
+
monnify: "https://reevit.io/images/providers/monnify.png",
|
|
357
|
+
mpesa: "https://reevit.io/images/providers/mpesa.png"
|
|
358
|
+
}, i = {
|
|
359
|
+
card: "Card",
|
|
360
|
+
mobile_money: "Mobile Money",
|
|
361
|
+
bank_transfer: "Bank Transfer"
|
|
362
|
+
}, p = (a) => a.length ? a.map((h) => i[h]).join(", ") : "Payment methods", u = (a, h) => a.toLowerCase().includes("hubtel") ? h.filter((o) => o === "card" || o === "mobile_money") : h;
|
|
363
|
+
return (a, h) => (m(), v("div", Ve, [
|
|
364
|
+
h[1] || (h[1] = r("div", { class: "reevit-psp-selector__label" }, "Select payment provider", -1)),
|
|
365
|
+
r("div", qe, [
|
|
366
|
+
(m(!0), v(Y, null, re(e.providers, (o) => (m(), v("div", {
|
|
367
|
+
key: o.provider,
|
|
368
|
+
class: "reevit-psp-accordion"
|
|
369
|
+
}, [
|
|
370
|
+
r("button", {
|
|
371
|
+
type: "button",
|
|
372
|
+
class: z(
|
|
373
|
+
q(me)(
|
|
374
|
+
"reevit-psp-option",
|
|
375
|
+
e.selectedProvider === o.provider && "reevit-psp-option--selected",
|
|
376
|
+
e.disabled && "reevit-psp-option--disabled"
|
|
377
|
+
)
|
|
378
|
+
),
|
|
379
|
+
disabled: e.disabled,
|
|
380
|
+
"aria-expanded": e.selectedProvider === o.provider,
|
|
381
|
+
onClick: (l) => n("select", o.provider)
|
|
382
|
+
}, [
|
|
383
|
+
r("span", Ge, [
|
|
384
|
+
d[o.provider] ? (m(), v("img", {
|
|
385
|
+
key: 0,
|
|
386
|
+
src: d[o.provider],
|
|
387
|
+
alt: "",
|
|
388
|
+
class: "reevit-psp-option__logo-img",
|
|
389
|
+
loading: "lazy"
|
|
390
|
+
}, null, 8, Je)) : (m(), v("span", We, I(o.name.slice(0, 1).toUpperCase()), 1))
|
|
391
|
+
]),
|
|
392
|
+
r("div", Qe, [
|
|
393
|
+
r("span", Xe, I(o.name), 1),
|
|
394
|
+
r("span", Ze, I(p(u(o.provider, o.methods))), 1)
|
|
395
|
+
])
|
|
396
|
+
], 10, Ye),
|
|
397
|
+
e.selectedProvider === o.provider ? (m(), v("div", et, [
|
|
398
|
+
r("div", tt, [
|
|
399
|
+
ie(ve, {
|
|
400
|
+
methods: u(o.provider, o.methods),
|
|
401
|
+
selected: e.selectedMethod || null,
|
|
402
|
+
provider: o.provider,
|
|
403
|
+
"show-label": !1,
|
|
404
|
+
layout: "list",
|
|
405
|
+
onSelect: h[0] || (h[0] = (l) => n("methodSelect", l))
|
|
406
|
+
}, null, 8, ["methods", "selected", "provider"])
|
|
407
|
+
]),
|
|
408
|
+
ae(a.$slots, "method-content")
|
|
409
|
+
])) : L("", !0)
|
|
410
|
+
]))), 128))
|
|
238
411
|
])
|
|
239
412
|
]));
|
|
240
413
|
}
|
|
241
|
-
}),
|
|
414
|
+
}), ot = { class: "reevit-form-group" }, st = ["disabled"], at = { class: "reevit-network-selector" }, it = { class: "reevit-networks-grid" }, rt = ["onClick", "disabled"], lt = {
|
|
242
415
|
key: 0,
|
|
243
416
|
class: "reevit-error-message"
|
|
244
|
-
},
|
|
417
|
+
}, dt = { class: "reevit-momo-form__actions" }, ct = ["disabled"], ut = ["disabled"], pt = {
|
|
245
418
|
key: 0,
|
|
246
419
|
class: "reevit-spinner"
|
|
247
|
-
},
|
|
420
|
+
}, mt = { key: 1 }, de = /* @__PURE__ */ ee({
|
|
248
421
|
__name: "MobileMoneyForm",
|
|
249
422
|
props: {
|
|
250
423
|
initialPhone: {},
|
|
251
|
-
loading: { type: Boolean }
|
|
424
|
+
loading: { type: Boolean },
|
|
425
|
+
hideCancel: { type: Boolean }
|
|
252
426
|
},
|
|
253
|
-
emits: ["submit"],
|
|
254
|
-
setup(
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
|
|
427
|
+
emits: ["submit", "cancel"],
|
|
428
|
+
setup(e, { emit: t }) {
|
|
429
|
+
const n = e, d = t, i = V(n.initialPhone || ""), p = V(null), u = V(null);
|
|
430
|
+
j(i, (o) => {
|
|
431
|
+
const l = Me(o);
|
|
432
|
+
l && (p.value = l), u.value && (u.value = null);
|
|
259
433
|
});
|
|
260
|
-
const
|
|
261
|
-
if (!
|
|
262
|
-
|
|
434
|
+
const a = () => {
|
|
435
|
+
if (!le(i.value)) {
|
|
436
|
+
u.value = "Please enter a valid phone number";
|
|
263
437
|
return;
|
|
264
438
|
}
|
|
265
|
-
if (!
|
|
266
|
-
|
|
439
|
+
if (!p.value) {
|
|
440
|
+
u.value = "Please select your mobile network";
|
|
267
441
|
return;
|
|
268
442
|
}
|
|
269
|
-
|
|
270
|
-
phone:
|
|
271
|
-
network:
|
|
443
|
+
d("submit", {
|
|
444
|
+
phone: i.value,
|
|
445
|
+
network: p.value
|
|
272
446
|
});
|
|
273
|
-
},
|
|
447
|
+
}, h = [
|
|
274
448
|
{ id: "mtn", name: "MTN", color: "#FFCC00" },
|
|
275
449
|
{ id: "vodafone", name: "Vodafone", color: "#E60000" },
|
|
276
450
|
{ id: "airteltigo", name: "AirtelTigo", color: "#005596" }
|
|
277
451
|
];
|
|
278
|
-
return (
|
|
452
|
+
return (o, l) => (m(), v("form", {
|
|
279
453
|
class: "reevit-momo-form",
|
|
280
|
-
onSubmit:
|
|
454
|
+
onSubmit: ue(a, ["prevent"])
|
|
281
455
|
}, [
|
|
282
|
-
|
|
283
|
-
|
|
456
|
+
r("div", ot, [
|
|
457
|
+
l[2] || (l[2] = r("label", {
|
|
284
458
|
class: "reevit-label",
|
|
285
459
|
for: "reevit-phone"
|
|
286
460
|
}, "Phone Number", -1)),
|
|
287
|
-
|
|
461
|
+
ye(r("input", {
|
|
288
462
|
id: "reevit-phone",
|
|
289
|
-
"onUpdate:modelValue":
|
|
463
|
+
"onUpdate:modelValue": l[0] || (l[0] = (_) => i.value = _),
|
|
290
464
|
type: "tel",
|
|
291
|
-
class:
|
|
465
|
+
class: z(["reevit-input", { "reevit-input--error": u.value && !q(le)(i.value) }]),
|
|
292
466
|
placeholder: "e.g. 024 123 4567",
|
|
293
|
-
disabled:
|
|
467
|
+
disabled: e.loading,
|
|
294
468
|
autocomplete: "tel"
|
|
295
|
-
}, null, 10,
|
|
296
|
-
[
|
|
469
|
+
}, null, 10, st), [
|
|
470
|
+
[be, i.value]
|
|
297
471
|
])
|
|
298
472
|
]),
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
(
|
|
303
|
-
key:
|
|
473
|
+
r("div", at, [
|
|
474
|
+
l[3] || (l[3] = r("label", { class: "reevit-label" }, "Select Network", -1)),
|
|
475
|
+
r("div", it, [
|
|
476
|
+
(m(), v(Y, null, re(h, (_) => r("button", {
|
|
477
|
+
key: _.id,
|
|
304
478
|
type: "button",
|
|
305
|
-
class:
|
|
306
|
-
onClick: (
|
|
307
|
-
disabled:
|
|
479
|
+
class: z(q(me)("reevit-network-btn", p.value === _.id && "reevit-network-btn--selected")),
|
|
480
|
+
onClick: (T) => p.value = _.id,
|
|
481
|
+
disabled: e.loading
|
|
308
482
|
}, [
|
|
309
|
-
|
|
483
|
+
r("div", {
|
|
310
484
|
class: "reevit-network-dot",
|
|
311
|
-
style:
|
|
485
|
+
style: Z({ backgroundColor: _.color })
|
|
312
486
|
}, null, 4),
|
|
313
|
-
|
|
314
|
-
], 10,
|
|
487
|
+
pe(" " + I(_.name), 1)
|
|
488
|
+
], 10, rt)), 64))
|
|
315
489
|
])
|
|
316
490
|
]),
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
491
|
+
u.value ? (m(), v("p", lt, I(u.value), 1)) : L("", !0),
|
|
492
|
+
r("div", dt, [
|
|
493
|
+
e.hideCancel ? L("", !0) : (m(), v("button", {
|
|
494
|
+
key: 0,
|
|
495
|
+
type: "button",
|
|
496
|
+
class: "reevit-btn reevit-btn--secondary",
|
|
497
|
+
onClick: l[1] || (l[1] = (_) => d("cancel")),
|
|
498
|
+
disabled: e.loading
|
|
499
|
+
}, " Back ", 8, ct)),
|
|
500
|
+
r("button", {
|
|
501
|
+
type: "submit",
|
|
502
|
+
class: "reevit-btn reevit-btn--primary",
|
|
503
|
+
disabled: e.loading || !i.value
|
|
504
|
+
}, [
|
|
505
|
+
e.loading ? (m(), v("span", pt)) : (m(), v("span", mt, "Continue"))
|
|
506
|
+
], 8, ut)
|
|
507
|
+
]),
|
|
508
|
+
l[4] || (l[4] = r("p", { class: "reevit-secure-text" }, " 🔒 Secure mobile money payment via Reevit ", -1))
|
|
326
509
|
], 32));
|
|
327
510
|
}
|
|
328
511
|
});
|
|
329
|
-
class
|
|
330
|
-
constructor(
|
|
331
|
-
this.baseUrl = "https://unified-pay.hubtel.com", this.messageHandler = null, this.stylesInjected = !1,
|
|
512
|
+
class vt {
|
|
513
|
+
constructor(t) {
|
|
514
|
+
this.baseUrl = "https://unified-pay.hubtel.com", this.messageHandler = null, this.stylesInjected = !1, t && (this.baseUrl = t);
|
|
332
515
|
}
|
|
333
516
|
/**
|
|
334
517
|
* Redirects the user to the checkout page with the provided purchase information and configuration.
|
|
@@ -336,9 +519,9 @@ class Ke {
|
|
|
336
519
|
* @param config - The configuration.
|
|
337
520
|
* @throws {Error} If the popup is blocked by the browser.
|
|
338
521
|
*/
|
|
339
|
-
redirect({ purchaseInfo:
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
522
|
+
redirect({ purchaseInfo: t, config: n }) {
|
|
523
|
+
const d = this.createCheckoutUrl(t, n), i = window.open(d);
|
|
524
|
+
if (!i || i.closed || typeof i.closed > "u")
|
|
342
525
|
throw new Error("Popup was blocked by the browser. Please allow popups for this site.");
|
|
343
526
|
}
|
|
344
527
|
/**
|
|
@@ -350,30 +533,30 @@ class Ke {
|
|
|
350
533
|
* @param iframeStyle - The style options for the iframe (optional).
|
|
351
534
|
* @throws {Error} If the container element with id "hubtel-checkout-iframe" is not found.
|
|
352
535
|
*/
|
|
353
|
-
initIframe({ purchaseInfo:
|
|
354
|
-
var
|
|
355
|
-
this.registerEvents(
|
|
356
|
-
const
|
|
357
|
-
if (!
|
|
536
|
+
initIframe({ purchaseInfo: t, callBacks: n, config: d, iframeStyle: i }) {
|
|
537
|
+
var p, u, a;
|
|
538
|
+
this.registerEvents(n);
|
|
539
|
+
const h = document.getElementById("hubtel-checkout-iframe");
|
|
540
|
+
if (!h)
|
|
358
541
|
throw new Error('Container element with id "hubtel-checkout-iframe" not found in the DOM.');
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
var
|
|
365
|
-
|
|
366
|
-
},
|
|
542
|
+
h.innerHTML = "";
|
|
543
|
+
const o = document.createElement("div");
|
|
544
|
+
o.textContent = "Loading...", h.appendChild(o);
|
|
545
|
+
const l = document.createElement("iframe");
|
|
546
|
+
l.setAttribute("id", "hubtel-iframe-element"), l.src = this.createCheckoutUrl(t, d), l.style.display = "none", l.style.width = (p = i?.width) !== null && p !== void 0 ? p : "100%", l.style.height = (u = i?.height) !== null && u !== void 0 ? u : "100%", l.style.minHeight = i?.minHeight || "400px", l.style.border = (a = i?.border) !== null && a !== void 0 ? a : "none", l.onload = () => {
|
|
547
|
+
var _;
|
|
548
|
+
h.removeChild(o), l.style.display = "block", (_ = n.onLoad) === null || _ === void 0 || _.call(n);
|
|
549
|
+
}, h.appendChild(l);
|
|
367
550
|
}
|
|
368
|
-
openModal({ purchaseInfo:
|
|
369
|
-
this.injectStyles(), this.createIframe(), this.handleBackButton(), this.registerEvents(
|
|
551
|
+
openModal({ purchaseInfo: t, callBacks: n, config: d }) {
|
|
552
|
+
this.injectStyles(), this.createIframe(), this.handleBackButton(), this.registerEvents(n), this.renderWebpageInPopup(this.createCheckoutUrl(t, d), n.onClose, n.onLoad);
|
|
370
553
|
}
|
|
371
|
-
createCheckoutUrl(
|
|
372
|
-
const
|
|
373
|
-
return `${
|
|
554
|
+
createCheckoutUrl(t, n) {
|
|
555
|
+
const d = Object.assign(Object.assign({}, t), n), i = Object.keys(d).reduce((o, l) => (d[l] !== null && d[l] !== void 0 && (o[l] = d[l]), o), {}), p = Object.keys(i).map((o) => `${o}=${encodeURIComponent(i[o])}`).join("&"), u = this.encodeBase64(p), a = encodeURIComponent(u);
|
|
556
|
+
return `${i?.branding === "disabled" ? `${this.baseUrl}/pay/direct` : `${this.baseUrl}/pay`}?p=${a}`;
|
|
374
557
|
}
|
|
375
|
-
encodeBase64(
|
|
376
|
-
return btoa(unescape(encodeURIComponent(
|
|
558
|
+
encodeBase64(t) {
|
|
559
|
+
return btoa(unescape(encodeURIComponent(t)));
|
|
377
560
|
}
|
|
378
561
|
handleBackButton() {
|
|
379
562
|
window.addEventListener("popstate", () => {
|
|
@@ -381,32 +564,32 @@ class Ke {
|
|
|
381
564
|
});
|
|
382
565
|
}
|
|
383
566
|
createIframe() {
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
567
|
+
const t = document.createElement("div");
|
|
568
|
+
t.setAttribute("id", "backdrop"), t.classList.add("backdrop");
|
|
569
|
+
const n = document.createElement("span");
|
|
570
|
+
n.classList.add("checkout-loader"), t.appendChild(n), document.body.appendChild(t);
|
|
388
571
|
}
|
|
389
|
-
registerEvents(
|
|
572
|
+
registerEvents(t) {
|
|
390
573
|
this.messageHandler && window.removeEventListener("message", this.messageHandler, !1);
|
|
391
|
-
const
|
|
392
|
-
var
|
|
393
|
-
if (
|
|
574
|
+
const n = (d) => {
|
|
575
|
+
var i, p, u, a, h, o;
|
|
576
|
+
if (d.origin !== this.baseUrl)
|
|
394
577
|
return;
|
|
395
|
-
const { data:
|
|
396
|
-
if (
|
|
397
|
-
(
|
|
398
|
-
else if (
|
|
399
|
-
(
|
|
400
|
-
else if (
|
|
401
|
-
(
|
|
402
|
-
else if (
|
|
403
|
-
(
|
|
404
|
-
else if (
|
|
405
|
-
const
|
|
406
|
-
|
|
578
|
+
const { data: l } = d;
|
|
579
|
+
if (l.success === !0)
|
|
580
|
+
(i = t.onPaymentSuccess) === null || i === void 0 || i.call(t, l);
|
|
581
|
+
else if (l.success === !1)
|
|
582
|
+
(p = t.onPaymentFailure) === null || p === void 0 || p.call(t, l);
|
|
583
|
+
else if (l.initialized)
|
|
584
|
+
(u = t.init) === null || u === void 0 || u.call(t, l), (a = t.onInit) === null || a === void 0 || a.call(t, l);
|
|
585
|
+
else if (l.feesChanged)
|
|
586
|
+
(h = t.onFeesChanged) === null || h === void 0 || h.call(t, l.fees);
|
|
587
|
+
else if (l.resize) {
|
|
588
|
+
const _ = document.getElementById("hubtel-iframe-element");
|
|
589
|
+
_ && (_.style.height = l.height + "px"), (o = t?.onResize) === null || o === void 0 || o.call(t, l);
|
|
407
590
|
}
|
|
408
591
|
};
|
|
409
|
-
this.messageHandler =
|
|
592
|
+
this.messageHandler = n, window.addEventListener("message", n, !1);
|
|
410
593
|
}
|
|
411
594
|
/**
|
|
412
595
|
* Removes the message event listener to prevent memory leaks.
|
|
@@ -415,27 +598,27 @@ class Ke {
|
|
|
415
598
|
destroy() {
|
|
416
599
|
this.messageHandler && (window.removeEventListener("message", this.messageHandler, !1), this.messageHandler = null);
|
|
417
600
|
}
|
|
418
|
-
renderWebpageInPopup(
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
this.closePopUp(),
|
|
424
|
-
}),
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
601
|
+
renderWebpageInPopup(t, n, d) {
|
|
602
|
+
const i = document.createElement("div");
|
|
603
|
+
i.classList.add("checkout-modal");
|
|
604
|
+
const p = document.createElement("div");
|
|
605
|
+
p.setAttribute("id", "checkout-close-icon"), p.innerHTML = "×", p.classList.add("close-icon"), p.addEventListener("click", () => {
|
|
606
|
+
this.closePopUp(), n?.();
|
|
607
|
+
}), i.appendChild(p);
|
|
608
|
+
const u = document.createElement("iframe");
|
|
609
|
+
u.src = t, history.pushState({ modalOpen: !0 }, ""), u.classList.add("iframe"), i.appendChild(u), document.body.appendChild(i), i.style.opacity = "0", u.addEventListener("load", () => {
|
|
610
|
+
i.style.opacity = "1", d?.();
|
|
428
611
|
});
|
|
429
612
|
}
|
|
430
613
|
closePopUp() {
|
|
431
|
-
const
|
|
432
|
-
|
|
614
|
+
const t = document.querySelector(".backdrop"), n = document.querySelector(".checkout-modal");
|
|
615
|
+
t && document.body.removeChild(t), n && document.body.removeChild(n), history.replaceState(null, ""), window.removeEventListener("popstate", this.closePopUp);
|
|
433
616
|
}
|
|
434
617
|
injectStyles() {
|
|
435
618
|
if (this.stylesInjected)
|
|
436
619
|
return;
|
|
437
|
-
const
|
|
438
|
-
|
|
620
|
+
const t = document.createElement("style");
|
|
621
|
+
t.type = "text/css", t.setAttribute("data-hubtel-checkout", "true"), t.innerHTML = `
|
|
439
622
|
.backdrop {
|
|
440
623
|
position: fixed;
|
|
441
624
|
left: 0;
|
|
@@ -535,186 +718,197 @@ class Ke {
|
|
|
535
718
|
|
|
536
719
|
}
|
|
537
720
|
}
|
|
538
|
-
`, document.head.appendChild(
|
|
721
|
+
`, document.head.appendChild(t), this.stylesInjected = !0;
|
|
539
722
|
}
|
|
540
723
|
}
|
|
541
|
-
const
|
|
542
|
-
function
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
546
|
-
if (document.getElementById(
|
|
547
|
-
|
|
724
|
+
const ce = /* @__PURE__ */ new Map();
|
|
725
|
+
function te(e, t) {
|
|
726
|
+
const n = ce.get(t);
|
|
727
|
+
if (n) return n;
|
|
728
|
+
const d = new Promise((i, p) => {
|
|
729
|
+
if (document.getElementById(t)) {
|
|
730
|
+
i();
|
|
548
731
|
return;
|
|
549
732
|
}
|
|
550
|
-
const
|
|
551
|
-
|
|
733
|
+
const u = document.createElement("script");
|
|
734
|
+
u.id = t, u.src = e, u.async = !0, u.onload = () => i(), u.onerror = () => p(new Error(`Failed to load ${t} script`)), document.head.appendChild(u);
|
|
552
735
|
});
|
|
553
|
-
return
|
|
736
|
+
return ce.set(t, d), d;
|
|
554
737
|
}
|
|
555
|
-
function
|
|
556
|
-
return
|
|
738
|
+
function ht() {
|
|
739
|
+
return te("https://js.paystack.co/v1/inline.js", "paystack-script");
|
|
557
740
|
}
|
|
558
|
-
function
|
|
741
|
+
function Gt() {
|
|
559
742
|
return Promise.resolve();
|
|
560
743
|
}
|
|
561
|
-
function
|
|
562
|
-
return
|
|
744
|
+
function yt() {
|
|
745
|
+
return te("https://checkout.flutterwave.com/v3.js", "flutterwave-script");
|
|
563
746
|
}
|
|
564
|
-
function
|
|
565
|
-
return
|
|
747
|
+
function bt() {
|
|
748
|
+
return te("https://js.stripe.com/v3/", "stripe-script");
|
|
566
749
|
}
|
|
567
|
-
function
|
|
568
|
-
return
|
|
750
|
+
function ft() {
|
|
751
|
+
return te("https://sdk.monnify.com/plugin/monnify.js", "monnify-script");
|
|
569
752
|
}
|
|
570
|
-
async function
|
|
571
|
-
if (await
|
|
753
|
+
async function _t(e) {
|
|
754
|
+
if (await ht(), !window.PaystackPop)
|
|
572
755
|
throw new Error("Paystack script not loaded");
|
|
573
756
|
window.PaystackPop.setup({
|
|
574
|
-
key:
|
|
575
|
-
email:
|
|
576
|
-
amount:
|
|
577
|
-
currency:
|
|
578
|
-
ref:
|
|
579
|
-
metadata:
|
|
580
|
-
callback:
|
|
581
|
-
onClose:
|
|
757
|
+
key: e.key,
|
|
758
|
+
email: e.email,
|
|
759
|
+
amount: e.amount,
|
|
760
|
+
currency: e.currency,
|
|
761
|
+
ref: e.ref,
|
|
762
|
+
metadata: e.metadata,
|
|
763
|
+
callback: e.onSuccess,
|
|
764
|
+
onClose: e.onClose
|
|
582
765
|
}).openIframe();
|
|
583
766
|
}
|
|
584
|
-
async function
|
|
585
|
-
const
|
|
586
|
-
amount:
|
|
587
|
-
purchaseDescription:
|
|
588
|
-
customerPhoneNumber:
|
|
589
|
-
clientReference: `hubtel_${Date.now()}
|
|
590
|
-
|
|
767
|
+
async function kt(e) {
|
|
768
|
+
const t = new vt(), n = e.preferredMethod === "mobile_money" ? "momo" : e.preferredMethod === "card" ? "card" : void 0, d = {
|
|
769
|
+
amount: e.amount,
|
|
770
|
+
purchaseDescription: e.purchaseDescription,
|
|
771
|
+
customerPhoneNumber: e.customerPhone || "",
|
|
772
|
+
clientReference: `hubtel_${Date.now()}`,
|
|
773
|
+
...n ? { paymentMethod: n } : {}
|
|
774
|
+
}, i = e.hubtelSessionToken || e.basicAuth || "", p = {
|
|
591
775
|
branding: "enabled",
|
|
592
|
-
callbackUrl:
|
|
593
|
-
merchantAccount: typeof
|
|
594
|
-
basicAuth:
|
|
776
|
+
callbackUrl: e.callbackUrl || (typeof window < "u" ? window.location.href : ""),
|
|
777
|
+
merchantAccount: typeof e.clientId == "string" ? parseInt(e.clientId, 10) : e.clientId,
|
|
778
|
+
basicAuth: i,
|
|
779
|
+
...n ? { paymentMethod: n } : {}
|
|
595
780
|
};
|
|
596
|
-
|
|
597
|
-
purchaseInfo:
|
|
598
|
-
config:
|
|
781
|
+
t.openModal({
|
|
782
|
+
purchaseInfo: d,
|
|
783
|
+
config: p,
|
|
599
784
|
callBacks: {
|
|
600
|
-
onPaymentSuccess: (
|
|
601
|
-
|
|
785
|
+
onPaymentSuccess: (u) => {
|
|
786
|
+
e.onSuccess(u), t.closePopUp();
|
|
602
787
|
},
|
|
603
788
|
onPaymentFailure: () => {
|
|
604
|
-
|
|
789
|
+
e.onClose();
|
|
605
790
|
},
|
|
606
791
|
onClose: () => {
|
|
607
|
-
|
|
792
|
+
e.onClose();
|
|
608
793
|
}
|
|
609
794
|
}
|
|
610
795
|
});
|
|
611
796
|
}
|
|
612
|
-
async function
|
|
613
|
-
if (await
|
|
797
|
+
async function wt(e) {
|
|
798
|
+
if (await yt(), !window.FlutterwaveCheckout)
|
|
614
799
|
throw new Error("Flutterwave script not loaded");
|
|
615
800
|
window.FlutterwaveCheckout({
|
|
616
|
-
public_key:
|
|
617
|
-
tx_ref:
|
|
618
|
-
amount:
|
|
619
|
-
currency:
|
|
620
|
-
customer:
|
|
621
|
-
payment_options:
|
|
622
|
-
customizations:
|
|
623
|
-
callback:
|
|
624
|
-
onclose:
|
|
801
|
+
public_key: e.public_key,
|
|
802
|
+
tx_ref: e.tx_ref,
|
|
803
|
+
amount: e.amount,
|
|
804
|
+
currency: e.currency,
|
|
805
|
+
customer: e.customer,
|
|
806
|
+
payment_options: e.payment_options,
|
|
807
|
+
customizations: e.customizations,
|
|
808
|
+
callback: e.callback,
|
|
809
|
+
onclose: e.onclose
|
|
625
810
|
});
|
|
626
811
|
}
|
|
627
|
-
async function
|
|
628
|
-
if (await
|
|
812
|
+
async function Pt(e) {
|
|
813
|
+
if (await bt(), !window.Stripe)
|
|
629
814
|
throw new Error("Stripe.js not loaded");
|
|
630
|
-
return window.Stripe(
|
|
815
|
+
return window.Stripe(e);
|
|
631
816
|
}
|
|
632
|
-
async function
|
|
633
|
-
const
|
|
634
|
-
elements:
|
|
635
|
-
clientSecret:
|
|
817
|
+
async function Jt(e) {
|
|
818
|
+
const n = await (await Pt(e.publishableKey)).confirmPayment({
|
|
819
|
+
elements: e.elements,
|
|
820
|
+
clientSecret: e.clientSecret,
|
|
636
821
|
redirect: "if_required"
|
|
637
822
|
});
|
|
638
|
-
|
|
639
|
-
paymentIntentId:
|
|
640
|
-
status:
|
|
823
|
+
n.error ? e.onError({ message: n.error.message || "Payment failed" }) : n.paymentIntent && e.onSuccess({
|
|
824
|
+
paymentIntentId: n.paymentIntent.id,
|
|
825
|
+
status: n.paymentIntent.status
|
|
641
826
|
});
|
|
642
827
|
}
|
|
643
|
-
async function
|
|
644
|
-
if (await
|
|
828
|
+
async function gt(e) {
|
|
829
|
+
if (await ft(), !window.MonnifySDK)
|
|
645
830
|
throw new Error("Monnify SDK not loaded");
|
|
646
831
|
window.MonnifySDK.initialize({
|
|
647
|
-
amount:
|
|
648
|
-
currency:
|
|
649
|
-
reference:
|
|
650
|
-
customerName:
|
|
651
|
-
customerEmail:
|
|
652
|
-
customerMobileNumber:
|
|
653
|
-
apiKey:
|
|
654
|
-
contractCode:
|
|
655
|
-
paymentDescription:
|
|
656
|
-
isTestMode:
|
|
657
|
-
metadata:
|
|
658
|
-
onComplete: (
|
|
659
|
-
|
|
660
|
-
transactionReference:
|
|
661
|
-
paymentReference:
|
|
662
|
-
...
|
|
663
|
-
}) :
|
|
832
|
+
amount: e.amount,
|
|
833
|
+
currency: e.currency,
|
|
834
|
+
reference: e.reference,
|
|
835
|
+
customerName: e.customerName,
|
|
836
|
+
customerEmail: e.customerEmail,
|
|
837
|
+
customerMobileNumber: e.customerPhone,
|
|
838
|
+
apiKey: e.apiKey,
|
|
839
|
+
contractCode: e.contractCode,
|
|
840
|
+
paymentDescription: e.paymentDescription || "Payment",
|
|
841
|
+
isTestMode: e.isTestMode ?? !1,
|
|
842
|
+
metadata: e.metadata,
|
|
843
|
+
onComplete: (t) => {
|
|
844
|
+
t.status === "SUCCESS" ? e.onSuccess({
|
|
845
|
+
transactionReference: t.transactionReference,
|
|
846
|
+
paymentReference: t.paymentReference,
|
|
847
|
+
...t
|
|
848
|
+
}) : e.onError?.({ message: t.message || "Payment failed" });
|
|
664
849
|
},
|
|
665
|
-
onClose:
|
|
850
|
+
onClose: e.onClose
|
|
666
851
|
});
|
|
667
852
|
}
|
|
668
|
-
async function
|
|
669
|
-
|
|
853
|
+
async function Ct(e, t) {
|
|
854
|
+
e.onInitiated();
|
|
670
855
|
try {
|
|
671
|
-
const
|
|
856
|
+
const n = await fetch(t, {
|
|
672
857
|
method: "POST",
|
|
673
858
|
headers: { "Content-Type": "application/json" },
|
|
674
859
|
body: JSON.stringify({
|
|
675
|
-
phone_number:
|
|
676
|
-
amount:
|
|
677
|
-
reference:
|
|
678
|
-
description:
|
|
860
|
+
phone_number: e.phoneNumber,
|
|
861
|
+
amount: e.amount,
|
|
862
|
+
reference: e.reference,
|
|
863
|
+
description: e.description
|
|
679
864
|
})
|
|
680
865
|
});
|
|
681
|
-
if (!
|
|
682
|
-
const
|
|
683
|
-
return
|
|
866
|
+
if (!n.ok) {
|
|
867
|
+
const p = (await n.json().catch(() => ({}))).message || "Failed to initiate M-Pesa payment";
|
|
868
|
+
return e.onError({ message: p }), { status: "failed", message: p };
|
|
684
869
|
}
|
|
685
|
-
const
|
|
870
|
+
const d = await n.json();
|
|
686
871
|
return {
|
|
687
872
|
status: "initiated",
|
|
688
873
|
message: "Please check your phone and enter your M-Pesa PIN to complete the payment.",
|
|
689
|
-
transactionId:
|
|
874
|
+
transactionId: d.checkout_request_id || d.transaction_id
|
|
690
875
|
};
|
|
691
|
-
} catch (
|
|
692
|
-
const
|
|
693
|
-
return
|
|
876
|
+
} catch (n) {
|
|
877
|
+
const d = n instanceof Error ? n.message : "Network error";
|
|
878
|
+
return e.onError({ message: d }), { status: "failed", message: d };
|
|
694
879
|
}
|
|
695
880
|
}
|
|
696
|
-
const
|
|
881
|
+
const St = ["disabled"], Mt = {
|
|
697
882
|
key: 0,
|
|
698
883
|
class: "reevit-spinner"
|
|
699
|
-
},
|
|
884
|
+
}, It = { class: "reevit-modal-header" }, Et = ["src"], Rt = { class: "reevit-modal-body" }, $t = {
|
|
700
885
|
key: 0,
|
|
701
886
|
class: "reevit-loading-state"
|
|
702
|
-
},
|
|
887
|
+
}, xt = {
|
|
703
888
|
key: 1,
|
|
704
889
|
class: "reevit-error-state"
|
|
705
|
-
},
|
|
890
|
+
}, Lt = {
|
|
706
891
|
key: 2,
|
|
707
892
|
class: "reevit-success-state"
|
|
708
|
-
},
|
|
893
|
+
}, Tt = {
|
|
894
|
+
key: 3,
|
|
895
|
+
class: "reevit-method-step reevit-animate-slide-up"
|
|
896
|
+
}, Nt = {
|
|
897
|
+
key: 0,
|
|
898
|
+
class: "reevit-inline-action reevit-animate-fade-in"
|
|
899
|
+
}, Ut = ["disabled"], Ot = {
|
|
709
900
|
key: 1,
|
|
710
|
-
class: "reevit-
|
|
711
|
-
},
|
|
712
|
-
key:
|
|
713
|
-
class: "reevit-
|
|
714
|
-
},
|
|
901
|
+
class: "reevit-inline-action reevit-animate-fade-in"
|
|
902
|
+
}, Ft = { class: "reevit-inline-action__hint" }, At = ["disabled"], Dt = {
|
|
903
|
+
key: 0,
|
|
904
|
+
class: "reevit-method-step__actions reevit-animate-slide-up"
|
|
905
|
+
}, Kt = { key: 0 }, jt = {
|
|
906
|
+
key: 1,
|
|
907
|
+
class: "reevit-card-info reevit-animate-fade-in"
|
|
908
|
+
}, zt = { class: "reevit-info-text" }, Ht = ["disabled"], Bt = {
|
|
715
909
|
key: 0,
|
|
716
910
|
class: "reevit-spinner"
|
|
717
|
-
},
|
|
911
|
+
}, Vt = { key: 1 }, Wt = /* @__PURE__ */ ee({
|
|
718
912
|
__name: "ReevitCheckout",
|
|
719
913
|
props: {
|
|
720
914
|
publicKey: {},
|
|
@@ -722,8 +916,11 @@ const Qe = ["disabled"], Xe = {
|
|
|
722
916
|
currency: {},
|
|
723
917
|
email: {},
|
|
724
918
|
phone: {},
|
|
919
|
+
customerName: {},
|
|
725
920
|
reference: {},
|
|
726
921
|
metadata: {},
|
|
922
|
+
customFields: {},
|
|
923
|
+
paymentLinkCode: {},
|
|
727
924
|
paymentMethods: {},
|
|
728
925
|
theme: {},
|
|
729
926
|
isOpen: { type: Boolean },
|
|
@@ -731,263 +928,389 @@ const Qe = ["disabled"], Xe = {
|
|
|
731
928
|
initialPaymentIntent: {}
|
|
732
929
|
},
|
|
733
930
|
emits: ["success", "error", "close"],
|
|
734
|
-
setup(
|
|
735
|
-
const
|
|
736
|
-
status:
|
|
737
|
-
paymentIntent:
|
|
738
|
-
selectedMethod:
|
|
739
|
-
error:
|
|
740
|
-
isLoading:
|
|
741
|
-
isReady:
|
|
742
|
-
initialize:
|
|
743
|
-
selectMethod:
|
|
744
|
-
handlePspSuccess:
|
|
745
|
-
handlePspError:
|
|
746
|
-
close:
|
|
747
|
-
|
|
931
|
+
setup(e, { emit: t }) {
|
|
932
|
+
const n = e, d = t, {
|
|
933
|
+
status: i,
|
|
934
|
+
paymentIntent: p,
|
|
935
|
+
selectedMethod: u,
|
|
936
|
+
error: a,
|
|
937
|
+
isLoading: h,
|
|
938
|
+
isReady: o,
|
|
939
|
+
initialize: l,
|
|
940
|
+
selectMethod: _,
|
|
941
|
+
handlePspSuccess: T,
|
|
942
|
+
handlePspError: U,
|
|
943
|
+
close: ne,
|
|
944
|
+
reset: W
|
|
945
|
+
} = Ue({
|
|
748
946
|
config: {
|
|
749
|
-
publicKey:
|
|
750
|
-
amount:
|
|
751
|
-
currency:
|
|
752
|
-
email:
|
|
753
|
-
phone:
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
947
|
+
publicKey: n.publicKey,
|
|
948
|
+
amount: n.amount,
|
|
949
|
+
currency: n.currency,
|
|
950
|
+
email: n.email,
|
|
951
|
+
phone: n.phone,
|
|
952
|
+
customerName: n.customerName,
|
|
953
|
+
reference: n.reference,
|
|
954
|
+
metadata: n.metadata,
|
|
955
|
+
customFields: n.customFields,
|
|
956
|
+
paymentLinkCode: n.paymentLinkCode,
|
|
957
|
+
paymentMethods: n.paymentMethods,
|
|
958
|
+
initialPaymentIntent: n.initialPaymentIntent
|
|
758
959
|
},
|
|
759
|
-
apiBaseUrl:
|
|
760
|
-
onSuccess: (
|
|
761
|
-
onError: (
|
|
762
|
-
onClose: () =>
|
|
763
|
-
}),
|
|
764
|
-
|
|
765
|
-
|
|
960
|
+
apiBaseUrl: n.apiBaseUrl,
|
|
961
|
+
onSuccess: (c) => d("success", c),
|
|
962
|
+
onError: (c) => d("error", c),
|
|
963
|
+
onClose: () => d("close")
|
|
964
|
+
}), O = V(n.isOpen ?? !1), M = V(null), G = {
|
|
965
|
+
hubtel: "Hubtel",
|
|
966
|
+
paystack: "Paystack",
|
|
967
|
+
flutterwave: "Flutterwave",
|
|
968
|
+
monnify: "Monnify",
|
|
969
|
+
mpesa: "M-Pesa",
|
|
970
|
+
stripe: "Stripe"
|
|
971
|
+
};
|
|
972
|
+
j(() => n.isOpen, (c) => {
|
|
973
|
+
c !== void 0 && (O.value = c);
|
|
766
974
|
});
|
|
767
|
-
const
|
|
768
|
-
|
|
975
|
+
const Q = () => {
|
|
976
|
+
O.value = !0, M.value = null, !p.value && i.value === "idle" && l();
|
|
769
977
|
};
|
|
770
|
-
|
|
771
|
-
|
|
978
|
+
j([O, p, u], ([c, s, k]) => {
|
|
979
|
+
if (c && s && k) {
|
|
980
|
+
const y = (M.value || s.recommendedPsp || "paystack").toLowerCase().includes("mpesa");
|
|
981
|
+
(k === "card" || k === "mobile_money" && (!y || n.phone)) && w(null);
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
const J = () => {
|
|
985
|
+
O.value = !1, ne(), M.value = null;
|
|
986
|
+
}, F = f(
|
|
987
|
+
() => n.paymentMethods?.length ? n.paymentMethods : ["card", "mobile_money"]
|
|
988
|
+
), A = f(() => {
|
|
989
|
+
const c = p.value;
|
|
990
|
+
if (!c) return [];
|
|
991
|
+
const s = new Set(F.value), k = (c.availableProviders || []).map((y) => {
|
|
992
|
+
const K = y.provider.toLowerCase().includes("hubtel") ? y.methods.filter((B) => B === "card" || B === "mobile_money") : y.methods;
|
|
993
|
+
return {
|
|
994
|
+
...y,
|
|
995
|
+
methods: K.filter((B) => s.has(B))
|
|
996
|
+
};
|
|
997
|
+
}).filter((y) => y.methods.length > 0);
|
|
998
|
+
if (k.length > 0)
|
|
999
|
+
return k;
|
|
1000
|
+
const P = c.recommendedPsp.toLowerCase().includes("hubtel") ? F.value.filter((y) => y === "card" || y === "mobile_money") : F.value;
|
|
1001
|
+
return [
|
|
1002
|
+
{
|
|
1003
|
+
provider: c.recommendedPsp,
|
|
1004
|
+
name: G[c.recommendedPsp] || c.recommendedPsp,
|
|
1005
|
+
methods: P
|
|
1006
|
+
}
|
|
1007
|
+
];
|
|
1008
|
+
}), S = f(() => {
|
|
1009
|
+
const c = p.value;
|
|
1010
|
+
return M.value || c?.recommendedPsp || "paystack";
|
|
1011
|
+
}), X = f(() => {
|
|
1012
|
+
const c = A.value.find(
|
|
1013
|
+
(s) => s.provider === S.value
|
|
1014
|
+
);
|
|
1015
|
+
return c?.methods.length ? c.methods : F.value;
|
|
772
1016
|
});
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
1017
|
+
j(
|
|
1018
|
+
() => A.value,
|
|
1019
|
+
(c) => {
|
|
1020
|
+
c.length && (M.value && c.some((s) => s.provider === M.value) || (c.length === 1 ? M.value = c[0].provider : M.value = null));
|
|
1021
|
+
},
|
|
1022
|
+
{ immediate: !0 }
|
|
1023
|
+
), j([X, u], ([c, s]) => {
|
|
1024
|
+
!s || c.length === 0 || c.includes(s) || _(c[0]);
|
|
1025
|
+
});
|
|
1026
|
+
const oe = (c) => {
|
|
1027
|
+
if (c === M.value) {
|
|
1028
|
+
M.value = null, W();
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
const s = A.value.find((y) => y.provider === c), k = s?.methods.length ? s.methods : F.value, P = u.value && k.includes(u.value) ? u.value : k[0];
|
|
1032
|
+
M.value = c, W(), l(P, { preferredProvider: c, allowedProviders: [c] });
|
|
1033
|
+
}, b = (c) => {
|
|
1034
|
+
_(c);
|
|
1035
|
+
}, w = async (c) => {
|
|
1036
|
+
const s = p.value;
|
|
1037
|
+
if (!s) return;
|
|
1038
|
+
const k = S.value;
|
|
781
1039
|
try {
|
|
782
|
-
if (
|
|
783
|
-
await
|
|
784
|
-
key:
|
|
785
|
-
email:
|
|
786
|
-
amount:
|
|
787
|
-
currency:
|
|
788
|
-
ref:
|
|
789
|
-
onSuccess: (
|
|
1040
|
+
if (k === "paystack")
|
|
1041
|
+
await _t({
|
|
1042
|
+
key: s.pspPublicKey || n.publicKey || "",
|
|
1043
|
+
email: n.email || "",
|
|
1044
|
+
amount: n.amount,
|
|
1045
|
+
currency: n.currency,
|
|
1046
|
+
ref: s.id,
|
|
1047
|
+
onSuccess: (P) => T(P),
|
|
790
1048
|
onClose: () => {
|
|
791
1049
|
}
|
|
792
1050
|
});
|
|
793
|
-
else if (
|
|
794
|
-
await
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
1051
|
+
else if (k === "hubtel") {
|
|
1052
|
+
const P = Ie({ publicKey: n.publicKey, baseUrl: n.apiBaseUrl }), { data: y, error: K } = await P.createHubtelSession(
|
|
1053
|
+
s.id,
|
|
1054
|
+
s.clientSecret
|
|
1055
|
+
);
|
|
1056
|
+
if (K || !y?.basicAuth) {
|
|
1057
|
+
U({
|
|
1058
|
+
code: K?.code || "hubtel_session_error",
|
|
1059
|
+
message: K?.message || "Failed to create Hubtel session"
|
|
1060
|
+
});
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
const B = C.value === "card" || C.value === "mobile_money" ? C.value : void 0;
|
|
1064
|
+
await kt({
|
|
1065
|
+
clientId: y.merchantAccount || s.pspCredentials?.merchantAccount || n.publicKey || "",
|
|
1066
|
+
purchaseDescription: `Payment for ${n.amount} ${n.currency}`,
|
|
1067
|
+
amount: n.amount,
|
|
1068
|
+
customerPhone: c?.phone || n.phone,
|
|
1069
|
+
customerEmail: n.email,
|
|
1070
|
+
basicAuth: y.basicAuth,
|
|
1071
|
+
preferredMethod: B,
|
|
1072
|
+
onSuccess: (he) => T(he),
|
|
802
1073
|
onClose: () => {
|
|
803
1074
|
}
|
|
804
1075
|
});
|
|
805
|
-
else if (
|
|
806
|
-
await
|
|
807
|
-
public_key:
|
|
808
|
-
tx_ref:
|
|
809
|
-
amount:
|
|
810
|
-
currency:
|
|
1076
|
+
} else if (k === "flutterwave")
|
|
1077
|
+
await wt({
|
|
1078
|
+
public_key: s.pspPublicKey || n.publicKey || "",
|
|
1079
|
+
tx_ref: s.id,
|
|
1080
|
+
amount: n.amount,
|
|
1081
|
+
currency: n.currency,
|
|
811
1082
|
customer: {
|
|
812
|
-
email:
|
|
813
|
-
phone_number:
|
|
1083
|
+
email: n.email || "",
|
|
1084
|
+
phone_number: c?.phone || n.phone
|
|
814
1085
|
},
|
|
815
|
-
callback: (
|
|
1086
|
+
callback: (P) => T(P),
|
|
816
1087
|
onclose: () => {
|
|
817
1088
|
}
|
|
818
1089
|
});
|
|
819
|
-
else if (
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
1090
|
+
else if (k === "monnify") {
|
|
1091
|
+
const P = s.pspPublicKey || n.publicKey || "", y = n.metadata?.contract_code || n.publicKey || "";
|
|
1092
|
+
if (!P || !y) {
|
|
1093
|
+
U({
|
|
1094
|
+
code: "MONNIFY_CONFIG_MISSING",
|
|
1095
|
+
message: "Monnify configuration is missing. Please check your API key and contract code."
|
|
1096
|
+
});
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
await gt({
|
|
1100
|
+
apiKey: P,
|
|
1101
|
+
contractCode: y,
|
|
1102
|
+
amount: n.amount,
|
|
1103
|
+
currency: n.currency,
|
|
1104
|
+
reference: s.reference || s.id,
|
|
1105
|
+
customerName: n.metadata?.customer_name || n.email || "",
|
|
1106
|
+
customerEmail: n.email || "",
|
|
1107
|
+
customerPhone: c?.phone || n.phone,
|
|
1108
|
+
metadata: n.metadata,
|
|
1109
|
+
onSuccess: (K) => T(K),
|
|
831
1110
|
onClose: () => {
|
|
832
1111
|
}
|
|
833
1112
|
});
|
|
834
|
-
else if (
|
|
835
|
-
const
|
|
836
|
-
await
|
|
837
|
-
phoneNumber:
|
|
838
|
-
amount:
|
|
839
|
-
reference:
|
|
840
|
-
description: `Payment ${
|
|
1113
|
+
} else if (k === "mpesa") {
|
|
1114
|
+
const P = `${n.apiBaseUrl || "https://api.reevit.io"}/v1/payments/${s.id}/mpesa`;
|
|
1115
|
+
await Ct({
|
|
1116
|
+
phoneNumber: c?.phone || n.phone || "",
|
|
1117
|
+
amount: n.amount,
|
|
1118
|
+
reference: s.reference || s.id,
|
|
1119
|
+
description: `Payment ${s.reference || ""}`,
|
|
841
1120
|
onInitiated: () => {
|
|
842
1121
|
},
|
|
843
|
-
onSuccess: (
|
|
844
|
-
onError: (
|
|
845
|
-
},
|
|
846
|
-
} else
|
|
1122
|
+
onSuccess: (y) => T(y),
|
|
1123
|
+
onError: (y) => U({ code: "MPESA_ERROR", message: y.message })
|
|
1124
|
+
}, P);
|
|
1125
|
+
} else U(k === "stripe" ? {
|
|
847
1126
|
code: "STRIPE_NOT_IMPLEMENTED",
|
|
848
1127
|
message: "Stripe integration requires custom Elements setup. Please use the React SDK or implement custom Stripe Elements."
|
|
849
1128
|
} : {
|
|
850
1129
|
code: "UNSUPPORTED_PSP",
|
|
851
|
-
message: `Payment provider "${
|
|
1130
|
+
message: `Payment provider "${k}" is not supported in this checkout.`
|
|
852
1131
|
});
|
|
853
|
-
} catch (
|
|
854
|
-
|
|
1132
|
+
} catch (P) {
|
|
1133
|
+
U({
|
|
855
1134
|
code: "BRIDGE_ERROR",
|
|
856
|
-
message:
|
|
1135
|
+
message: P instanceof Error ? P.message : "Failed to open payment gateway"
|
|
857
1136
|
});
|
|
858
1137
|
}
|
|
859
|
-
},
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
}),
|
|
1138
|
+
}, g = f(() => ({
|
|
1139
|
+
...p.value?.branding || {},
|
|
1140
|
+
...n.theme || {}
|
|
1141
|
+
})), E = f(() => Ee(g.value)), $ = f(() => g.value?.darkMode);
|
|
1142
|
+
j(O, (c) => {
|
|
1143
|
+
c ? document.body.style.overflow = "hidden" : document.body.style.overflow = "";
|
|
1144
|
+
}), fe(() => {
|
|
863
1145
|
document.body.style.overflow = "";
|
|
864
1146
|
});
|
|
865
|
-
const
|
|
866
|
-
return (
|
|
1147
|
+
const R = f(() => i.value), D = f(() => a.value), C = f(() => u.value), H = f(() => h.value), x = f(() => o.value);
|
|
1148
|
+
return (c, s) => (m(), v("div", {
|
|
867
1149
|
class: "reevit-sdk-container",
|
|
868
|
-
style:
|
|
1150
|
+
style: Z(E.value)
|
|
869
1151
|
}, [
|
|
870
|
-
|
|
871
|
-
open:
|
|
872
|
-
isLoading:
|
|
1152
|
+
ae(c.$slots, "default", {
|
|
1153
|
+
open: Q,
|
|
1154
|
+
isLoading: H.value
|
|
873
1155
|
}, () => [
|
|
874
|
-
|
|
1156
|
+
r("button", {
|
|
875
1157
|
type: "button",
|
|
876
1158
|
class: "reevit-pay-button",
|
|
877
|
-
onClick:
|
|
878
|
-
disabled:
|
|
1159
|
+
onClick: Q,
|
|
1160
|
+
disabled: H.value
|
|
879
1161
|
}, [
|
|
880
|
-
|
|
881
|
-
|
|
1162
|
+
H.value ? (m(), v("span", Mt)) : ae(c.$slots, "button-text", { key: 1 }, () => [
|
|
1163
|
+
s[5] || (s[5] = pe("Pay Now", -1))
|
|
882
1164
|
])
|
|
883
|
-
], 8,
|
|
1165
|
+
], 8, St)
|
|
884
1166
|
]),
|
|
885
|
-
(
|
|
886
|
-
|
|
1167
|
+
(m(), se(_e, { to: "body" }, [
|
|
1168
|
+
O.value ? (m(), v("div", {
|
|
887
1169
|
key: 0,
|
|
888
1170
|
class: "reevit-modal-overlay",
|
|
889
|
-
onClick:
|
|
1171
|
+
onClick: ue(J, ["self"])
|
|
890
1172
|
}, [
|
|
891
|
-
|
|
892
|
-
class:
|
|
1173
|
+
r("div", {
|
|
1174
|
+
class: z(["reevit-modal-content", { "reevit-modal--dark": $.value }]),
|
|
1175
|
+
style: Z(E.value)
|
|
893
1176
|
}, [
|
|
894
|
-
|
|
1177
|
+
r("button", {
|
|
895
1178
|
class: "reevit-modal-close",
|
|
896
|
-
onClick:
|
|
1179
|
+
onClick: J,
|
|
897
1180
|
"aria-label": "Close"
|
|
898
1181
|
}, " × "),
|
|
899
|
-
r
|
|
900
|
-
|
|
901
|
-
src: "https://i.imgur.com/bzUR5Lm.png",
|
|
902
|
-
alt: "
|
|
1182
|
+
r("div", It, [
|
|
1183
|
+
r("img", {
|
|
1184
|
+
src: g.value.logoUrl || "https://i.imgur.com/bzUR5Lm.png",
|
|
1185
|
+
alt: "Checkout",
|
|
903
1186
|
class: "reevit-modal__logo"
|
|
904
|
-
})
|
|
905
|
-
]
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
])])) :
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1187
|
+
}, null, 8, Et)
|
|
1188
|
+
]),
|
|
1189
|
+
r("div", Rt, [
|
|
1190
|
+
R.value === "loading" ? (m(), v("div", $t, [...s[6] || (s[6] = [
|
|
1191
|
+
r("div", { class: "reevit-spinner reevit-spinner--large" }, null, -1),
|
|
1192
|
+
r("p", null, "Initializing payment...", -1)
|
|
1193
|
+
])])) : R.value === "failed" && D.value ? (m(), v("div", xt, [
|
|
1194
|
+
s[7] || (s[7] = r("div", { class: "reevit-error-icon" }, "⚠️", -1)),
|
|
1195
|
+
s[8] || (s[8] = r("h3", null, "Payment Failed", -1)),
|
|
1196
|
+
r("p", null, I(D.value.message), 1),
|
|
1197
|
+
r("button", {
|
|
915
1198
|
class: "reevit-retry-btn",
|
|
916
|
-
onClick:
|
|
1199
|
+
onClick: s[0] || (s[0] = (k) => q(l)())
|
|
917
1200
|
}, "Retry")
|
|
918
|
-
])) :
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1201
|
+
])) : R.value === "success" ? (m(), v("div", Lt, [
|
|
1202
|
+
s[9] || (s[9] = r("div", { class: "reevit-success-icon" }, "✅", -1)),
|
|
1203
|
+
s[10] || (s[10] = r("h3", null, "Payment Successful", -1)),
|
|
1204
|
+
s[11] || (s[11] = r("p", null, "Thank you for your payment.", -1)),
|
|
1205
|
+
r("button", {
|
|
923
1206
|
class: "reevit-done-btn",
|
|
924
|
-
onClick:
|
|
1207
|
+
onClick: J
|
|
925
1208
|
}, "Done")
|
|
926
|
-
])) :
|
|
927
|
-
|
|
1209
|
+
])) : x.value ? (m(), v("div", Tt, [
|
|
1210
|
+
A.value.length > 1 ? (m(), se(nt, {
|
|
928
1211
|
key: 0,
|
|
929
|
-
|
|
930
|
-
selected:
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
onSelect:
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
"
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
1212
|
+
providers: A.value,
|
|
1213
|
+
"selected-provider": M.value,
|
|
1214
|
+
disabled: H.value,
|
|
1215
|
+
theme: g.value,
|
|
1216
|
+
"selected-method": C.value,
|
|
1217
|
+
onSelect: oe,
|
|
1218
|
+
onMethodSelect: b
|
|
1219
|
+
}, {
|
|
1220
|
+
"method-content": ke(() => [
|
|
1221
|
+
C.value === "card" ? (m(), v("div", Nt, [
|
|
1222
|
+
s[12] || (s[12] = r("p", { class: "reevit-inline-action__hint" }, " You'll be redirected to complete your card payment securely. ", -1)),
|
|
1223
|
+
r("button", {
|
|
1224
|
+
class: "reevit-btn reevit-btn--primary",
|
|
1225
|
+
onClick: s[1] || (s[1] = (k) => w(null)),
|
|
1226
|
+
disabled: R.value === "processing"
|
|
1227
|
+
}, " Pay with Card ", 8, Ut)
|
|
1228
|
+
])) : C.value === "mobile_money" ? (m(), v("div", Ot, [
|
|
1229
|
+
S.value.includes("mpesa") && !n.phone ? (m(), se(de, {
|
|
1230
|
+
key: 0,
|
|
1231
|
+
"initial-phone": n.phone,
|
|
1232
|
+
loading: R.value === "processing",
|
|
1233
|
+
"hide-cancel": "",
|
|
1234
|
+
onSubmit: w
|
|
1235
|
+
}, null, 8, ["initial-phone", "loading"])) : (m(), v(Y, { key: 1 }, [
|
|
1236
|
+
r("p", Ft, I(S.value.includes("hubtel") ? "Opens the Hubtel checkout with Mobile Money selected." : `Continue to pay securely with Mobile Money via ${G[S.value] || S.value}.`), 1),
|
|
1237
|
+
r("button", {
|
|
1238
|
+
class: "reevit-btn reevit-btn--primary",
|
|
1239
|
+
onClick: s[2] || (s[2] = (k) => w(null)),
|
|
1240
|
+
disabled: R.value === "processing"
|
|
1241
|
+
}, I(S.value.includes("hubtel") ? "Continue with Hubtel" : "Pay with Mobile Money"), 9, At)
|
|
1242
|
+
], 64))
|
|
1243
|
+
])) : L("", !0)
|
|
1244
|
+
]),
|
|
1245
|
+
_: 1
|
|
1246
|
+
}, 8, ["providers", "selected-provider", "disabled", "theme", "selected-method"])) : (m(), v(Y, { key: 1 }, [
|
|
1247
|
+
ie(ve, {
|
|
1248
|
+
methods: X.value,
|
|
1249
|
+
selected: C.value,
|
|
1250
|
+
provider: S.value,
|
|
1251
|
+
"show-label": !1,
|
|
1252
|
+
layout: "grid",
|
|
1253
|
+
onSelect: b
|
|
1254
|
+
}, null, 8, ["methods", "selected", "provider"]),
|
|
1255
|
+
C.value ? (m(), v("div", Dt, [
|
|
1256
|
+
C.value === "mobile_money" && S.value.includes("mpesa") && !n.phone ? (m(), v("div", Kt, [
|
|
1257
|
+
ie(de, {
|
|
1258
|
+
"initial-phone": n.phone,
|
|
1259
|
+
loading: R.value === "processing",
|
|
1260
|
+
onSubmit: w,
|
|
1261
|
+
onCancel: s[3] || (s[3] = (k) => q(_)(null))
|
|
1262
|
+
}, null, 8, ["initial-phone", "loading"])
|
|
1263
|
+
])) : (m(), v("div", jt, [
|
|
1264
|
+
r("p", zt, I(C.value === "card" ? "You will be redirected to complete your card payment securely." : S.value.includes("hubtel") ? "Opens the Hubtel checkout with Mobile Money selected." : `Continue to pay securely via ${G[S.value] || S.value}.`), 1),
|
|
1265
|
+
r("button", {
|
|
1266
|
+
class: "reevit-submit-btn",
|
|
1267
|
+
onClick: s[4] || (s[4] = (k) => w(null)),
|
|
1268
|
+
disabled: R.value === "processing"
|
|
1269
|
+
}, [
|
|
1270
|
+
R.value === "processing" ? (m(), v("span", Bt)) : (m(), v("span", Vt, I(C.value === "card" ? "Pay with Card" : S.value.includes("hubtel") ? "Continue with Hubtel" : "Pay with Mobile Money"), 1))
|
|
1271
|
+
], 8, Ht)
|
|
1272
|
+
]))
|
|
1273
|
+
])) : L("", !0)
|
|
1274
|
+
], 64))
|
|
1275
|
+
])) : L("", !0)
|
|
954
1276
|
]),
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1277
|
+
s[13] || (s[13] = r("div", { class: "reevit-modal-footer" }, [
|
|
1278
|
+
r("div", { class: "reevit-trust-badges" }, [
|
|
1279
|
+
r("span", null, "PCI DSS Compliant"),
|
|
1280
|
+
r("span", null, "•"),
|
|
1281
|
+
r("span", null, "SSL Secure")
|
|
960
1282
|
])
|
|
961
1283
|
], -1))
|
|
962
|
-
],
|
|
963
|
-
])) :
|
|
1284
|
+
], 6)
|
|
1285
|
+
])) : L("", !0)
|
|
964
1286
|
]))
|
|
965
1287
|
], 4));
|
|
966
1288
|
}
|
|
967
1289
|
});
|
|
968
1290
|
export {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1291
|
+
de as MobileMoneyForm,
|
|
1292
|
+
ve as PaymentMethodSelector,
|
|
1293
|
+
nt as ProviderSelector,
|
|
1294
|
+
Zt as ReevitAPIClient,
|
|
1295
|
+
Wt as ReevitCheckout,
|
|
1296
|
+
en as cn,
|
|
1297
|
+
Jt as confirmStripePayment,
|
|
1298
|
+
tn as createReevitClient,
|
|
1299
|
+
Pt as createStripeInstance,
|
|
1300
|
+
nn as detectCountryFromCurrency,
|
|
1301
|
+
on as detectNetwork,
|
|
1302
|
+
sn as formatAmount,
|
|
1303
|
+
an as formatPhone,
|
|
1304
|
+
Ct as initiateMPesaSTKPush,
|
|
1305
|
+
yt as loadFlutterwaveScript,
|
|
1306
|
+
Gt as loadHubtelScript,
|
|
1307
|
+
ft as loadMonnifyScript,
|
|
1308
|
+
ht as loadPaystackScript,
|
|
1309
|
+
bt as loadStripeScript,
|
|
1310
|
+
wt as openFlutterwaveModal,
|
|
1311
|
+
kt as openHubtelPopup,
|
|
1312
|
+
gt as openMonnifyModal,
|
|
1313
|
+
_t as openPaystackPopup,
|
|
1314
|
+
Ue as useReevit,
|
|
1315
|
+
rn as validatePhone
|
|
993
1316
|
};
|