@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/index.mjs CHANGED
@@ -1,334 +1,517 @@
1
- import { ref as $, watch as N, computed as w, readonly as _, defineComponent as V, createElementBlock as h, openBlock as v, createElementVNode as c, toDisplayString as I, unref as L, Fragment as q, renderList as Q, normalizeClass as D, createCommentVNode as E, withModifiers as X, withDirectives as oe, vModelText as ae, createTextVNode as Z, normalizeStyle as ee, onUnmounted as re, renderSlot as Y, createBlock as W, Teleport as se, createVNode as ie } from "vue";
2
- import { createInitialState as le, ReevitAPIClient as ce, generateReference as de, detectCountryFromCurrency as ue, reevitReducer as me, formatAmount as pe, cn as te, detectNetwork as ye, validatePhone as G, createThemeVariables as ve } from "@reevit/core";
3
- import { ReevitAPIClient as vt, cn as ht, createReevitClient as ft, detectCountryFromCurrency as bt, detectNetwork as wt, formatAmount as kt, formatPhone as Pt, validatePhone as Ct } from "@reevit/core";
4
- function he(t) {
5
- const n = t.toLowerCase();
6
- return n.includes("paystack") ? "paystack" : n.includes("hubtel") ? "hubtel" : n.includes("flutterwave") ? "flutterwave" : n.includes("stripe") ? "stripe" : n.includes("monnify") ? "monnify" : n.includes("mpesa") || n.includes("m-pesa") ? "mpesa" : "paystack";
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 fe(t, n) {
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: t.id,
11
- clientSecret: t.client_secret,
12
- pspPublicKey: t.psp_public_key,
13
- pspCredentials: t.psp_credentials,
14
- amount: t.amount,
15
- currency: t.currency,
16
- status: t.status,
17
- recommendedPsp: he(t.provider),
18
- availableMethods: n.paymentMethods || ["card", "mobile_money"],
19
- reference: t.reference || n.reference,
20
- connectionId: t.connection_id,
21
- provider: t.provider,
22
- feeAmount: t.fee_amount,
23
- feeCurrency: t.fee_currency,
24
- netAmount: t.net_amount,
25
- metadata: n.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 be(t) {
29
- const { config: n, onSuccess: e, onError: i, onClose: o, onStateChange: m, apiBaseUrl: d } = t, s = $(le());
30
- if (n.initialPaymentIntent) {
31
- const l = n.initialPaymentIntent;
32
- s.value = {
33
- ...s.value,
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: l,
36
- selectedMethod: l.availableMethods?.length === 1 ? l.availableMethods[0] : null
65
+ paymentIntent: b,
66
+ selectedMethod: b.availableMethods?.length === 1 ? b.availableMethods[0] : null
37
67
  };
38
68
  }
39
- const p = new ce({
40
- publicKey: n.publicKey,
41
- baseUrl: d
42
- }), u = (l) => {
43
- s.value = me(s.value, l);
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
- N(
46
- () => s.value.status,
47
- (l) => {
48
- m?.(l);
75
+ j(
76
+ () => a.value.status,
77
+ (b) => {
78
+ p?.(b);
49
79
  }
50
80
  );
51
- const a = async (l) => {
52
- u({ type: "INIT_START" });
81
+ const l = async (b, w) => {
82
+ o({ type: "INIT_START" });
53
83
  try {
54
- const r = n.reference || de(), y = ue(n.currency), b = l || n.paymentMethods?.[0] || "card", { data: P, error: H } = await p.createPaymentIntent(
55
- { ...n, reference: r },
56
- b,
57
- y
58
- );
59
- if (H) {
60
- u({ type: "INIT_ERROR", payload: H }), i?.(H);
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 (!P) {
64
- const B = {
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
- u({ type: "INIT_ERROR", payload: B }), i?.(B);
130
+ o({ type: "INIT_ERROR", payload: x }), d?.(x);
70
131
  return;
71
132
  }
72
- const ne = fe(P, { ...n, reference: r });
73
- u({ type: "INIT_SUCCESS", payload: ne });
74
- } catch (r) {
75
- const y = {
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: r instanceof Error ? r.message : "Failed to initialize checkout",
138
+ message: g instanceof Error ? g.message : "Failed to initialize checkout",
78
139
  recoverable: !0,
79
- originalError: r
140
+ originalError: g
80
141
  };
81
- u({ type: "INIT_ERROR", payload: y }), i?.(y);
142
+ o({ type: "INIT_ERROR", payload: E }), d?.(E);
82
143
  }
83
- }, f = (l) => {
84
- u({ type: "SELECT_METHOD", payload: l });
85
- }, C = async (l) => {
86
- if (!(!s.value.paymentIntent || !s.value.selectedMethod)) {
87
- u({ type: "PROCESS_START" });
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 r;
90
- if (s.value.paymentIntent.clientSecret) {
91
- const { data: b, error: P } = await p.confirmPaymentIntent(
92
- s.value.paymentIntent.id,
93
- s.value.paymentIntent.clientSecret
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 (P) {
96
- u({ type: "PROCESS_ERROR", payload: P }), i?.(P);
156
+ if ($) {
157
+ o({ type: "PROCESS_ERROR", payload: $ }), d?.($);
97
158
  return;
98
159
  }
99
- r = b;
160
+ w = E;
100
161
  } else {
101
- const { data: b, error: P } = await p.confirmPayment(s.value.paymentIntent.id);
102
- if (P) {
103
- u({ type: "PROCESS_ERROR", payload: P }), i?.(P);
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
- r = b;
167
+ w = E;
107
168
  }
108
- const y = {
109
- paymentId: s.value.paymentIntent.id,
110
- reference: l.reference || s.value.paymentIntent.reference || s.value.paymentIntent.metadata?.reference || "",
111
- amount: s.value.paymentIntent.amount,
112
- currency: s.value.paymentIntent.currency,
113
- paymentMethod: s.value.selectedMethod,
114
- psp: s.value.paymentIntent.recommendedPsp,
115
- pspReference: l.pspReference || r?.provider_ref_id || "",
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: l
178
+ metadata: b
118
179
  };
119
- u({ type: "PROCESS_SUCCESS", payload: y }), e?.(y);
120
- } catch (r) {
121
- const y = {
180
+ o({ type: "PROCESS_SUCCESS", payload: g }), n?.(g);
181
+ } catch (w) {
182
+ const g = {
122
183
  code: "PAYMENT_FAILED",
123
- message: r instanceof Error ? r.message : "Payment failed",
184
+ message: w instanceof Error ? w.message : "Payment failed",
124
185
  recoverable: !0,
125
- originalError: r
186
+ originalError: w
126
187
  };
127
- u({ type: "PROCESS_ERROR", payload: y }), i?.(y);
188
+ o({ type: "PROCESS_ERROR", payload: g }), d?.(g);
128
189
  }
129
190
  }
130
- }, g = async (l) => {
131
- await C(l);
132
- }, A = (l) => {
133
- u({ type: "PROCESS_ERROR", payload: l }), i?.(l);
134
- }, S = () => {
135
- u({ type: "RESET" });
136
- }, U = async () => {
137
- if (s.value.paymentIntent && s.value.status !== "success")
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 p.cancelPaymentIntent(s.value.paymentIntent.id);
200
+ await h.cancelPaymentIntent(a.value.paymentIntent.id);
140
201
  } catch {
141
202
  }
142
- u({ type: "CLOSE" }), o?.();
143
- }, M = w(() => s.value.status), K = w(() => s.value.paymentIntent), R = w(() => s.value.selectedMethod), j = w(() => s.value.error), k = w(() => s.value.result), O = w(
144
- () => s.value.status === "loading" || s.value.status === "processing"
145
- ), x = w(
146
- () => s.value.status === "ready" || s.value.status === "method_selected" || s.value.status === "processing"
147
- ), T = w(() => s.value.status === "success"), z = w(() => s.value.error?.recoverable ?? !1);
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: _(M),
151
- paymentIntent: _(K),
152
- selectedMethod: _(R),
153
- error: _(j),
154
- result: _(k),
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: a,
157
- selectMethod: f,
158
- processPayment: C,
159
- handlePspSuccess: g,
160
- handlePspError: A,
161
- reset: S,
162
- close: U,
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: _(O),
165
- isReady: _(x),
166
- isComplete: _(T),
167
- canRetry: _(z)
225
+ isLoading: N(A),
226
+ isReady: N(S),
227
+ isComplete: N(X),
228
+ canRetry: N(oe)
168
229
  };
169
230
  }
170
- const we = { class: "reevit-method-selector" }, ke = { class: "reevit-amount-display" }, Pe = { class: "reevit-methods-grid" }, Ce = ["onClick"], _e = { class: "reevit-method-icon" }, Se = { class: "reevit-method-info" }, Ee = { class: "reevit-method-name" }, Ie = { class: "reevit-method-description" }, ge = { class: "reevit-method-radio" }, Me = {
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-radio-inner"
173
- }, Re = /* @__PURE__ */ V({
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
- amount: {},
179
- currency: {},
180
- provider: {}
248
+ provider: {},
249
+ layout: {},
250
+ showLabel: { type: Boolean }
181
251
  },
182
252
  emits: ["select"],
183
- setup(t, { emit: n }) {
184
- const e = t, i = n, o = {
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: m("card"),
203
- description: d("card"),
204
- icon: "💳"
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: m("mobile_money"),
209
- description: d("mobile_money"),
210
- icon: "📱"
263
+ name: "Mobile Money",
264
+ icon: "📱",
265
+ description: "MTN, Vodafone Cash, AirtelTigo Money"
211
266
  },
212
267
  {
213
268
  id: "bank_transfer",
214
- name: m("bank_transfer"),
215
- description: d("bank_transfer"),
216
- icon: "🏦"
269
+ name: "Bank Transfer",
270
+ icon: "🏦",
271
+ description: "Pay directly from your bank account"
217
272
  }
218
- ].filter((p) => e.methods.includes(p.id)));
219
- return (p, u) => (v(), h("div", we, [
220
- u[0] || (u[0] = c("h3", { class: "reevit-section-title" }, "Select Payment Method", -1)),
221
- c("p", ke, " Pay " + I(L(pe)(t.amount, t.currency)), 1),
222
- c("div", Pe, [
223
- (v(!0), h(q, null, Q(s.value, (a) => (v(), h("button", {
224
- key: a.id,
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: D(L(te)("reevit-method-card", t.selected === a.id && "reevit-method-card--selected")),
227
- onClick: (f) => i("select", a.id)
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
- c("span", _e, I(a.icon), 1),
230
- c("div", Se, [
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
- c("div", ge, [
235
- t.selected === a.id ? (v(), h("div", Me)) : E("", !0)
236
- ])
237
- ], 10, Ce))), 128))
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
- }), xe = { class: "reevit-form-group" }, Te = ["disabled"], $e = { class: "reevit-network-selector" }, Ne = { class: "reevit-networks-grid" }, Le = ["onClick", "disabled"], Ue = {
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
- }, Oe = ["disabled"], De = {
417
+ }, dt = { class: "reevit-momo-form__actions" }, ct = ["disabled"], ut = ["disabled"], pt = {
245
418
  key: 0,
246
419
  class: "reevit-spinner"
247
- }, Fe = { key: 1 }, Ae = /* @__PURE__ */ V({
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(t, { emit: n }) {
255
- const e = t, i = n, o = $(e.initialPhone || ""), m = $(null), d = $(null);
256
- N(o, (u) => {
257
- const a = ye(u);
258
- a && (m.value = a), d.value && (d.value = null);
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 s = () => {
261
- if (!G(o.value)) {
262
- d.value = "Please enter a valid phone number";
434
+ const a = () => {
435
+ if (!le(i.value)) {
436
+ u.value = "Please enter a valid phone number";
263
437
  return;
264
438
  }
265
- if (!m.value) {
266
- d.value = "Please select your mobile network";
439
+ if (!p.value) {
440
+ u.value = "Please select your mobile network";
267
441
  return;
268
442
  }
269
- i("submit", {
270
- phone: o.value,
271
- network: m.value
443
+ d("submit", {
444
+ phone: i.value,
445
+ network: p.value
272
446
  });
273
- }, p = [
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 (u, a) => (v(), h("form", {
452
+ return (o, l) => (m(), v("form", {
279
453
  class: "reevit-momo-form",
280
- onSubmit: X(s, ["prevent"])
454
+ onSubmit: ue(a, ["prevent"])
281
455
  }, [
282
- c("div", xe, [
283
- a[1] || (a[1] = c("label", {
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
- oe(c("input", {
461
+ ye(r("input", {
288
462
  id: "reevit-phone",
289
- "onUpdate:modelValue": a[0] || (a[0] = (f) => o.value = f),
463
+ "onUpdate:modelValue": l[0] || (l[0] = (_) => i.value = _),
290
464
  type: "tel",
291
- class: D(["reevit-input", { "reevit-input--error": d.value && !L(G)(o.value) }]),
465
+ class: z(["reevit-input", { "reevit-input--error": u.value && !q(le)(i.value) }]),
292
466
  placeholder: "e.g. 024 123 4567",
293
- disabled: t.loading,
467
+ disabled: e.loading,
294
468
  autocomplete: "tel"
295
- }, null, 10, Te), [
296
- [ae, o.value]
469
+ }, null, 10, st), [
470
+ [be, i.value]
297
471
  ])
298
472
  ]),
299
- c("div", $e, [
300
- a[2] || (a[2] = c("label", { class: "reevit-label" }, "Select Network", -1)),
301
- c("div", Ne, [
302
- (v(), h(q, null, Q(p, (f) => c("button", {
303
- key: f.id,
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: D(L(te)("reevit-network-btn", m.value === f.id && "reevit-network-btn--selected")),
306
- onClick: (C) => m.value = f.id,
307
- disabled: t.loading
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
- c("div", {
483
+ r("div", {
310
484
  class: "reevit-network-dot",
311
- style: ee({ backgroundColor: f.color })
485
+ style: Z({ backgroundColor: _.color })
312
486
  }, null, 4),
313
- Z(" " + I(f.name), 1)
314
- ], 10, Le)), 64))
487
+ pe(" " + I(_.name), 1)
488
+ ], 10, rt)), 64))
315
489
  ])
316
490
  ]),
317
- d.value ? (v(), h("p", Ue, I(d.value), 1)) : E("", !0),
318
- c("button", {
319
- type: "submit",
320
- class: "reevit-submit-btn",
321
- disabled: t.loading || !o.value
322
- }, [
323
- t.loading ? (v(), h("span", De)) : (v(), h("span", Fe, "Continue"))
324
- ], 8, Oe),
325
- a[3] || (a[3] = c("p", { class: "reevit-secure-text" }, " 🔒 Secure mobile money payment via Reevit ", -1))
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 Ke {
330
- constructor(n) {
331
- this.baseUrl = "https://unified-pay.hubtel.com", this.messageHandler = null, this.stylesInjected = !1, n && (this.baseUrl = n);
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: n, config: e }) {
340
- const i = this.createCheckoutUrl(n, e), o = window.open(i);
341
- if (!o || o.closed || typeof o.closed > "u")
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: n, callBacks: e, config: i, iframeStyle: o }) {
354
- var m, d, s;
355
- this.registerEvents(e);
356
- const p = document.getElementById("hubtel-checkout-iframe");
357
- if (!p)
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
- p.innerHTML = "";
360
- const u = document.createElement("div");
361
- u.textContent = "Loading...", p.appendChild(u);
362
- const a = document.createElement("iframe");
363
- a.setAttribute("id", "hubtel-iframe-element"), a.src = this.createCheckoutUrl(n, i), a.style.display = "none", a.style.width = (m = o?.width) !== null && m !== void 0 ? m : "100%", a.style.height = (d = o?.height) !== null && d !== void 0 ? d : "100%", a.style.minHeight = o?.minHeight || "400px", a.style.border = (s = o?.border) !== null && s !== void 0 ? s : "none", a.onload = () => {
364
- var f;
365
- p.removeChild(u), a.style.display = "block", (f = e.onLoad) === null || f === void 0 || f.call(e);
366
- }, p.appendChild(a);
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: n, callBacks: e, config: i }) {
369
- this.injectStyles(), this.createIframe(), this.handleBackButton(), this.registerEvents(e), this.renderWebpageInPopup(this.createCheckoutUrl(n, i), e.onClose, e.onLoad);
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(n, e) {
372
- const i = Object.assign(Object.assign({}, n), e), o = Object.keys(i).reduce((u, a) => (i[a] !== null && i[a] !== void 0 && (u[a] = i[a]), u), {}), m = Object.keys(o).map((u) => `${u}=${encodeURIComponent(o[u])}`).join("&"), d = this.encodeBase64(m), s = encodeURIComponent(d);
373
- return `${o?.branding === "disabled" ? `${this.baseUrl}/pay/direct` : `${this.baseUrl}/pay`}?p=${s}`;
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(n) {
376
- return btoa(unescape(encodeURIComponent(n)));
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 n = document.createElement("div");
385
- n.setAttribute("id", "backdrop"), n.classList.add("backdrop");
386
- const e = document.createElement("span");
387
- e.classList.add("checkout-loader"), n.appendChild(e), document.body.appendChild(n);
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(n) {
572
+ registerEvents(t) {
390
573
  this.messageHandler && window.removeEventListener("message", this.messageHandler, !1);
391
- const e = (i) => {
392
- var o, m, d, s, p, u;
393
- if (i.origin !== this.baseUrl)
574
+ const n = (d) => {
575
+ var i, p, u, a, h, o;
576
+ if (d.origin !== this.baseUrl)
394
577
  return;
395
- const { data: a } = i;
396
- if (a.success === !0)
397
- (o = n.onPaymentSuccess) === null || o === void 0 || o.call(n, a);
398
- else if (a.success === !1)
399
- (m = n.onPaymentFailure) === null || m === void 0 || m.call(n, a);
400
- else if (a.initialized)
401
- (d = n.init) === null || d === void 0 || d.call(n, a), (s = n.onInit) === null || s === void 0 || s.call(n, a);
402
- else if (a.feesChanged)
403
- (p = n.onFeesChanged) === null || p === void 0 || p.call(n, a.fees);
404
- else if (a.resize) {
405
- const f = document.getElementById("hubtel-iframe-element");
406
- f && (f.style.height = a.height + "px"), (u = n?.onResize) === null || u === void 0 || u.call(n, a);
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 = e, window.addEventListener("message", e, !1);
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(n, e, i) {
419
- const o = document.createElement("div");
420
- o.classList.add("checkout-modal");
421
- const m = document.createElement("div");
422
- m.setAttribute("id", "checkout-close-icon"), m.innerHTML = "×", m.classList.add("close-icon"), m.addEventListener("click", () => {
423
- this.closePopUp(), e?.();
424
- }), o.appendChild(m);
425
- const d = document.createElement("iframe");
426
- d.src = n, history.pushState({ modalOpen: !0 }, ""), d.classList.add("iframe"), o.appendChild(d), document.body.appendChild(o), o.style.opacity = "0", d.addEventListener("load", () => {
427
- o.style.opacity = "1", i?.();
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 n = document.querySelector(".backdrop"), e = document.querySelector(".checkout-modal");
432
- n && document.body.removeChild(n), e && document.body.removeChild(e), history.replaceState(null, ""), window.removeEventListener("popstate", this.closePopUp);
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 n = document.createElement("style");
438
- n.type = "text/css", n.setAttribute("data-hubtel-checkout", "true"), n.innerHTML = `
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(n), this.stylesInjected = !0;
721
+ `, document.head.appendChild(t), this.stylesInjected = !0;
539
722
  }
540
723
  }
541
- const J = /* @__PURE__ */ new Map();
542
- function F(t, n) {
543
- const e = J.get(n);
544
- if (e) return e;
545
- const i = new Promise((o, m) => {
546
- if (document.getElementById(n)) {
547
- o();
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 d = document.createElement("script");
551
- d.id = n, d.src = t, d.async = !0, d.onload = () => o(), d.onerror = () => m(new Error(`Failed to load ${n} script`)), document.head.appendChild(d);
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 J.set(n, i), i;
736
+ return ce.set(t, d), d;
554
737
  }
555
- function je() {
556
- return F("https://js.paystack.co/v1/inline.js", "paystack-script");
738
+ function ht() {
739
+ return te("https://js.paystack.co/v1/inline.js", "paystack-script");
557
740
  }
558
- function dt() {
741
+ function Gt() {
559
742
  return Promise.resolve();
560
743
  }
561
- function ze() {
562
- return F("https://checkout.flutterwave.com/v3.js", "flutterwave-script");
744
+ function yt() {
745
+ return te("https://checkout.flutterwave.com/v3.js", "flutterwave-script");
563
746
  }
564
- function He() {
565
- return F("https://js.stripe.com/v3/", "stripe-script");
747
+ function bt() {
748
+ return te("https://js.stripe.com/v3/", "stripe-script");
566
749
  }
567
- function Ve() {
568
- return F("https://sdk.monnify.com/plugin/monnify.js", "monnify-script");
750
+ function ft() {
751
+ return te("https://sdk.monnify.com/plugin/monnify.js", "monnify-script");
569
752
  }
570
- async function qe(t) {
571
- if (await je(), !window.PaystackPop)
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: t.key,
575
- email: t.email,
576
- amount: t.amount,
577
- currency: t.currency,
578
- ref: t.ref,
579
- metadata: t.metadata,
580
- callback: t.onSuccess,
581
- onClose: t.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 Be(t) {
585
- const n = new Ke(), e = {
586
- amount: t.amount,
587
- purchaseDescription: t.purchaseDescription,
588
- customerPhoneNumber: t.customerPhone || "",
589
- clientReference: `hubtel_${Date.now()}`
590
- }, i = {
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: t.callbackUrl || (typeof window < "u" ? window.location.href : ""),
593
- merchantAccount: typeof t.clientId == "string" ? parseInt(t.clientId, 10) : t.clientId,
594
- basicAuth: t.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
- n.openModal({
597
- purchaseInfo: e,
598
- config: i,
781
+ t.openModal({
782
+ purchaseInfo: d,
783
+ config: p,
599
784
  callBacks: {
600
- onPaymentSuccess: (o) => {
601
- t.onSuccess(o), n.closePopUp();
785
+ onPaymentSuccess: (u) => {
786
+ e.onSuccess(u), t.closePopUp();
602
787
  },
603
788
  onPaymentFailure: () => {
604
- t.onClose();
789
+ e.onClose();
605
790
  },
606
791
  onClose: () => {
607
- t.onClose();
792
+ e.onClose();
608
793
  }
609
794
  }
610
795
  });
611
796
  }
612
- async function Ye(t) {
613
- if (await ze(), !window.FlutterwaveCheckout)
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: t.public_key,
617
- tx_ref: t.tx_ref,
618
- amount: t.amount,
619
- currency: t.currency,
620
- customer: t.customer,
621
- payment_options: t.payment_options,
622
- customizations: t.customizations,
623
- callback: t.callback,
624
- onclose: t.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 We(t) {
628
- if (await He(), !window.Stripe)
812
+ async function Pt(e) {
813
+ if (await bt(), !window.Stripe)
629
814
  throw new Error("Stripe.js not loaded");
630
- return window.Stripe(t);
815
+ return window.Stripe(e);
631
816
  }
632
- async function ut(t) {
633
- const e = await (await We(t.publishableKey)).confirmPayment({
634
- elements: t.elements,
635
- clientSecret: t.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
- e.error ? t.onError({ message: e.error.message || "Payment failed" }) : e.paymentIntent && t.onSuccess({
639
- paymentIntentId: e.paymentIntent.id,
640
- status: e.paymentIntent.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 Ge(t) {
644
- if (await Ve(), !window.MonnifySDK)
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: t.amount,
648
- currency: t.currency,
649
- reference: t.reference,
650
- customerName: t.customerName,
651
- customerEmail: t.customerEmail,
652
- customerMobileNumber: t.customerPhone,
653
- apiKey: t.apiKey,
654
- contractCode: t.contractCode,
655
- paymentDescription: t.paymentDescription || "Payment",
656
- isTestMode: t.isTestMode ?? !1,
657
- metadata: t.metadata,
658
- onComplete: (n) => {
659
- n.status === "SUCCESS" ? t.onSuccess({
660
- transactionReference: n.transactionReference,
661
- paymentReference: n.paymentReference,
662
- ...n
663
- }) : t.onError?.({ message: n.message || "Payment failed" });
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: t.onClose
850
+ onClose: e.onClose
666
851
  });
667
852
  }
668
- async function Je(t, n) {
669
- t.onInitiated();
853
+ async function Ct(e, t) {
854
+ e.onInitiated();
670
855
  try {
671
- const e = await fetch(n, {
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: t.phoneNumber,
676
- amount: t.amount,
677
- reference: t.reference,
678
- description: t.description
860
+ phone_number: e.phoneNumber,
861
+ amount: e.amount,
862
+ reference: e.reference,
863
+ description: e.description
679
864
  })
680
865
  });
681
- if (!e.ok) {
682
- const m = (await e.json().catch(() => ({}))).message || "Failed to initiate M-Pesa payment";
683
- return t.onError({ message: m }), { status: "failed", message: m };
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 i = await e.json();
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: i.checkout_request_id || i.transaction_id
874
+ transactionId: d.checkout_request_id || d.transaction_id
690
875
  };
691
- } catch (e) {
692
- const i = e instanceof Error ? e.message : "Network error";
693
- return t.onError({ message: i }), { status: "failed", message: i };
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 Qe = ["disabled"], Xe = {
881
+ const St = ["disabled"], Mt = {
697
882
  key: 0,
698
883
  class: "reevit-spinner"
699
- }, Ze = { class: "reevit-modal-body" }, et = {
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
- }, tt = {
887
+ }, xt = {
703
888
  key: 1,
704
889
  class: "reevit-error-state"
705
- }, nt = {
890
+ }, Lt = {
706
891
  key: 2,
707
892
  class: "reevit-success-state"
708
- }, ot = {
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-method-form-container"
711
- }, at = {
712
- key: 2,
713
- class: "reevit-card-info"
714
- }, rt = ["disabled"], st = {
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
- }, it = { key: 1 }, mt = /* @__PURE__ */ V({
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(t, { emit: n }) {
735
- const e = t, i = n, {
736
- status: o,
737
- paymentIntent: m,
738
- selectedMethod: d,
739
- error: s,
740
- isLoading: p,
741
- isReady: u,
742
- initialize: a,
743
- selectMethod: f,
744
- handlePspSuccess: C,
745
- handlePspError: g,
746
- close: A
747
- } = be({
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: e.publicKey,
750
- amount: e.amount,
751
- currency: e.currency,
752
- email: e.email,
753
- phone: e.phone,
754
- reference: e.reference,
755
- metadata: e.metadata,
756
- paymentMethods: e.paymentMethods,
757
- initialPaymentIntent: e.initialPaymentIntent
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: e.apiBaseUrl,
760
- onSuccess: (l) => i("success", l),
761
- onError: (l) => i("error", l),
762
- onClose: () => i("close")
763
- }), S = $(e.isOpen ?? !1);
764
- N(() => e.isOpen, (l) => {
765
- l !== void 0 && (S.value = l);
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 U = () => {
768
- S.value = !0, !m.value && o.value === "idle" && a();
975
+ const Q = () => {
976
+ O.value = !0, M.value = null, !p.value && i.value === "idle" && l();
769
977
  };
770
- N([S, m, d], ([l, r, y]) => {
771
- l && r && y && y === "card" && R(null);
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
- const M = () => {
774
- S.value = !1, A();
775
- }, K = (l) => {
776
- f(l);
777
- }, R = async (l) => {
778
- const r = m.value;
779
- if (!r) return;
780
- const y = r.recommendedPsp;
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 (y === "paystack")
783
- await qe({
784
- key: e.publicKey,
785
- email: e.email || "",
786
- amount: e.amount,
787
- currency: e.currency,
788
- ref: r.id,
789
- onSuccess: (b) => C(b),
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 (y === "hubtel")
794
- await Be({
795
- clientId: r.pspCredentials?.merchantAccount || e.publicKey,
796
- purchaseDescription: `Payment for ${e.amount} ${e.currency}`,
797
- amount: e.amount,
798
- customerPhone: l?.phone || e.phone,
799
- customerEmail: e.email,
800
- basicAuth: r.pspCredentials?.basicAuth,
801
- onSuccess: (b) => C(b),
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 (y === "flutterwave")
806
- await Ye({
807
- public_key: e.publicKey,
808
- tx_ref: r.id,
809
- amount: e.amount,
810
- currency: e.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: e.email || "",
813
- phone_number: l?.phone || e.phone
1083
+ email: n.email || "",
1084
+ phone_number: c?.phone || n.phone
814
1085
  },
815
- callback: (b) => C(b),
1086
+ callback: (P) => T(P),
816
1087
  onclose: () => {
817
1088
  }
818
1089
  });
819
- else if (y === "monnify")
820
- await Ge({
821
- apiKey: r.pspPublicKey || e.publicKey,
822
- contractCode: e.metadata?.contract_code || e.publicKey,
823
- amount: e.amount,
824
- currency: e.currency,
825
- reference: r.reference || r.id,
826
- customerName: e.metadata?.customer_name || e.email || "",
827
- customerEmail: e.email || "",
828
- customerPhone: l?.phone || e.phone,
829
- metadata: e.metadata,
830
- onSuccess: (b) => C(b),
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 (y === "mpesa") {
835
- const b = `${e.apiBaseUrl || "https://api.reevit.io"}/v1/payments/${r.id}/mpesa`;
836
- await Je({
837
- phoneNumber: l?.phone || e.phone || "",
838
- amount: e.amount,
839
- reference: r.reference || r.id,
840
- description: `Payment ${r.reference || ""}`,
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: (P) => C(P),
844
- onError: (P) => g({ code: "MPESA_ERROR", message: P.message })
845
- }, b);
846
- } else g(y === "stripe" ? {
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 "${y}" is not supported in this checkout.`
1130
+ message: `Payment provider "${k}" is not supported in this checkout.`
852
1131
  });
853
- } catch (b) {
854
- g({
1132
+ } catch (P) {
1133
+ U({
855
1134
  code: "BRIDGE_ERROR",
856
- message: b instanceof Error ? b.message : "Failed to open payment gateway"
1135
+ message: P instanceof Error ? P.message : "Failed to open payment gateway"
857
1136
  });
858
1137
  }
859
- }, j = w(() => ve(e.theme || {}));
860
- N(S, (l) => {
861
- l ? document.body.style.overflow = "hidden" : document.body.style.overflow = "";
862
- }), re(() => {
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 k = w(() => o.value), O = w(() => s.value), x = w(() => d.value), T = w(() => p.value), z = w(() => u.value);
866
- return (l, r) => (v(), h("div", {
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: ee(j.value)
1150
+ style: Z(E.value)
869
1151
  }, [
870
- Y(l.$slots, "default", {
871
- open: U,
872
- isLoading: T.value
1152
+ ae(c.$slots, "default", {
1153
+ open: Q,
1154
+ isLoading: H.value
873
1155
  }, () => [
874
- c("button", {
1156
+ r("button", {
875
1157
  type: "button",
876
1158
  class: "reevit-pay-button",
877
- onClick: U,
878
- disabled: T.value
1159
+ onClick: Q,
1160
+ disabled: H.value
879
1161
  }, [
880
- T.value ? (v(), h("span", Xe)) : Y(l.$slots, "button-text", { key: 1 }, () => [
881
- r[1] || (r[1] = Z("Pay Now", -1))
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, Qe)
1165
+ ], 8, St)
884
1166
  ]),
885
- (v(), W(se, { to: "body" }, [
886
- S.value ? (v(), h("div", {
1167
+ (m(), se(_e, { to: "body" }, [
1168
+ O.value ? (m(), v("div", {
887
1169
  key: 0,
888
1170
  class: "reevit-modal-overlay",
889
- onClick: X(M, ["self"])
1171
+ onClick: ue(J, ["self"])
890
1172
  }, [
891
- c("div", {
892
- class: D(["reevit-modal-content", { "reevit-modal--dark": e.theme?.darkMode }])
1173
+ r("div", {
1174
+ class: z(["reevit-modal-content", { "reevit-modal--dark": $.value }]),
1175
+ style: Z(E.value)
893
1176
  }, [
894
- c("button", {
1177
+ r("button", {
895
1178
  class: "reevit-modal-close",
896
- onClick: M,
1179
+ onClick: J,
897
1180
  "aria-label": "Close"
898
1181
  }, " × "),
899
- r[9] || (r[9] = c("div", { class: "reevit-modal-header" }, [
900
- c("img", {
901
- src: "https://i.imgur.com/bzUR5Lm.png",
902
- alt: "Reevit",
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
- ], -1)),
906
- c("div", Ze, [
907
- k.value === "loading" ? (v(), h("div", et, [...r[2] || (r[2] = [
908
- c("div", { class: "reevit-spinner reevit-spinner--large" }, null, -1),
909
- c("p", null, "Initializing payment...", -1)
910
- ])])) : k.value === "failed" && O.value ? (v(), h("div", tt, [
911
- r[3] || (r[3] = c("div", { class: "reevit-error-icon" }, "⚠️", -1)),
912
- r[4] || (r[4] = c("h3", null, "Payment Failed", -1)),
913
- c("p", null, I(O.value.message), 1),
914
- c("button", {
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: r[0] || (r[0] = (y) => L(a)())
1199
+ onClick: s[0] || (s[0] = (k) => q(l)())
917
1200
  }, "Retry")
918
- ])) : k.value === "success" ? (v(), h("div", nt, [
919
- r[5] || (r[5] = c("div", { class: "reevit-success-icon" }, "✅", -1)),
920
- r[6] || (r[6] = c("h3", null, "Payment Successful", -1)),
921
- r[7] || (r[7] = c("p", null, "Thank you for your payment.", -1)),
922
- c("button", {
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: M
1207
+ onClick: J
925
1208
  }, "Done")
926
- ])) : z.value ? (v(), h(q, { key: 3 }, [
927
- k.value === "ready" || k.value === "method_selected" || k.value === "processing" ? (v(), W(Re, {
1209
+ ])) : x.value ? (m(), v("div", Tt, [
1210
+ A.value.length > 1 ? (m(), se(nt, {
928
1211
  key: 0,
929
- methods: e.paymentMethods || ["card", "mobile_money"],
930
- selected: x.value,
931
- amount: e.amount,
932
- currency: e.currency,
933
- provider: l.psp,
934
- onSelect: K
935
- }, null, 8, ["methods", "selected", "amount", "currency", "provider"])) : E("", !0),
936
- (k.value === "method_selected" || k.value === "processing") && x.value === "mobile_money" ? (v(), h("div", ot, [
937
- ie(Ae, {
938
- "initial-phone": e.phone,
939
- loading: k.value === "processing",
940
- onSubmit: R
941
- }, null, 8, ["initial-phone", "loading"])
942
- ])) : E("", !0),
943
- (k.value === "method_selected" || k.value === "processing") && x.value === "card" ? (v(), h("div", at, [
944
- r[8] || (r[8] = c("p", { class: "reevit-info-text" }, "You will be redirected to our secure payment partner to complete your card payment.", -1)),
945
- c("button", {
946
- class: "reevit-submit-btn",
947
- onClick: R,
948
- disabled: k.value === "processing"
949
- }, [
950
- k.value === "processing" ? (v(), h("span", st)) : (v(), h("span", it, "Proceed to Card Payment"))
951
- ], 8, rt)
952
- ])) : E("", !0)
953
- ], 64)) : E("", !0)
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
- r[10] || (r[10] = c("div", { class: "reevit-modal-footer" }, [
956
- c("div", { class: "reevit-trust-badges" }, [
957
- c("span", null, "PCI DSS Compliant"),
958
- c("span", null, "•"),
959
- c("span", null, "SSL Secure")
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
- ], 2)
963
- ])) : E("", !0)
1284
+ ], 6)
1285
+ ])) : L("", !0)
964
1286
  ]))
965
1287
  ], 4));
966
1288
  }
967
1289
  });
968
1290
  export {
969
- Ae as MobileMoneyForm,
970
- Re as PaymentMethodSelector,
971
- vt as ReevitAPIClient,
972
- mt as ReevitCheckout,
973
- ht as cn,
974
- ut as confirmStripePayment,
975
- ft as createReevitClient,
976
- We as createStripeInstance,
977
- bt as detectCountryFromCurrency,
978
- wt as detectNetwork,
979
- kt as formatAmount,
980
- Pt as formatPhone,
981
- Je as initiateMPesaSTKPush,
982
- ze as loadFlutterwaveScript,
983
- dt as loadHubtelScript,
984
- Ve as loadMonnifyScript,
985
- je as loadPaystackScript,
986
- He as loadStripeScript,
987
- Ye as openFlutterwaveModal,
988
- Be as openHubtelPopup,
989
- Ge as openMonnifyModal,
990
- qe as openPaystackPopup,
991
- be as useReevit,
992
- Ct as validatePhone
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
  };