@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
|
@@ -102,7 +102,9 @@ export interface HubtelConfig {
|
|
|
102
102
|
callbackUrl?: string;
|
|
103
103
|
customerPhone?: string;
|
|
104
104
|
customerEmail?: string;
|
|
105
|
+
hubtelSessionToken?: string;
|
|
105
106
|
basicAuth?: string;
|
|
107
|
+
preferredMethod?: 'card' | 'mobile_money';
|
|
106
108
|
onSuccess: (response: Record<string, unknown>) => void;
|
|
107
109
|
onClose: () => void;
|
|
108
110
|
}
|
|
@@ -2,10 +2,13 @@ import { MobileMoneyFormData } from '../../../core/src/index.ts';
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
initialPhone?: string;
|
|
4
4
|
loading?: boolean;
|
|
5
|
+
hideCancel?: boolean;
|
|
5
6
|
};
|
|
6
7
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
7
8
|
submit: (data: MobileMoneyFormData) => any;
|
|
9
|
+
cancel: () => any;
|
|
8
10
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
11
|
onSubmit?: ((data: MobileMoneyFormData) => any) | undefined;
|
|
12
|
+
onCancel?: (() => any) | undefined;
|
|
10
13
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLFormElement>;
|
|
11
14
|
export default _default;
|
|
@@ -2,9 +2,9 @@ import { PaymentMethod } from '../../../core/src/index.ts';
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
methods: PaymentMethod[];
|
|
4
4
|
selected: PaymentMethod | null;
|
|
5
|
-
amount: number;
|
|
6
|
-
currency: string;
|
|
7
5
|
provider?: string;
|
|
6
|
+
layout?: 'grid' | 'list';
|
|
7
|
+
showLabel?: boolean;
|
|
8
8
|
};
|
|
9
9
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
10
10
|
select: (method: PaymentMethod) => any;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CheckoutProviderOption, PaymentMethod, ReevitTheme } from '../../../core/src/index.ts';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
providers: CheckoutProviderOption[];
|
|
4
|
+
selectedProvider: string | null;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
theme?: ReevitTheme;
|
|
7
|
+
selectedMethod?: PaymentMethod | null;
|
|
8
|
+
};
|
|
9
|
+
declare function __VLS_template(): {
|
|
10
|
+
attrs: Partial<{}>;
|
|
11
|
+
slots: {
|
|
12
|
+
'method-content'?(_: {}): any;
|
|
13
|
+
};
|
|
14
|
+
refs: {};
|
|
15
|
+
rootEl: HTMLDivElement;
|
|
16
|
+
};
|
|
17
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
18
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
19
|
+
select: (provider: string) => any;
|
|
20
|
+
methodSelect: (method: PaymentMethod) => any;
|
|
21
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
22
|
+
onSelect?: ((provider: string) => any) | undefined;
|
|
23
|
+
onMethodSelect?: ((method: PaymentMethod) => any) | undefined;
|
|
24
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
25
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
26
|
+
export default _default;
|
|
27
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { ReevitTheme } from '../../../core/src/index.ts';
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
-
publicKey
|
|
3
|
+
publicKey?: string;
|
|
4
4
|
amount: number;
|
|
5
5
|
currency: string;
|
|
6
6
|
email?: string;
|
|
7
7
|
phone?: string;
|
|
8
|
+
customerName?: string;
|
|
8
9
|
reference?: string;
|
|
9
10
|
metadata?: Record<string, unknown>;
|
|
11
|
+
customFields?: Record<string, unknown>;
|
|
12
|
+
paymentLinkCode?: string;
|
|
10
13
|
paymentMethods?: ('card' | 'mobile_money' | 'bank_transfer')[];
|
|
11
14
|
theme?: ReevitTheme;
|
|
12
15
|
isOpen?: boolean;
|
|
@@ -32,6 +32,28 @@ export declare function useReevit(options: UseReevitOptions): {
|
|
|
32
32
|
readonly metadata?: {
|
|
33
33
|
readonly [x: string]: Readonly<unknown>;
|
|
34
34
|
} | undefined;
|
|
35
|
+
readonly availableProviders?: readonly {
|
|
36
|
+
readonly provider: string;
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly methods: readonly PaymentMethod[];
|
|
39
|
+
readonly countries?: readonly string[] | undefined;
|
|
40
|
+
}[] | undefined;
|
|
41
|
+
readonly branding?: {
|
|
42
|
+
readonly primaryColor?: string | undefined;
|
|
43
|
+
readonly primaryForegroundColor?: string | undefined;
|
|
44
|
+
readonly backgroundColor?: string | undefined;
|
|
45
|
+
readonly surfaceColor?: string | undefined;
|
|
46
|
+
readonly textColor?: string | undefined;
|
|
47
|
+
readonly mutedTextColor?: string | undefined;
|
|
48
|
+
readonly borderRadius?: string | undefined;
|
|
49
|
+
readonly fontFamily?: string | undefined;
|
|
50
|
+
readonly darkMode?: boolean | undefined;
|
|
51
|
+
readonly logoUrl?: string | undefined;
|
|
52
|
+
readonly pspSelectorBgColor?: string | undefined;
|
|
53
|
+
readonly pspSelectorTextColor?: string | undefined;
|
|
54
|
+
readonly pspSelectorBorderColor?: string | undefined;
|
|
55
|
+
readonly pspSelectorUseBorder?: boolean | undefined;
|
|
56
|
+
} | undefined;
|
|
35
57
|
} | null, {
|
|
36
58
|
readonly id: string;
|
|
37
59
|
readonly clientSecret: string;
|
|
@@ -55,6 +77,28 @@ export declare function useReevit(options: UseReevitOptions): {
|
|
|
55
77
|
readonly metadata?: {
|
|
56
78
|
readonly [x: string]: Readonly<unknown>;
|
|
57
79
|
} | undefined;
|
|
80
|
+
readonly availableProviders?: readonly {
|
|
81
|
+
readonly provider: string;
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly methods: readonly PaymentMethod[];
|
|
84
|
+
readonly countries?: readonly string[] | undefined;
|
|
85
|
+
}[] | undefined;
|
|
86
|
+
readonly branding?: {
|
|
87
|
+
readonly primaryColor?: string | undefined;
|
|
88
|
+
readonly primaryForegroundColor?: string | undefined;
|
|
89
|
+
readonly backgroundColor?: string | undefined;
|
|
90
|
+
readonly surfaceColor?: string | undefined;
|
|
91
|
+
readonly textColor?: string | undefined;
|
|
92
|
+
readonly mutedTextColor?: string | undefined;
|
|
93
|
+
readonly borderRadius?: string | undefined;
|
|
94
|
+
readonly fontFamily?: string | undefined;
|
|
95
|
+
readonly darkMode?: boolean | undefined;
|
|
96
|
+
readonly logoUrl?: string | undefined;
|
|
97
|
+
readonly pspSelectorBgColor?: string | undefined;
|
|
98
|
+
readonly pspSelectorTextColor?: string | undefined;
|
|
99
|
+
readonly pspSelectorBorderColor?: string | undefined;
|
|
100
|
+
readonly pspSelectorUseBorder?: boolean | undefined;
|
|
101
|
+
} | undefined;
|
|
58
102
|
} | null>>;
|
|
59
103
|
selectedMethod: Readonly<import('vue').Ref<PaymentMethod | null, PaymentMethod | null>>;
|
|
60
104
|
error: Readonly<import('vue').Ref<{
|
|
@@ -105,7 +149,10 @@ export declare function useReevit(options: UseReevitOptions): {
|
|
|
105
149
|
readonly sourceId?: string | undefined;
|
|
106
150
|
readonly sourceDescription?: string | undefined;
|
|
107
151
|
} | null>>;
|
|
108
|
-
initialize: (method?: PaymentMethod
|
|
152
|
+
initialize: (method?: PaymentMethod, options?: {
|
|
153
|
+
preferredProvider?: string;
|
|
154
|
+
allowedProviders?: string[];
|
|
155
|
+
}) => Promise<void>;
|
|
109
156
|
selectMethod: (method: PaymentMethod) => void;
|
|
110
157
|
processPayment: (paymentData: Record<string, unknown>) => Promise<void>;
|
|
111
158
|
handlePspSuccess: (pspData: Record<string, unknown>) => Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as ReevitCheckout } from './components/ReevitCheckout.vue';
|
|
2
|
+
export { default as ProviderSelector } from './components/ProviderSelector.vue';
|
|
2
3
|
export { default as PaymentMethodSelector } from './components/PaymentMethodSelector.vue';
|
|
3
4
|
export { default as MobileMoneyForm } from './components/MobileMoneyForm.vue';
|
|
4
5
|
export { useReevit } from './composables';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),v=require("@reevit/core");function Q(n){const o=n.toLowerCase();return o.includes("paystack")?"paystack":o.includes("hubtel")?"hubtel":o.includes("flutterwave")?"flutterwave":o.includes("stripe")?"stripe":o.includes("monnify")?"monnify":o.includes("mpesa")||o.includes("m-pesa")?"mpesa":"paystack"}function X(n,o){return{id:n.id,clientSecret:n.client_secret,pspPublicKey:n.psp_public_key,pspCredentials:n.psp_credentials,amount:n.amount,currency:n.currency,status:n.status,recommendedPsp:Q(n.provider),availableMethods:o.paymentMethods||["card","mobile_money"],reference:n.reference||o.reference,connectionId:n.connection_id,provider:n.provider,feeAmount:n.fee_amount,feeCurrency:n.fee_currency,netAmount:n.net_amount,metadata:o.metadata}}function L(n){const{config:o,onSuccess:t,onError:l,onClose:r,onStateChange:m,apiBaseUrl:d}=n,i=e.ref(v.createInitialState());if(o.initialPaymentIntent){const c=o.initialPaymentIntent;i.value={...i.value,status:"ready",paymentIntent:c,selectedMethod:c.availableMethods?.length===1?c.availableMethods[0]:null}}const p=new v.ReevitAPIClient({publicKey:o.publicKey,baseUrl:d}),u=c=>{i.value=v.reevitReducer(i.value,c)};e.watch(()=>i.value.status,c=>{m?.(c)});const a=async c=>{u({type:"INIT_START"});try{const s=o.reference||v.generateReference(),y=v.detectCountryFromCurrency(o.currency),f=c||o.paymentMethods?.[0]||"card",{data:k,error:x}=await p.createPaymentIntent({...o,reference:s},f,y);if(x){u({type:"INIT_ERROR",payload:x}),l?.(x);return}if(!k){const $={code:"INIT_FAILED",message:"No data received from API",recoverable:!0};u({type:"INIT_ERROR",payload:$}),l?.($);return}const J=X(k,{...o,reference:s});u({type:"INIT_SUCCESS",payload:J})}catch(s){const y={code:"INIT_FAILED",message:s instanceof Error?s.message:"Failed to initialize checkout",recoverable:!0,originalError:s};u({type:"INIT_ERROR",payload:y}),l?.(y)}},h=c=>{u({type:"SELECT_METHOD",payload:c})},E=async c=>{if(!(!i.value.paymentIntent||!i.value.selectedMethod)){u({type:"PROCESS_START"});try{let s;if(i.value.paymentIntent.clientSecret){const{data:f,error:k}=await p.confirmPaymentIntent(i.value.paymentIntent.id,i.value.paymentIntent.clientSecret);if(k){u({type:"PROCESS_ERROR",payload:k}),l?.(k);return}s=f}else{const{data:f,error:k}=await p.confirmPayment(i.value.paymentIntent.id);if(k){u({type:"PROCESS_ERROR",payload:k}),l?.(k);return}s=f}const y={paymentId:i.value.paymentIntent.id,reference:c.reference||i.value.paymentIntent.reference||i.value.paymentIntent.metadata?.reference||"",amount:i.value.paymentIntent.amount,currency:i.value.paymentIntent.currency,paymentMethod:i.value.selectedMethod,psp:i.value.paymentIntent.recommendedPsp,pspReference:c.pspReference||s?.provider_ref_id||"",status:"success",metadata:c};u({type:"PROCESS_SUCCESS",payload:y}),t?.(y)}catch(s){const y={code:"PAYMENT_FAILED",message:s instanceof Error?s.message:"Payment failed",recoverable:!0,originalError:s};u({type:"PROCESS_ERROR",payload:y}),l?.(y)}}},P=async c=>{await E(c)},R=c=>{u({type:"PROCESS_ERROR",payload:c}),l?.(c)},w=()=>{u({type:"RESET"})},I=async()=>{if(i.value.paymentIntent&&i.value.status!=="success")try{await p.cancelPaymentIntent(i.value.paymentIntent.id)}catch{}u({type:"CLOSE"}),r?.()},C=e.computed(()=>i.value.status),V=e.computed(()=>i.value.paymentIntent),S=e.computed(()=>i.value.selectedMethod),B=e.computed(()=>i.value.error),b=e.computed(()=>i.value.result),N=e.computed(()=>i.value.status==="loading"||i.value.status==="processing"),_=e.computed(()=>i.value.status==="ready"||i.value.status==="method_selected"||i.value.status==="processing"),g=e.computed(()=>i.value.status==="success"),T=e.computed(()=>i.value.error?.recoverable??!1);return{status:e.readonly(C),paymentIntent:e.readonly(V),selectedMethod:e.readonly(S),error:e.readonly(B),result:e.readonly(b),initialize:a,selectMethod:h,processPayment:E,handlePspSuccess:P,handlePspError:R,reset:w,close:I,isLoading:e.readonly(N),isReady:e.readonly(_),isComplete:e.readonly(g),canRetry:e.readonly(T)}}const Z={class:"reevit-method-selector"},ee={class:"reevit-amount-display"},te={class:"reevit-methods-grid"},ne=["onClick"],oe={class:"reevit-method-icon"},re={class:"reevit-method-info"},ae={class:"reevit-method-name"},se={class:"reevit-method-description"},ie={class:"reevit-method-radio"},le={key:0,class:"reevit-radio-inner"},D=e.defineComponent({__name:"PaymentMethodSelector",props:{methods:{},selected:{},amount:{},currency:{},provider:{}},emits:["select"],setup(n,{emit:o}){const t=n,l=o,r={hubtel:"Hubtel",paystack:"Paystack",flutterwave:"Flutterwave",monnify:"Monnify",mpesa:"M-Pesa",stripe:"Stripe"},m=p=>t.provider?.toLowerCase().includes("hubtel")&&p==="mobile_money"?`Pay with ${r[t.provider.toLowerCase()]||"Hubtel"}`:{card:"Card",mobile_money:"Mobile Money",bank_transfer:"Bank Transfer"}[p],d=p=>t.provider?.toLowerCase().includes("hubtel")?"Card, Mobile Money, and Bank Transfer":{card:"Visa, Mastercard, Maestro",mobile_money:"MTN, Vodafone, AirtelTigo",bank_transfer:"Transfer directly from your bank"}[p],i=e.computed(()=>[{id:"card",name:m("card"),description:d("card"),icon:"💳"},{id:"mobile_money",name:m("mobile_money"),description:d("mobile_money"),icon:"📱"},{id:"bank_transfer",name:m("bank_transfer"),description:d("bank_transfer"),icon:"🏦"}].filter(p=>t.methods.includes(p.id)));return(p,u)=>(e.openBlock(),e.createElementBlock("div",Z,[u[0]||(u[0]=e.createElementVNode("h3",{class:"reevit-section-title"},"Select Payment Method",-1)),e.createElementVNode("p",ee," Pay "+e.toDisplayString(e.unref(v.formatAmount)(n.amount,n.currency)),1),e.createElementVNode("div",te,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,a=>(e.openBlock(),e.createElementBlock("button",{key:a.id,type:"button",class:e.normalizeClass(e.unref(v.cn)("reevit-method-card",n.selected===a.id&&"reevit-method-card--selected")),onClick:h=>l("select",a.id)},[e.createElementVNode("span",oe,e.toDisplayString(a.icon),1),e.createElementVNode("div",re,[e.createElementVNode("span",ae,e.toDisplayString(a.name),1),e.createElementVNode("span",se,e.toDisplayString(a.description),1)]),e.createElementVNode("div",ie,[n.selected===a.id?(e.openBlock(),e.createElementBlock("div",le)):e.createCommentVNode("",!0)])],10,ne))),128))])]))}}),ce={class:"reevit-form-group"},de=["disabled"],ue={class:"reevit-network-selector"},me={class:"reevit-networks-grid"},pe=["onClick","disabled"],ye={key:0,class:"reevit-error-message"},ve=["disabled"],he={key:0,class:"reevit-spinner"},fe={key:1},U=e.defineComponent({__name:"MobileMoneyForm",props:{initialPhone:{},loading:{type:Boolean}},emits:["submit"],setup(n,{emit:o}){const t=n,l=o,r=e.ref(t.initialPhone||""),m=e.ref(null),d=e.ref(null);e.watch(r,u=>{const a=v.detectNetwork(u);a&&(m.value=a),d.value&&(d.value=null)});const i=()=>{if(!v.validatePhone(r.value)){d.value="Please enter a valid phone number";return}if(!m.value){d.value="Please select your mobile network";return}l("submit",{phone:r.value,network:m.value})},p=[{id:"mtn",name:"MTN",color:"#FFCC00"},{id:"vodafone",name:"Vodafone",color:"#E60000"},{id:"airteltigo",name:"AirtelTigo",color:"#005596"}];return(u,a)=>(e.openBlock(),e.createElementBlock("form",{class:"reevit-momo-form",onSubmit:e.withModifiers(i,["prevent"])},[e.createElementVNode("div",ce,[a[1]||(a[1]=e.createElementVNode("label",{class:"reevit-label",for:"reevit-phone"},"Phone Number",-1)),e.withDirectives(e.createElementVNode("input",{id:"reevit-phone","onUpdate:modelValue":a[0]||(a[0]=h=>r.value=h),type:"tel",class:e.normalizeClass(["reevit-input",{"reevit-input--error":d.value&&!e.unref(v.validatePhone)(r.value)}]),placeholder:"e.g. 024 123 4567",disabled:n.loading,autocomplete:"tel"},null,10,de),[[e.vModelText,r.value]])]),e.createElementVNode("div",ue,[a[2]||(a[2]=e.createElementVNode("label",{class:"reevit-label"},"Select Network",-1)),e.createElementVNode("div",me,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(p,h=>e.createElementVNode("button",{key:h.id,type:"button",class:e.normalizeClass(e.unref(v.cn)("reevit-network-btn",m.value===h.id&&"reevit-network-btn--selected")),onClick:E=>m.value=h.id,disabled:n.loading},[e.createElementVNode("div",{class:"reevit-network-dot",style:e.normalizeStyle({backgroundColor:h.color})},null,4),e.createTextVNode(" "+e.toDisplayString(h.name),1)],10,pe)),64))])]),d.value?(e.openBlock(),e.createElementBlock("p",ye,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"submit",class:"reevit-submit-btn",disabled:n.loading||!r.value},[n.loading?(e.openBlock(),e.createElementBlock("span",he)):(e.openBlock(),e.createElementBlock("span",fe,"Continue"))],8,ve),a[3]||(a[3]=e.createElementVNode("p",{class:"reevit-secure-text"}," 🔒 Secure mobile money payment via Reevit ",-1))],32))}});class be{constructor(o){this.baseUrl="https://unified-pay.hubtel.com",this.messageHandler=null,this.stylesInjected=!1,o&&(this.baseUrl=o)}redirect({purchaseInfo:o,config:t}){const l=this.createCheckoutUrl(o,t),r=window.open(l);if(!r||r.closed||typeof r.closed>"u")throw new Error("Popup was blocked by the browser. Please allow popups for this site.")}initIframe({purchaseInfo:o,callBacks:t,config:l,iframeStyle:r}){var m,d,i;this.registerEvents(t);const p=document.getElementById("hubtel-checkout-iframe");if(!p)throw new Error('Container element with id "hubtel-checkout-iframe" not found in the DOM.');p.innerHTML="";const u=document.createElement("div");u.textContent="Loading...",p.appendChild(u);const a=document.createElement("iframe");a.setAttribute("id","hubtel-iframe-element"),a.src=this.createCheckoutUrl(o,l),a.style.display="none",a.style.width=(m=r?.width)!==null&&m!==void 0?m:"100%",a.style.height=(d=r?.height)!==null&&d!==void 0?d:"100%",a.style.minHeight=r?.minHeight||"400px",a.style.border=(i=r?.border)!==null&&i!==void 0?i:"none",a.onload=()=>{var h;p.removeChild(u),a.style.display="block",(h=t.onLoad)===null||h===void 0||h.call(t)},p.appendChild(a)}openModal({purchaseInfo:o,callBacks:t,config:l}){this.injectStyles(),this.createIframe(),this.handleBackButton(),this.registerEvents(t),this.renderWebpageInPopup(this.createCheckoutUrl(o,l),t.onClose,t.onLoad)}createCheckoutUrl(o,t){const l=Object.assign(Object.assign({},o),t),r=Object.keys(l).reduce((u,a)=>(l[a]!==null&&l[a]!==void 0&&(u[a]=l[a]),u),{}),m=Object.keys(r).map(u=>`${u}=${encodeURIComponent(r[u])}`).join("&"),d=this.encodeBase64(m),i=encodeURIComponent(d);return`${r?.branding==="disabled"?`${this.baseUrl}/pay/direct`:`${this.baseUrl}/pay`}?p=${i}`}encodeBase64(o){return btoa(unescape(encodeURIComponent(o)))}handleBackButton(){window.addEventListener("popstate",()=>{this.closePopUp()})}createIframe(){const o=document.createElement("div");o.setAttribute("id","backdrop"),o.classList.add("backdrop");const t=document.createElement("span");t.classList.add("checkout-loader"),o.appendChild(t),document.body.appendChild(o)}registerEvents(o){this.messageHandler&&window.removeEventListener("message",this.messageHandler,!1);const t=l=>{var r,m,d,i,p,u;if(l.origin!==this.baseUrl)return;const{data:a}=l;if(a.success===!0)(r=o.onPaymentSuccess)===null||r===void 0||r.call(o,a);else if(a.success===!1)(m=o.onPaymentFailure)===null||m===void 0||m.call(o,a);else if(a.initialized)(d=o.init)===null||d===void 0||d.call(o,a),(i=o.onInit)===null||i===void 0||i.call(o,a);else if(a.feesChanged)(p=o.onFeesChanged)===null||p===void 0||p.call(o,a.fees);else if(a.resize){const h=document.getElementById("hubtel-iframe-element");h&&(h.style.height=a.height+"px"),(u=o?.onResize)===null||u===void 0||u.call(o,a)}};this.messageHandler=t,window.addEventListener("message",t,!1)}destroy(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler,!1),this.messageHandler=null)}renderWebpageInPopup(o,t,l){const r=document.createElement("div");r.classList.add("checkout-modal");const m=document.createElement("div");m.setAttribute("id","checkout-close-icon"),m.innerHTML="×",m.classList.add("close-icon"),m.addEventListener("click",()=>{this.closePopUp(),t?.()}),r.appendChild(m);const d=document.createElement("iframe");d.src=o,history.pushState({modalOpen:!0},""),d.classList.add("iframe"),r.appendChild(d),document.body.appendChild(r),r.style.opacity="0",d.addEventListener("load",()=>{r.style.opacity="1",l?.()})}closePopUp(){const o=document.querySelector(".backdrop"),t=document.querySelector(".checkout-modal");o&&document.body.removeChild(o),t&&document.body.removeChild(t),history.replaceState(null,""),window.removeEventListener("popstate",this.closePopUp)}injectStyles(){if(this.stylesInjected)return;const o=document.createElement("style");o.type="text/css",o.setAttribute("data-hubtel-checkout","true"),o.innerHTML=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),k=require("@reevit/core"),le="https://api.reevit.io";function ce(t,o){return{code:o?.code||"payment_link_error",message:o?.message||"Payment link request failed",recoverable:!0,details:{httpStatus:t.status,...o?.details||{}}}}function de(t){const o=t.toLowerCase();return o.includes("paystack")?"paystack":o.includes("hubtel")?"hubtel":o.includes("flutterwave")?"flutterwave":o.includes("stripe")?"stripe":o.includes("monnify")?"monnify":o.includes("mpesa")||o.includes("m-pesa")?"mpesa":"paystack"}function ue(t){const o=t.toLowerCase().trim();return o==="card"?"card":o==="mobile_money"||o==="momo"||o==="mobilemoney"?"mobile_money":o==="bank"||o==="bank_transfer"||o==="transfer"?"bank_transfer":null}function me(t){if(!(!t||t.length===0))return t.map(o=>{const n=o.methods.map(c=>ue(c)).filter(Boolean);return{provider:o.provider,name:o.name,methods:n,countries:o.countries}}).filter(o=>o.methods.length>0)}function pe(t,o){return{id:t.id,clientSecret:t.client_secret,pspPublicKey:t.psp_public_key,pspCredentials:t.psp_credentials,amount:t.amount,currency:t.currency,status:t.status,recommendedPsp:de(t.provider),availableMethods:o.paymentMethods||["card","mobile_money"],reference:t.reference||o.reference,connectionId:t.connection_id,provider:t.provider,feeAmount:t.fee_amount,feeCurrency:t.fee_currency,netAmount:t.net_amount,metadata:o.metadata,availableProviders:me(t.available_psps),branding:t.branding}}function J(t){const{config:o,onSuccess:n,onError:c,onClose:i,onStateChange:m,apiBaseUrl:u}=t,s=e.ref(k.createInitialState());if(o.initialPaymentIntent){const y=o.initialPaymentIntent;s.value={...s.value,status:"ready",paymentIntent:y,selectedMethod:y.availableMethods?.length===1?y.availableMethods[0]:null}}const p=new k.ReevitAPIClient({publicKey:o.publicKey,baseUrl:u}),r=y=>{s.value=k.reevitReducer(s.value,y)};e.watch(()=>s.value.status,y=>{m?.(y)});const l=async(y,f)=>{r({type:"INIT_START"});try{const E=o.reference||k.generateReference(),C=k.detectCountryFromCurrency(o.currency),M=o.paymentMethods&&o.paymentMethods.length===1?o.paymentMethods[0]:void 0,S=y??M;let L,P;if(o.paymentLinkCode){const N=await fetch(`${u||le}/v1/pay/${o.paymentLinkCode}/pay`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":`${Date.now()}-${Math.random().toString(36).substring(2,15)}`},body:JSON.stringify({amount:o.amount,email:o.email||"",name:o.customerName||"",phone:o.phone||"",method:S,country:C,provider:f?.preferredProvider||f?.allowedProviders?.[0],custom_fields:o.customFields})}),d=await N.json().catch(()=>({}));N.ok?L=d:P=ce(N,d)}else{const N=await p.createPaymentIntent({...o,reference:E},S,C,{preferredProviders:f?.preferredProvider?[f.preferredProvider]:void 0,allowedProviders:f?.allowedProviders});L=N.data,P=N.error}if(P){r({type:"INIT_ERROR",payload:P}),c?.(P);return}if(!L){const N={code:"INIT_FAILED",message:"No data received from API",recoverable:!0};r({type:"INIT_ERROR",payload:N}),c?.(N);return}const T=pe(L,{...o,reference:E});r({type:"INIT_SUCCESS",payload:T})}catch(E){const C={code:"INIT_FAILED",message:E instanceof Error?E.message:"Failed to initialize checkout",recoverable:!0,originalError:E};r({type:"INIT_ERROR",payload:C}),c?.(C)}},h=y=>{r({type:"SELECT_METHOD",payload:y})},I=async y=>{if(!(!s.value.paymentIntent||!s.value.selectedMethod)){r({type:"PROCESS_START"});try{let f;if(s.value.paymentIntent.clientSecret){const{data:C,error:M}=await p.confirmPaymentIntent(s.value.paymentIntent.id,s.value.paymentIntent.clientSecret);if(M){r({type:"PROCESS_ERROR",payload:M}),c?.(M);return}f=C}else{const{data:C,error:M}=await p.confirmPayment(s.value.paymentIntent.id);if(M){r({type:"PROCESS_ERROR",payload:M}),c?.(M);return}f=C}const E={paymentId:s.value.paymentIntent.id,reference:y.reference||s.value.paymentIntent.reference||s.value.paymentIntent.metadata?.reference||"",amount:s.value.paymentIntent.amount,currency:s.value.paymentIntent.currency,paymentMethod:s.value.selectedMethod,psp:s.value.paymentIntent.recommendedPsp,pspReference:y.pspReference||f?.provider_ref_id||"",status:"success",metadata:y};r({type:"PROCESS_SUCCESS",payload:E}),n?.(E)}catch(f){const E={code:"PAYMENT_FAILED",message:f instanceof Error?f.message:"Payment failed",recoverable:!0,originalError:f};r({type:"PROCESS_ERROR",payload:E}),c?.(E)}}},B=async y=>{await I(y)},K=y=>{r({type:"PROCESS_ERROR",payload:y}),c?.(y)},U=()=>{r({type:"RESET"})},V=async()=>{if(s.value.paymentIntent&&s.value.status!=="success")try{await p.cancelPaymentIntent(s.value.paymentIntent.id)}catch{}r({type:"CLOSE"}),i?.()},g=e.computed(()=>s.value.status),F=e.computed(()=>s.value.paymentIntent),A=e.computed(()=>s.value.selectedMethod),D=e.computed(()=>s.value.error),R=e.computed(()=>s.value.result),$=e.computed(()=>s.value.status==="loading"||s.value.status==="processing"),w=e.computed(()=>s.value.status==="ready"||s.value.status==="method_selected"||s.value.status==="processing"),j=e.computed(()=>s.value.status==="success"),H=e.computed(()=>s.value.error?.recoverable??!1);return{status:e.readonly(g),paymentIntent:e.readonly(F),selectedMethod:e.readonly(A),error:e.readonly(D),result:e.readonly(R),initialize:l,selectMethod:h,processPayment:I,handlePspSuccess:B,handlePspError:K,reset:U,close:V,isLoading:e.readonly($),isReady:e.readonly(w),isComplete:e.readonly(j),canRetry:e.readonly(H)}}const ve={key:0,class:"reevit-method-selector__label"},ye=["onClick"],he={class:"reevit-method-option__icon-wrapper"},be={class:"reevit-method-option__icon"},fe={class:"reevit-method-option__content"},ke={class:"reevit-method-option__label"},_e={key:0,class:"reevit-method-option__description"},Ee={key:0,class:"reevit-method-option__check"},Pe={key:1,class:"reevit-method-option__chevron"},Y=e.defineComponent({__name:"PaymentMethodSelector",props:{methods:{},selected:{},provider:{},layout:{},showLabel:{type:Boolean}},emits:["select"],setup(t,{emit:o}){const n=t,{showLabel:c=!0}=n,i=o,m=e.computed(()=>(n.layout||"list")==="grid"),u=e.computed(()=>[{id:"card",name:"Card",icon:"💳",description:"Pay with Visa, Mastercard, or other cards"},{id:"mobile_money",name:"Mobile Money",icon:"📱",description:"MTN, Vodafone Cash, AirtelTigo Money"},{id:"bank_transfer",name:"Bank Transfer",icon:"🏦",description:"Pay directly from your bank account"}].filter(s=>n.methods.includes(s.id)));return(s,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["reevit-method-selector",{"reevit-method-selector--grid":m.value}])},[e.unref(c)?(e.openBlock(),e.createElementBlock("div",ve,"Select payment method")):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["reevit-method-selector__options",m.value?"reevit-method-selector__options--grid":"reevit-method-selector__options--list"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,(r,l)=>(e.openBlock(),e.createElementBlock("button",{key:r.id,type:"button",class:e.normalizeClass(["reevit-method-option",[m.value?"reevit-method-option--grid":"reevit-method-option--list",{"reevit-method-option--selected":t.selected===r.id}]]),style:e.normalizeStyle({animationDelay:`${l*.05}s`}),onClick:h=>i("select",r.id)},[e.createElementVNode("span",he,[e.createElementVNode("span",be,e.toDisplayString(r.icon),1)]),e.createElementVNode("div",fe,[e.createElementVNode("span",ke,e.toDisplayString(r.name),1),m.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",_e,e.toDisplayString(r.description),1))]),m.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t.selected===r.id?(e.openBlock(),e.createElementBlock("span",Ee,[...p[0]||(p[0]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)])])):(e.openBlock(),e.createElementBlock("span",Pe,[...p[1]||(p[1]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"9 18 15 12 9 6"})],-1)])]))],64))],14,ye))),128))],2)],2))}}),we={class:"reevit-psp-selector"},ge={class:"reevit-psp-selector__options"},Ce=["disabled","aria-expanded","onClick"],Se={class:"reevit-psp-option__logo","aria-hidden":"true"},Me=["src"],Ne={key:1,class:"reevit-psp-option__logo-fallback"},Ie={class:"reevit-psp-option__content"},Be={class:"reevit-psp-option__name"},Ve={class:"reevit-psp-option__methods"},Re={key:0,class:"reevit-psp-accordion__content reevit-animate-fade-in"},$e={class:"reevit-psp-methods"},W=e.defineComponent({__name:"ProviderSelector",props:{providers:{},selectedProvider:{},disabled:{type:Boolean},theme:{},selectedMethod:{}},emits:["select","methodSelect"],setup(t,{emit:o}){const n=o,c={paystack:"https://reevit.io/images/providers/paystack.png",stripe:"https://reevit.io/images/providers/stripe.png",flutterwave:"https://reevit.io/images/providers/flutterwave.png",hubtel:"https://reevit.io/images/providers/hubtel.png",monnify:"https://reevit.io/images/providers/monnify.png",mpesa:"https://reevit.io/images/providers/mpesa.png"},i={card:"Card",mobile_money:"Mobile Money",bank_transfer:"Bank Transfer"},m=s=>s.length?s.map(p=>i[p]).join(", "):"Payment methods",u=(s,p)=>s.toLowerCase().includes("hubtel")?p.filter(r=>r==="card"||r==="mobile_money"):p;return(s,p)=>(e.openBlock(),e.createElementBlock("div",we,[p[1]||(p[1]=e.createElementVNode("div",{class:"reevit-psp-selector__label"},"Select payment provider",-1)),e.createElementVNode("div",ge,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.providers,r=>(e.openBlock(),e.createElementBlock("div",{key:r.provider,class:"reevit-psp-accordion"},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(e.unref(k.cn)("reevit-psp-option",t.selectedProvider===r.provider&&"reevit-psp-option--selected",t.disabled&&"reevit-psp-option--disabled")),disabled:t.disabled,"aria-expanded":t.selectedProvider===r.provider,onClick:l=>n("select",r.provider)},[e.createElementVNode("span",Se,[c[r.provider]?(e.openBlock(),e.createElementBlock("img",{key:0,src:c[r.provider],alt:"",class:"reevit-psp-option__logo-img",loading:"lazy"},null,8,Me)):(e.openBlock(),e.createElementBlock("span",Ne,e.toDisplayString(r.name.slice(0,1).toUpperCase()),1))]),e.createElementVNode("div",Ie,[e.createElementVNode("span",Be,e.toDisplayString(r.name),1),e.createElementVNode("span",Ve,e.toDisplayString(m(u(r.provider,r.methods))),1)])],10,Ce),t.selectedProvider===r.provider?(e.openBlock(),e.createElementBlock("div",Re,[e.createElementVNode("div",$e,[e.createVNode(Y,{methods:u(r.provider,r.methods),selected:t.selectedMethod||null,provider:r.provider,"show-label":!1,layout:"list",onSelect:p[0]||(p[0]=l=>n("methodSelect",l))},null,8,["methods","selected","provider"])]),e.renderSlot(s.$slots,"method-content")])):e.createCommentVNode("",!0)]))),128))])]))}}),Le={class:"reevit-form-group"},xe=["disabled"],Te={class:"reevit-network-selector"},Oe={class:"reevit-networks-grid"},Fe=["onClick","disabled"],De={key:0,class:"reevit-error-message"},Ue={class:"reevit-momo-form__actions"},Ae=["disabled"],je=["disabled"],ze={key:0,class:"reevit-spinner"},Ke={key:1},q=e.defineComponent({__name:"MobileMoneyForm",props:{initialPhone:{},loading:{type:Boolean},hideCancel:{type:Boolean}},emits:["submit","cancel"],setup(t,{emit:o}){const n=t,c=o,i=e.ref(n.initialPhone||""),m=e.ref(null),u=e.ref(null);e.watch(i,r=>{const l=k.detectNetwork(r);l&&(m.value=l),u.value&&(u.value=null)});const s=()=>{if(!k.validatePhone(i.value)){u.value="Please enter a valid phone number";return}if(!m.value){u.value="Please select your mobile network";return}c("submit",{phone:i.value,network:m.value})},p=[{id:"mtn",name:"MTN",color:"#FFCC00"},{id:"vodafone",name:"Vodafone",color:"#E60000"},{id:"airteltigo",name:"AirtelTigo",color:"#005596"}];return(r,l)=>(e.openBlock(),e.createElementBlock("form",{class:"reevit-momo-form",onSubmit:e.withModifiers(s,["prevent"])},[e.createElementVNode("div",Le,[l[2]||(l[2]=e.createElementVNode("label",{class:"reevit-label",for:"reevit-phone"},"Phone Number",-1)),e.withDirectives(e.createElementVNode("input",{id:"reevit-phone","onUpdate:modelValue":l[0]||(l[0]=h=>i.value=h),type:"tel",class:e.normalizeClass(["reevit-input",{"reevit-input--error":u.value&&!e.unref(k.validatePhone)(i.value)}]),placeholder:"e.g. 024 123 4567",disabled:t.loading,autocomplete:"tel"},null,10,xe),[[e.vModelText,i.value]])]),e.createElementVNode("div",Te,[l[3]||(l[3]=e.createElementVNode("label",{class:"reevit-label"},"Select Network",-1)),e.createElementVNode("div",Oe,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(p,h=>e.createElementVNode("button",{key:h.id,type:"button",class:e.normalizeClass(e.unref(k.cn)("reevit-network-btn",m.value===h.id&&"reevit-network-btn--selected")),onClick:I=>m.value=h.id,disabled:t.loading},[e.createElementVNode("div",{class:"reevit-network-dot",style:e.normalizeStyle({backgroundColor:h.color})},null,4),e.createTextVNode(" "+e.toDisplayString(h.name),1)],10,Fe)),64))])]),u.value?(e.openBlock(),e.createElementBlock("p",De,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ue,[t.hideCancel?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"reevit-btn reevit-btn--secondary",onClick:l[1]||(l[1]=h=>c("cancel")),disabled:t.loading}," Back ",8,Ae)),e.createElementVNode("button",{type:"submit",class:"reevit-btn reevit-btn--primary",disabled:t.loading||!i.value},[t.loading?(e.openBlock(),e.createElementBlock("span",ze)):(e.openBlock(),e.createElementBlock("span",Ke,"Continue"))],8,je)]),l[4]||(l[4]=e.createElementVNode("p",{class:"reevit-secure-text"}," 🔒 Secure mobile money payment via Reevit ",-1))],32))}});class He{constructor(o){this.baseUrl="https://unified-pay.hubtel.com",this.messageHandler=null,this.stylesInjected=!1,o&&(this.baseUrl=o)}redirect({purchaseInfo:o,config:n}){const c=this.createCheckoutUrl(o,n),i=window.open(c);if(!i||i.closed||typeof i.closed>"u")throw new Error("Popup was blocked by the browser. Please allow popups for this site.")}initIframe({purchaseInfo:o,callBacks:n,config:c,iframeStyle:i}){var m,u,s;this.registerEvents(n);const p=document.getElementById("hubtel-checkout-iframe");if(!p)throw new Error('Container element with id "hubtel-checkout-iframe" not found in the DOM.');p.innerHTML="";const r=document.createElement("div");r.textContent="Loading...",p.appendChild(r);const l=document.createElement("iframe");l.setAttribute("id","hubtel-iframe-element"),l.src=this.createCheckoutUrl(o,c),l.style.display="none",l.style.width=(m=i?.width)!==null&&m!==void 0?m:"100%",l.style.height=(u=i?.height)!==null&&u!==void 0?u:"100%",l.style.minHeight=i?.minHeight||"400px",l.style.border=(s=i?.border)!==null&&s!==void 0?s:"none",l.onload=()=>{var h;p.removeChild(r),l.style.display="block",(h=n.onLoad)===null||h===void 0||h.call(n)},p.appendChild(l)}openModal({purchaseInfo:o,callBacks:n,config:c}){this.injectStyles(),this.createIframe(),this.handleBackButton(),this.registerEvents(n),this.renderWebpageInPopup(this.createCheckoutUrl(o,c),n.onClose,n.onLoad)}createCheckoutUrl(o,n){const c=Object.assign(Object.assign({},o),n),i=Object.keys(c).reduce((r,l)=>(c[l]!==null&&c[l]!==void 0&&(r[l]=c[l]),r),{}),m=Object.keys(i).map(r=>`${r}=${encodeURIComponent(i[r])}`).join("&"),u=this.encodeBase64(m),s=encodeURIComponent(u);return`${i?.branding==="disabled"?`${this.baseUrl}/pay/direct`:`${this.baseUrl}/pay`}?p=${s}`}encodeBase64(o){return btoa(unescape(encodeURIComponent(o)))}handleBackButton(){window.addEventListener("popstate",()=>{this.closePopUp()})}createIframe(){const o=document.createElement("div");o.setAttribute("id","backdrop"),o.classList.add("backdrop");const n=document.createElement("span");n.classList.add("checkout-loader"),o.appendChild(n),document.body.appendChild(o)}registerEvents(o){this.messageHandler&&window.removeEventListener("message",this.messageHandler,!1);const n=c=>{var i,m,u,s,p,r;if(c.origin!==this.baseUrl)return;const{data:l}=c;if(l.success===!0)(i=o.onPaymentSuccess)===null||i===void 0||i.call(o,l);else if(l.success===!1)(m=o.onPaymentFailure)===null||m===void 0||m.call(o,l);else if(l.initialized)(u=o.init)===null||u===void 0||u.call(o,l),(s=o.onInit)===null||s===void 0||s.call(o,l);else if(l.feesChanged)(p=o.onFeesChanged)===null||p===void 0||p.call(o,l.fees);else if(l.resize){const h=document.getElementById("hubtel-iframe-element");h&&(h.style.height=l.height+"px"),(r=o?.onResize)===null||r===void 0||r.call(o,l)}};this.messageHandler=n,window.addEventListener("message",n,!1)}destroy(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler,!1),this.messageHandler=null)}renderWebpageInPopup(o,n,c){const i=document.createElement("div");i.classList.add("checkout-modal");const m=document.createElement("div");m.setAttribute("id","checkout-close-icon"),m.innerHTML="×",m.classList.add("close-icon"),m.addEventListener("click",()=>{this.closePopUp(),n?.()}),i.appendChild(m);const u=document.createElement("iframe");u.src=o,history.pushState({modalOpen:!0},""),u.classList.add("iframe"),i.appendChild(u),document.body.appendChild(i),i.style.opacity="0",u.addEventListener("load",()=>{i.style.opacity="1",c?.()})}closePopUp(){const o=document.querySelector(".backdrop"),n=document.querySelector(".checkout-modal");o&&document.body.removeChild(o),n&&document.body.removeChild(n),history.replaceState(null,""),window.removeEventListener("popstate",this.closePopUp)}injectStyles(){if(this.stylesInjected)return;const o=document.createElement("style");o.type="text/css",o.setAttribute("data-hubtel-checkout","true"),o.innerHTML=`
|
|
2
2
|
.backdrop {
|
|
3
3
|
position: fixed;
|
|
4
4
|
left: 0;
|
|
@@ -98,4 +98,4 @@
|
|
|
98
98
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
`,document.head.appendChild(o),this.stylesInjected=!0}}const O=new Map;function M(n,o){const t=O.get(o);if(t)return t;const l=new Promise((r,m)=>{if(document.getElementById(o)){r();return}const d=document.createElement("script");d.id=o,d.src=n,d.async=!0,d.onload=()=>r(),d.onerror=()=>m(new Error(`Failed to load ${o} script`)),document.head.appendChild(d)});return O.set(o,l),l}function F(){return M("https://js.paystack.co/v1/inline.js","paystack-script")}function ke(){return Promise.resolve()}function j(){return M("https://checkout.flutterwave.com/v3.js","flutterwave-script")}function A(){return M("https://js.stripe.com/v3/","stripe-script")}function z(){return M("https://sdk.monnify.com/plugin/monnify.js","monnify-script")}async function K(n){if(await F(),!window.PaystackPop)throw new Error("Paystack script not loaded");window.PaystackPop.setup({key:n.key,email:n.email,amount:n.amount,currency:n.currency,ref:n.ref,metadata:n.metadata,callback:n.onSuccess,onClose:n.onClose}).openIframe()}async function H(n){const o=new be,t={amount:n.amount,purchaseDescription:n.purchaseDescription,customerPhoneNumber:n.customerPhone||"",clientReference:`hubtel_${Date.now()}`},l={branding:"enabled",callbackUrl:n.callbackUrl||(typeof window<"u"?window.location.href:""),merchantAccount:typeof n.clientId=="string"?parseInt(n.clientId,10):n.clientId,basicAuth:n.basicAuth||""};o.openModal({purchaseInfo:t,config:l,callBacks:{onPaymentSuccess:r=>{n.onSuccess(r),o.closePopUp()},onPaymentFailure:()=>{n.onClose()},onClose:()=>{n.onClose()}}})}async function q(n){if(await j(),!window.FlutterwaveCheckout)throw new Error("Flutterwave script not loaded");window.FlutterwaveCheckout({public_key:n.public_key,tx_ref:n.tx_ref,amount:n.amount,currency:n.currency,customer:n.customer,payment_options:n.payment_options,customizations:n.customizations,callback:n.callback,onclose:n.onclose})}async function Y(n){if(await A(),!window.Stripe)throw new Error("Stripe.js not loaded");return window.Stripe(n)}async function Ee(n){const t=await(await Y(n.publishableKey)).confirmPayment({elements:n.elements,clientSecret:n.clientSecret,redirect:"if_required"});t.error?n.onError({message:t.error.message||"Payment failed"}):t.paymentIntent&&n.onSuccess({paymentIntentId:t.paymentIntent.id,status:t.paymentIntent.status})}async function W(n){if(await z(),!window.MonnifySDK)throw new Error("Monnify SDK not loaded");window.MonnifySDK.initialize({amount:n.amount,currency:n.currency,reference:n.reference,customerName:n.customerName,customerEmail:n.customerEmail,customerMobileNumber:n.customerPhone,apiKey:n.apiKey,contractCode:n.contractCode,paymentDescription:n.paymentDescription||"Payment",isTestMode:n.isTestMode??!1,metadata:n.metadata,onComplete:o=>{o.status==="SUCCESS"?n.onSuccess({transactionReference:o.transactionReference,paymentReference:o.paymentReference,...o}):n.onError?.({message:o.message||"Payment failed"})},onClose:n.onClose})}async function G(n,o){n.onInitiated();try{const t=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phone_number:n.phoneNumber,amount:n.amount,reference:n.reference,description:n.description})});if(!t.ok){const m=(await t.json().catch(()=>({}))).message||"Failed to initiate M-Pesa payment";return n.onError({message:m}),{status:"failed",message:m}}const l=await t.json();return{status:"initiated",message:"Please check your phone and enter your M-Pesa PIN to complete the payment.",transactionId:l.checkout_request_id||l.transaction_id}}catch(t){const l=t instanceof Error?t.message:"Network error";return n.onError({message:l}),{status:"failed",message:l}}}const we=["disabled"],Pe={key:0,class:"reevit-spinner"},Ce={class:"reevit-modal-body"},Se={key:0,class:"reevit-loading-state"},_e={key:1,class:"reevit-error-state"},ge={key:2,class:"reevit-success-state"},Ie={key:1,class:"reevit-method-form-container"},Ne={key:2,class:"reevit-card-info"},Me=["disabled"],Re={key:0,class:"reevit-spinner"},Ve={key:1},Be=e.defineComponent({__name:"ReevitCheckout",props:{publicKey:{},amount:{},currency:{},email:{},phone:{},reference:{},metadata:{},paymentMethods:{},theme:{},isOpen:{type:Boolean},apiBaseUrl:{},initialPaymentIntent:{}},emits:["success","error","close"],setup(n,{emit:o}){const t=n,l=o,{status:r,paymentIntent:m,selectedMethod:d,error:i,isLoading:p,isReady:u,initialize:a,selectMethod:h,handlePspSuccess:E,handlePspError:P,close:R}=L({config:{publicKey:t.publicKey,amount:t.amount,currency:t.currency,email:t.email,phone:t.phone,reference:t.reference,metadata:t.metadata,paymentMethods:t.paymentMethods,initialPaymentIntent:t.initialPaymentIntent},apiBaseUrl:t.apiBaseUrl,onSuccess:c=>l("success",c),onError:c=>l("error",c),onClose:()=>l("close")}),w=e.ref(t.isOpen??!1);e.watch(()=>t.isOpen,c=>{c!==void 0&&(w.value=c)});const I=()=>{w.value=!0,!m.value&&r.value==="idle"&&a()};e.watch([w,m,d],([c,s,y])=>{c&&s&&y&&y==="card"&&S(null)});const C=()=>{w.value=!1,R()},V=c=>{h(c)},S=async c=>{const s=m.value;if(!s)return;const y=s.recommendedPsp;try{if(y==="paystack")await K({key:t.publicKey,email:t.email||"",amount:t.amount,currency:t.currency,ref:s.id,onSuccess:f=>E(f),onClose:()=>{}});else if(y==="hubtel")await H({clientId:s.pspCredentials?.merchantAccount||t.publicKey,purchaseDescription:`Payment for ${t.amount} ${t.currency}`,amount:t.amount,customerPhone:c?.phone||t.phone,customerEmail:t.email,basicAuth:s.pspCredentials?.basicAuth,onSuccess:f=>E(f),onClose:()=>{}});else if(y==="flutterwave")await q({public_key:t.publicKey,tx_ref:s.id,amount:t.amount,currency:t.currency,customer:{email:t.email||"",phone_number:c?.phone||t.phone},callback:f=>E(f),onclose:()=>{}});else if(y==="monnify")await W({apiKey:s.pspPublicKey||t.publicKey,contractCode:t.metadata?.contract_code||t.publicKey,amount:t.amount,currency:t.currency,reference:s.reference||s.id,customerName:t.metadata?.customer_name||t.email||"",customerEmail:t.email||"",customerPhone:c?.phone||t.phone,metadata:t.metadata,onSuccess:f=>E(f),onClose:()=>{}});else if(y==="mpesa"){const f=`${t.apiBaseUrl||"https://api.reevit.io"}/v1/payments/${s.id}/mpesa`;await G({phoneNumber:c?.phone||t.phone||"",amount:t.amount,reference:s.reference||s.id,description:`Payment ${s.reference||""}`,onInitiated:()=>{},onSuccess:k=>E(k),onError:k=>P({code:"MPESA_ERROR",message:k.message})},f)}else P(y==="stripe"?{code:"STRIPE_NOT_IMPLEMENTED",message:"Stripe integration requires custom Elements setup. Please use the React SDK or implement custom Stripe Elements."}:{code:"UNSUPPORTED_PSP",message:`Payment provider "${y}" is not supported in this checkout.`})}catch(f){P({code:"BRIDGE_ERROR",message:f instanceof Error?f.message:"Failed to open payment gateway"})}},B=e.computed(()=>v.createThemeVariables(t.theme||{}));e.watch(w,c=>{c?document.body.style.overflow="hidden":document.body.style.overflow=""}),e.onUnmounted(()=>{document.body.style.overflow=""});const b=e.computed(()=>r.value),N=e.computed(()=>i.value),_=e.computed(()=>d.value),g=e.computed(()=>p.value),T=e.computed(()=>u.value);return(c,s)=>(e.openBlock(),e.createElementBlock("div",{class:"reevit-sdk-container",style:e.normalizeStyle(B.value)},[e.renderSlot(c.$slots,"default",{open:I,isLoading:g.value},()=>[e.createElementVNode("button",{type:"button",class:"reevit-pay-button",onClick:I,disabled:g.value},[g.value?(e.openBlock(),e.createElementBlock("span",Pe)):e.renderSlot(c.$slots,"button-text",{key:1},()=>[s[1]||(s[1]=e.createTextVNode("Pay Now",-1))])],8,we)]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[w.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"reevit-modal-overlay",onClick:e.withModifiers(C,["self"])},[e.createElementVNode("div",{class:e.normalizeClass(["reevit-modal-content",{"reevit-modal--dark":t.theme?.darkMode}])},[e.createElementVNode("button",{class:"reevit-modal-close",onClick:C,"aria-label":"Close"}," × "),s[9]||(s[9]=e.createElementVNode("div",{class:"reevit-modal-header"},[e.createElementVNode("img",{src:"https://i.imgur.com/bzUR5Lm.png",alt:"Reevit",class:"reevit-modal__logo"})],-1)),e.createElementVNode("div",Ce,[b.value==="loading"?(e.openBlock(),e.createElementBlock("div",Se,[...s[2]||(s[2]=[e.createElementVNode("div",{class:"reevit-spinner reevit-spinner--large"},null,-1),e.createElementVNode("p",null,"Initializing payment...",-1)])])):b.value==="failed"&&N.value?(e.openBlock(),e.createElementBlock("div",_e,[s[3]||(s[3]=e.createElementVNode("div",{class:"reevit-error-icon"},"⚠️",-1)),s[4]||(s[4]=e.createElementVNode("h3",null,"Payment Failed",-1)),e.createElementVNode("p",null,e.toDisplayString(N.value.message),1),e.createElementVNode("button",{class:"reevit-retry-btn",onClick:s[0]||(s[0]=y=>e.unref(a)())},"Retry")])):b.value==="success"?(e.openBlock(),e.createElementBlock("div",ge,[s[5]||(s[5]=e.createElementVNode("div",{class:"reevit-success-icon"},"✅",-1)),s[6]||(s[6]=e.createElementVNode("h3",null,"Payment Successful",-1)),s[7]||(s[7]=e.createElementVNode("p",null,"Thank you for your payment.",-1)),e.createElementVNode("button",{class:"reevit-done-btn",onClick:C},"Done")])):T.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[b.value==="ready"||b.value==="method_selected"||b.value==="processing"?(e.openBlock(),e.createBlock(D,{key:0,methods:t.paymentMethods||["card","mobile_money"],selected:_.value,amount:t.amount,currency:t.currency,provider:c.psp,onSelect:V},null,8,["methods","selected","amount","currency","provider"])):e.createCommentVNode("",!0),(b.value==="method_selected"||b.value==="processing")&&_.value==="mobile_money"?(e.openBlock(),e.createElementBlock("div",Ie,[e.createVNode(U,{"initial-phone":t.phone,loading:b.value==="processing",onSubmit:S},null,8,["initial-phone","loading"])])):e.createCommentVNode("",!0),(b.value==="method_selected"||b.value==="processing")&&_.value==="card"?(e.openBlock(),e.createElementBlock("div",Ne,[s[8]||(s[8]=e.createElementVNode("p",{class:"reevit-info-text"},"You will be redirected to our secure payment partner to complete your card payment.",-1)),e.createElementVNode("button",{class:"reevit-submit-btn",onClick:S,disabled:b.value==="processing"},[b.value==="processing"?(e.openBlock(),e.createElementBlock("span",Re)):(e.openBlock(),e.createElementBlock("span",Ve,"Proceed to Card Payment"))],8,Me)])):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)]),s[10]||(s[10]=e.createElementVNode("div",{class:"reevit-modal-footer"},[e.createElementVNode("div",{class:"reevit-trust-badges"},[e.createElementVNode("span",null,"PCI DSS Compliant"),e.createElementVNode("span",null,"•"),e.createElementVNode("span",null,"SSL Secure")])],-1))],2)])):e.createCommentVNode("",!0)]))],4))}});Object.defineProperty(exports,"ReevitAPIClient",{enumerable:!0,get:()=>v.ReevitAPIClient});Object.defineProperty(exports,"cn",{enumerable:!0,get:()=>v.cn});Object.defineProperty(exports,"createReevitClient",{enumerable:!0,get:()=>v.createReevitClient});Object.defineProperty(exports,"detectCountryFromCurrency",{enumerable:!0,get:()=>v.detectCountryFromCurrency});Object.defineProperty(exports,"detectNetwork",{enumerable:!0,get:()=>v.detectNetwork});Object.defineProperty(exports,"formatAmount",{enumerable:!0,get:()=>v.formatAmount});Object.defineProperty(exports,"formatPhone",{enumerable:!0,get:()=>v.formatPhone});Object.defineProperty(exports,"validatePhone",{enumerable:!0,get:()=>v.validatePhone});exports.MobileMoneyForm=U;exports.PaymentMethodSelector=D;exports.ReevitCheckout=Be;exports.confirmStripePayment=Ee;exports.createStripeInstance=Y;exports.initiateMPesaSTKPush=G;exports.loadFlutterwaveScript=j;exports.loadHubtelScript=ke;exports.loadMonnifyScript=z;exports.loadPaystackScript=F;exports.loadStripeScript=A;exports.openFlutterwaveModal=q;exports.openHubtelPopup=H;exports.openMonnifyModal=W;exports.openPaystackPopup=K;exports.useReevit=L;
|
|
101
|
+
`,document.head.appendChild(o),this.stylesInjected=!0}}const G=new Map;function z(t,o){const n=G.get(o);if(n)return n;const c=new Promise((i,m)=>{if(document.getElementById(o)){i();return}const u=document.createElement("script");u.id=o,u.src=t,u.async=!0,u.onload=()=>i(),u.onerror=()=>m(new Error(`Failed to load ${o} script`)),document.head.appendChild(u)});return G.set(o,c),c}function Q(){return z("https://js.paystack.co/v1/inline.js","paystack-script")}function qe(){return Promise.resolve()}function X(){return z("https://checkout.flutterwave.com/v3.js","flutterwave-script")}function Z(){return z("https://js.stripe.com/v3/","stripe-script")}function ee(){return z("https://sdk.monnify.com/plugin/monnify.js","monnify-script")}async function te(t){if(await Q(),!window.PaystackPop)throw new Error("Paystack script not loaded");window.PaystackPop.setup({key:t.key,email:t.email,amount:t.amount,currency:t.currency,ref:t.ref,metadata:t.metadata,callback:t.onSuccess,onClose:t.onClose}).openIframe()}async function oe(t){const o=new He,n=t.preferredMethod==="mobile_money"?"momo":t.preferredMethod==="card"?"card":void 0,c={amount:t.amount,purchaseDescription:t.purchaseDescription,customerPhoneNumber:t.customerPhone||"",clientReference:`hubtel_${Date.now()}`,...n?{paymentMethod:n}:{}},i=t.hubtelSessionToken||t.basicAuth||"",m={branding:"enabled",callbackUrl:t.callbackUrl||(typeof window<"u"?window.location.href:""),merchantAccount:typeof t.clientId=="string"?parseInt(t.clientId,10):t.clientId,basicAuth:i,...n?{paymentMethod:n}:{}};o.openModal({purchaseInfo:c,config:m,callBacks:{onPaymentSuccess:u=>{t.onSuccess(u),o.closePopUp()},onPaymentFailure:()=>{t.onClose()},onClose:()=>{t.onClose()}}})}async function ne(t){if(await X(),!window.FlutterwaveCheckout)throw new Error("Flutterwave script not loaded");window.FlutterwaveCheckout({public_key:t.public_key,tx_ref:t.tx_ref,amount:t.amount,currency:t.currency,customer:t.customer,payment_options:t.payment_options,customizations:t.customizations,callback:t.callback,onclose:t.onclose})}async function re(t){if(await Z(),!window.Stripe)throw new Error("Stripe.js not loaded");return window.Stripe(t)}async function Ye(t){const n=await(await re(t.publishableKey)).confirmPayment({elements:t.elements,clientSecret:t.clientSecret,redirect:"if_required"});n.error?t.onError({message:n.error.message||"Payment failed"}):n.paymentIntent&&t.onSuccess({paymentIntentId:n.paymentIntent.id,status:n.paymentIntent.status})}async function ae(t){if(await ee(),!window.MonnifySDK)throw new Error("Monnify SDK not loaded");window.MonnifySDK.initialize({amount:t.amount,currency:t.currency,reference:t.reference,customerName:t.customerName,customerEmail:t.customerEmail,customerMobileNumber:t.customerPhone,apiKey:t.apiKey,contractCode:t.contractCode,paymentDescription:t.paymentDescription||"Payment",isTestMode:t.isTestMode??!1,metadata:t.metadata,onComplete:o=>{o.status==="SUCCESS"?t.onSuccess({transactionReference:o.transactionReference,paymentReference:o.paymentReference,...o}):t.onError?.({message:o.message||"Payment failed"})},onClose:t.onClose})}async function se(t,o){t.onInitiated();try{const n=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phone_number:t.phoneNumber,amount:t.amount,reference:t.reference,description:t.description})});if(!n.ok){const m=(await n.json().catch(()=>({}))).message||"Failed to initiate M-Pesa payment";return t.onError({message:m}),{status:"failed",message:m}}const c=await n.json();return{status:"initiated",message:"Please check your phone and enter your M-Pesa PIN to complete the payment.",transactionId:c.checkout_request_id||c.transaction_id}}catch(n){const c=n instanceof Error?n.message:"Network error";return t.onError({message:c}),{status:"failed",message:c}}}const Ge=["disabled"],Je={key:0,class:"reevit-spinner"},We={class:"reevit-modal-header"},Qe=["src"],Xe={class:"reevit-modal-body"},Ze={key:0,class:"reevit-loading-state"},et={key:1,class:"reevit-error-state"},tt={key:2,class:"reevit-success-state"},ot={key:3,class:"reevit-method-step reevit-animate-slide-up"},nt={key:0,class:"reevit-inline-action reevit-animate-fade-in"},rt=["disabled"],at={key:1,class:"reevit-inline-action reevit-animate-fade-in"},st={class:"reevit-inline-action__hint"},it=["disabled"],lt={key:0,class:"reevit-method-step__actions reevit-animate-slide-up"},ct={key:0},dt={key:1,class:"reevit-card-info reevit-animate-fade-in"},ut={class:"reevit-info-text"},mt=["disabled"],pt={key:0,class:"reevit-spinner"},vt={key:1},yt=e.defineComponent({__name:"ReevitCheckout",props:{publicKey:{},amount:{},currency:{},email:{},phone:{},customerName:{},reference:{},metadata:{},customFields:{},paymentLinkCode:{},paymentMethods:{},theme:{},isOpen:{type:Boolean},apiBaseUrl:{},initialPaymentIntent:{}},emits:["success","error","close"],setup(t,{emit:o}){const n=t,c=o,{status:i,paymentIntent:m,selectedMethod:u,error:s,isLoading:p,isReady:r,initialize:l,selectMethod:h,handlePspSuccess:I,handlePspError:B,close:K,reset:U}=J({config:{publicKey:n.publicKey,amount:n.amount,currency:n.currency,email:n.email,phone:n.phone,customerName:n.customerName,reference:n.reference,metadata:n.metadata,customFields:n.customFields,paymentLinkCode:n.paymentLinkCode,paymentMethods:n.paymentMethods,initialPaymentIntent:n.initialPaymentIntent},apiBaseUrl:n.apiBaseUrl,onSuccess:d=>c("success",d),onError:d=>c("error",d),onClose:()=>c("close")}),V=e.ref(n.isOpen??!1),g=e.ref(null),F={hubtel:"Hubtel",paystack:"Paystack",flutterwave:"Flutterwave",monnify:"Monnify",mpesa:"M-Pesa",stripe:"Stripe"};e.watch(()=>n.isOpen,d=>{d!==void 0&&(V.value=d)});const A=()=>{V.value=!0,g.value=null,!m.value&&i.value==="idle"&&l()};e.watch([V,m,u],([d,a,b])=>{if(d&&a&&b){const v=(g.value||a.recommendedPsp||"paystack").toLowerCase().includes("mpesa");(b==="card"||b==="mobile_money"&&(!v||n.phone))&&f(null)}});const D=()=>{V.value=!1,K(),g.value=null},R=e.computed(()=>n.paymentMethods?.length?n.paymentMethods:["card","mobile_money"]),$=e.computed(()=>{const d=m.value;if(!d)return[];const a=new Set(R.value),b=(d.availableProviders||[]).map(v=>{const x=v.provider.toLowerCase().includes("hubtel")?v.methods.filter(O=>O==="card"||O==="mobile_money"):v.methods;return{...v,methods:x.filter(O=>a.has(O))}}).filter(v=>v.methods.length>0);if(b.length>0)return b;const _=d.recommendedPsp.toLowerCase().includes("hubtel")?R.value.filter(v=>v==="card"||v==="mobile_money"):R.value;return[{provider:d.recommendedPsp,name:F[d.recommendedPsp]||d.recommendedPsp,methods:_}]}),w=e.computed(()=>{const d=m.value;return g.value||d?.recommendedPsp||"paystack"}),j=e.computed(()=>{const d=$.value.find(a=>a.provider===w.value);return d?.methods.length?d.methods:R.value});e.watch(()=>$.value,d=>{d.length&&(g.value&&d.some(a=>a.provider===g.value)||(d.length===1?g.value=d[0].provider:g.value=null))},{immediate:!0}),e.watch([j,u],([d,a])=>{!a||d.length===0||d.includes(a)||h(d[0])});const H=d=>{if(d===g.value){g.value=null,U();return}const a=$.value.find(v=>v.provider===d),b=a?.methods.length?a.methods:R.value,_=u.value&&b.includes(u.value)?u.value:b[0];g.value=d,U(),l(_,{preferredProvider:d,allowedProviders:[d]})},y=d=>{h(d)},f=async d=>{const a=m.value;if(!a)return;const b=w.value;try{if(b==="paystack")await te({key:a.pspPublicKey||n.publicKey||"",email:n.email||"",amount:n.amount,currency:n.currency,ref:a.id,onSuccess:_=>I(_),onClose:()=>{}});else if(b==="hubtel"){const _=k.createReevitClient({publicKey:n.publicKey,baseUrl:n.apiBaseUrl}),{data:v,error:x}=await _.createHubtelSession(a.id,a.clientSecret);if(x||!v?.basicAuth){B({code:x?.code||"hubtel_session_error",message:x?.message||"Failed to create Hubtel session"});return}const O=P.value==="card"||P.value==="mobile_money"?P.value:void 0;await oe({clientId:v.merchantAccount||a.pspCredentials?.merchantAccount||n.publicKey||"",purchaseDescription:`Payment for ${n.amount} ${n.currency}`,amount:n.amount,customerPhone:d?.phone||n.phone,customerEmail:n.email,basicAuth:v.basicAuth,preferredMethod:O,onSuccess:ie=>I(ie),onClose:()=>{}})}else if(b==="flutterwave")await ne({public_key:a.pspPublicKey||n.publicKey||"",tx_ref:a.id,amount:n.amount,currency:n.currency,customer:{email:n.email||"",phone_number:d?.phone||n.phone},callback:_=>I(_),onclose:()=>{}});else if(b==="monnify"){const _=a.pspPublicKey||n.publicKey||"",v=n.metadata?.contract_code||n.publicKey||"";if(!_||!v){B({code:"MONNIFY_CONFIG_MISSING",message:"Monnify configuration is missing. Please check your API key and contract code."});return}await ae({apiKey:_,contractCode:v,amount:n.amount,currency:n.currency,reference:a.reference||a.id,customerName:n.metadata?.customer_name||n.email||"",customerEmail:n.email||"",customerPhone:d?.phone||n.phone,metadata:n.metadata,onSuccess:x=>I(x),onClose:()=>{}})}else if(b==="mpesa"){const _=`${n.apiBaseUrl||"https://api.reevit.io"}/v1/payments/${a.id}/mpesa`;await se({phoneNumber:d?.phone||n.phone||"",amount:n.amount,reference:a.reference||a.id,description:`Payment ${a.reference||""}`,onInitiated:()=>{},onSuccess:v=>I(v),onError:v=>B({code:"MPESA_ERROR",message:v.message})},_)}else B(b==="stripe"?{code:"STRIPE_NOT_IMPLEMENTED",message:"Stripe integration requires custom Elements setup. Please use the React SDK or implement custom Stripe Elements."}:{code:"UNSUPPORTED_PSP",message:`Payment provider "${b}" is not supported in this checkout.`})}catch(_){B({code:"BRIDGE_ERROR",message:_ instanceof Error?_.message:"Failed to open payment gateway"})}},E=e.computed(()=>({...m.value?.branding||{},...n.theme||{}})),C=e.computed(()=>k.createThemeVariables(E.value)),M=e.computed(()=>E.value?.darkMode);e.watch(V,d=>{d?document.body.style.overflow="hidden":document.body.style.overflow=""}),e.onUnmounted(()=>{document.body.style.overflow=""});const S=e.computed(()=>i.value),L=e.computed(()=>s.value),P=e.computed(()=>u.value),T=e.computed(()=>p.value),N=e.computed(()=>r.value);return(d,a)=>(e.openBlock(),e.createElementBlock("div",{class:"reevit-sdk-container",style:e.normalizeStyle(C.value)},[e.renderSlot(d.$slots,"default",{open:A,isLoading:T.value},()=>[e.createElementVNode("button",{type:"button",class:"reevit-pay-button",onClick:A,disabled:T.value},[T.value?(e.openBlock(),e.createElementBlock("span",Je)):e.renderSlot(d.$slots,"button-text",{key:1},()=>[a[5]||(a[5]=e.createTextVNode("Pay Now",-1))])],8,Ge)]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[V.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"reevit-modal-overlay",onClick:e.withModifiers(D,["self"])},[e.createElementVNode("div",{class:e.normalizeClass(["reevit-modal-content",{"reevit-modal--dark":M.value}]),style:e.normalizeStyle(C.value)},[e.createElementVNode("button",{class:"reevit-modal-close",onClick:D,"aria-label":"Close"}," × "),e.createElementVNode("div",We,[e.createElementVNode("img",{src:E.value.logoUrl||"https://i.imgur.com/bzUR5Lm.png",alt:"Checkout",class:"reevit-modal__logo"},null,8,Qe)]),e.createElementVNode("div",Xe,[S.value==="loading"?(e.openBlock(),e.createElementBlock("div",Ze,[...a[6]||(a[6]=[e.createElementVNode("div",{class:"reevit-spinner reevit-spinner--large"},null,-1),e.createElementVNode("p",null,"Initializing payment...",-1)])])):S.value==="failed"&&L.value?(e.openBlock(),e.createElementBlock("div",et,[a[7]||(a[7]=e.createElementVNode("div",{class:"reevit-error-icon"},"⚠️",-1)),a[8]||(a[8]=e.createElementVNode("h3",null,"Payment Failed",-1)),e.createElementVNode("p",null,e.toDisplayString(L.value.message),1),e.createElementVNode("button",{class:"reevit-retry-btn",onClick:a[0]||(a[0]=b=>e.unref(l)())},"Retry")])):S.value==="success"?(e.openBlock(),e.createElementBlock("div",tt,[a[9]||(a[9]=e.createElementVNode("div",{class:"reevit-success-icon"},"✅",-1)),a[10]||(a[10]=e.createElementVNode("h3",null,"Payment Successful",-1)),a[11]||(a[11]=e.createElementVNode("p",null,"Thank you for your payment.",-1)),e.createElementVNode("button",{class:"reevit-done-btn",onClick:D},"Done")])):N.value?(e.openBlock(),e.createElementBlock("div",ot,[$.value.length>1?(e.openBlock(),e.createBlock(W,{key:0,providers:$.value,"selected-provider":g.value,disabled:T.value,theme:E.value,"selected-method":P.value,onSelect:H,onMethodSelect:y},{"method-content":e.withCtx(()=>[P.value==="card"?(e.openBlock(),e.createElementBlock("div",nt,[a[12]||(a[12]=e.createElementVNode("p",{class:"reevit-inline-action__hint"}," You'll be redirected to complete your card payment securely. ",-1)),e.createElementVNode("button",{class:"reevit-btn reevit-btn--primary",onClick:a[1]||(a[1]=b=>f(null)),disabled:S.value==="processing"}," Pay with Card ",8,rt)])):P.value==="mobile_money"?(e.openBlock(),e.createElementBlock("div",at,[w.value.includes("mpesa")&&!n.phone?(e.openBlock(),e.createBlock(q,{key:0,"initial-phone":n.phone,loading:S.value==="processing","hide-cancel":"",onSubmit:f},null,8,["initial-phone","loading"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("p",st,e.toDisplayString(w.value.includes("hubtel")?"Opens the Hubtel checkout with Mobile Money selected.":`Continue to pay securely with Mobile Money via ${F[w.value]||w.value}.`),1),e.createElementVNode("button",{class:"reevit-btn reevit-btn--primary",onClick:a[2]||(a[2]=b=>f(null)),disabled:S.value==="processing"},e.toDisplayString(w.value.includes("hubtel")?"Continue with Hubtel":"Pay with Mobile Money"),9,it)],64))])):e.createCommentVNode("",!0)]),_:1},8,["providers","selected-provider","disabled","theme","selected-method"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(Y,{methods:j.value,selected:P.value,provider:w.value,"show-label":!1,layout:"grid",onSelect:y},null,8,["methods","selected","provider"]),P.value?(e.openBlock(),e.createElementBlock("div",lt,[P.value==="mobile_money"&&w.value.includes("mpesa")&&!n.phone?(e.openBlock(),e.createElementBlock("div",ct,[e.createVNode(q,{"initial-phone":n.phone,loading:S.value==="processing",onSubmit:f,onCancel:a[3]||(a[3]=b=>e.unref(h)(null))},null,8,["initial-phone","loading"])])):(e.openBlock(),e.createElementBlock("div",dt,[e.createElementVNode("p",ut,e.toDisplayString(P.value==="card"?"You will be redirected to complete your card payment securely.":w.value.includes("hubtel")?"Opens the Hubtel checkout with Mobile Money selected.":`Continue to pay securely via ${F[w.value]||w.value}.`),1),e.createElementVNode("button",{class:"reevit-submit-btn",onClick:a[4]||(a[4]=b=>f(null)),disabled:S.value==="processing"},[S.value==="processing"?(e.openBlock(),e.createElementBlock("span",pt)):(e.openBlock(),e.createElementBlock("span",vt,e.toDisplayString(P.value==="card"?"Pay with Card":w.value.includes("hubtel")?"Continue with Hubtel":"Pay with Mobile Money"),1))],8,mt)]))])):e.createCommentVNode("",!0)],64))])):e.createCommentVNode("",!0)]),a[13]||(a[13]=e.createElementVNode("div",{class:"reevit-modal-footer"},[e.createElementVNode("div",{class:"reevit-trust-badges"},[e.createElementVNode("span",null,"PCI DSS Compliant"),e.createElementVNode("span",null,"•"),e.createElementVNode("span",null,"SSL Secure")])],-1))],6)])):e.createCommentVNode("",!0)]))],4))}});Object.defineProperty(exports,"ReevitAPIClient",{enumerable:!0,get:()=>k.ReevitAPIClient});Object.defineProperty(exports,"cn",{enumerable:!0,get:()=>k.cn});Object.defineProperty(exports,"createReevitClient",{enumerable:!0,get:()=>k.createReevitClient});Object.defineProperty(exports,"detectCountryFromCurrency",{enumerable:!0,get:()=>k.detectCountryFromCurrency});Object.defineProperty(exports,"detectNetwork",{enumerable:!0,get:()=>k.detectNetwork});Object.defineProperty(exports,"formatAmount",{enumerable:!0,get:()=>k.formatAmount});Object.defineProperty(exports,"formatPhone",{enumerable:!0,get:()=>k.formatPhone});Object.defineProperty(exports,"validatePhone",{enumerable:!0,get:()=>k.validatePhone});exports.MobileMoneyForm=q;exports.PaymentMethodSelector=Y;exports.ProviderSelector=W;exports.ReevitCheckout=yt;exports.confirmStripePayment=Ye;exports.createStripeInstance=re;exports.initiateMPesaSTKPush=se;exports.loadFlutterwaveScript=X;exports.loadHubtelScript=qe;exports.loadMonnifyScript=ee;exports.loadPaystackScript=Q;exports.loadStripeScript=Z;exports.openFlutterwaveModal=ne;exports.openHubtelPopup=oe;exports.openMonnifyModal=ae;exports.openPaystackPopup=te;exports.useReevit=J;
|