@reevit/vue 0.3.2 → 0.3.4
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/components/MobileMoneyForm.vue.d.ts +1 -1
- package/dist/components/PaymentMethodSelector.vue.d.ts +1 -1
- package/dist/components/ReevitCheckout.vue.d.ts +1 -1
- package/dist/components/ReevitCheckout.vue.d.ts.map +1 -1
- package/dist/composables/useReevit.d.ts +7 -1
- package/dist/composables/useReevit.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +312 -273
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReevitCheckout.vue.d.ts","sourceRoot":"","sources":["../../src/components/ReevitCheckout.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ReevitCheckout.vue.d.ts","sourceRoot":"","sources":["../../src/components/ReevitCheckout.vue"],"names":[],"mappings":"AAiTA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAahD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,cAAc,GAAG,eAAe,CAAC,EAAE,CAAC;IAC/D,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,GAAG,CAAC;CAC5B,CAAC;AAoLF,iBAAS,cAAc;WAqNT,OAAO,IAA6B;;;;;YAXrB,GAAG;+BACG,GAAG;;;;EAerC;AAuBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;6FAQnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReevitCheckoutConfig, CheckoutState, PaymentMethod, PaymentResult, PaymentError, PSPType } from '../../../core/
|
|
1
|
+
import { ReevitCheckoutConfig, CheckoutState, PaymentMethod, PaymentResult, PaymentError, PSPType } from '../../../core/src/index.ts';
|
|
2
2
|
interface UseReevitOptions {
|
|
3
3
|
config: ReevitCheckoutConfig;
|
|
4
4
|
onSuccess?: (result: PaymentResult) => void;
|
|
@@ -76,6 +76,9 @@ export declare function useReevit(options: UseReevitOptions): {
|
|
|
76
76
|
readonly metadata?: {
|
|
77
77
|
readonly [x: string]: Readonly<unknown>;
|
|
78
78
|
} | undefined;
|
|
79
|
+
readonly source?: import('../../../core/src/index.ts').PaymentSource | undefined;
|
|
80
|
+
readonly sourceId?: string | undefined;
|
|
81
|
+
readonly sourceDescription?: string | undefined;
|
|
79
82
|
} | null, {
|
|
80
83
|
readonly paymentId: string;
|
|
81
84
|
readonly reference: string;
|
|
@@ -88,6 +91,9 @@ export declare function useReevit(options: UseReevitOptions): {
|
|
|
88
91
|
readonly metadata?: {
|
|
89
92
|
readonly [x: string]: Readonly<unknown>;
|
|
90
93
|
} | undefined;
|
|
94
|
+
readonly source?: import('../../../core/src/index.ts').PaymentSource | undefined;
|
|
95
|
+
readonly sourceId?: string | undefined;
|
|
96
|
+
readonly sourceDescription?: string | undefined;
|
|
91
97
|
} | null>>;
|
|
92
98
|
initialize: (method?: PaymentMethod) => Promise<void>;
|
|
93
99
|
selectMethod: (method: PaymentMethod) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReevit.d.ts","sourceRoot":"","sources":["../../src/composables/useReevit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EAKjB,KAAK,OAAO,EACb,MAAM,cAAc,CAAC;AAEtB,UAAU,gBAAgB;IACxB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAuCD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB
|
|
1
|
+
{"version":3,"file":"useReevit.d.ts","sourceRoot":"","sources":["../../src/composables/useReevit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EAKjB,KAAK,OAAO,EACb,MAAM,cAAc,CAAC;AAEtB,UAAU,gBAAgB;IACxB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAuCD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAwCd,aAAa;2BA8ClB,aAAa;kCAKA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gCA8DzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;4BAKjC,YAAY;;;;;;;EAgE5C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { default as ReevitCheckout } from './components/ReevitCheckout.vue';
|
|
|
2
2
|
export { default as PaymentMethodSelector } from './components/PaymentMethodSelector.vue';
|
|
3
3
|
export { default as MobileMoneyForm } from './components/MobileMoneyForm.vue';
|
|
4
4
|
export { useReevit } from './composables';
|
|
5
|
-
export type { PaymentMethod, MobileMoneyNetwork, ReevitCheckoutConfig, ReevitCheckoutCallbacks, CheckoutState, PaymentResult, PaymentError, ReevitTheme, MobileMoneyFormData, PaymentIntent, PSPType, } from '../../core/
|
|
6
|
-
export { formatAmount, validatePhone, detectNetwork, formatPhone, detectCountryFromCurrency, cn, ReevitAPIClient, createReevitClient, } from '../../core/
|
|
5
|
+
export type { PaymentMethod, MobileMoneyNetwork, ReevitCheckoutConfig, ReevitCheckoutCallbacks, CheckoutState, PaymentResult, PaymentError, ReevitTheme, MobileMoneyFormData, PaymentIntent, PSPType, PaymentSource, } from '../../core/src/index.ts';
|
|
6
|
+
export { formatAmount, validatePhone, detectNetwork, formatPhone, detectCountryFromCurrency, cn, ReevitAPIClient, createReevitClient, } from '../../core/src/index.ts';
|
|
7
7
|
export { loadPaystackScript, loadHubtelScript, loadFlutterwaveScript, loadStripeScript, loadMonnifyScript, openPaystackPopup, openHubtelPopup, openFlutterwaveModal, createStripeInstance, confirmStripePayment, openMonnifyModal, initiateMPesaSTKPush, type PaystackConfig, type HubtelConfig, type FlutterwaveConfig, type StripeConfig, type MonnifyConfig, type MPesaConfig, type MPesaSTKPushResult, } from './bridges';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,cAAc,CAAC;AAGtB,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,cAAc,CAAC;AAGtB,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,yBAAyB,EACzB,EAAE,EACF,eAAe,EACf,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EAGpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),d=require("@reevit/core");function Q(t){const l=t.toLowerCase();return l.includes("paystack")?"paystack":l.includes("hubtel")?"hubtel":l.includes("flutterwave")?"flutterwave":"paystack"}function W(t,l){return{id:t.id,clientSecret:t.client_secret,pspPublicKey:t.psp_public_key,amount:t.amount,currency:t.currency,status:t.status,recommendedPsp:Q(t.provider),availableMethods:l.paymentMethods||["card","mobile_money"],reference:t.reference||l.reference,connectionId:t.connection_id,provider:t.provider,feeAmount:t.fee_amount,feeCurrency:t.fee_currency,netAmount:t.net_amount,metadata:l.metadata}}function F(t){const{config:l,onSuccess:n,onError:s,onClose:p,onStateChange:i,apiBaseUrl:u}=t,o=e.ref(d.createInitialState());if(l.initialPaymentIntent){const r=l.initialPaymentIntent;o.value={...o.value,status:"ready",paymentIntent:r,selectedMethod:r.availableMethods?.length===1?r.availableMethods[0]:null}}const k=new d.ReevitAPIClient({publicKey:l.publicKey,baseUrl:u}),m=r=>{o.value=d.reevitReducer(o.value,r)};e.watch(()=>o.value.status,r=>{i?.(r)});const y=async r=>{m({type:"INIT_START"});try{const a=l.reference||d.generateReference(),c=d.detectCountryFromCurrency(l.currency),_=r||l.paymentMethods?.[0]||"card",{data:f,error:O}=await k.createPaymentIntent({...l,reference:a},_,c);if(O){m({type:"INIT_ERROR",payload:O}),s?.(O);return}if(!f){const $={code:"INIT_FAILED",message:"No data received from API",recoverable:!0};m({type:"INIT_ERROR",payload:$}),s?.($);return}const J=W(f,{...l,reference:a});m({type:"INIT_SUCCESS",payload:J})}catch(a){const c={code:"INIT_FAILED",message:a instanceof Error?a.message:"Failed to initialize checkout",recoverable:!0,originalError:a};m({type:"INIT_ERROR",payload:c}),s?.(c)}},h=r=>{m({type:"SELECT_METHOD",payload:r})},E=async r=>{if(!(!o.value.paymentIntent||!o.value.selectedMethod)){m({type:"PROCESS_START"});try{let a;if(o.value.paymentIntent.clientSecret){const{data:_,error:f}=await k.confirmPaymentIntent(o.value.paymentIntent.id,o.value.paymentIntent.clientSecret);if(f){m({type:"PROCESS_ERROR",payload:f}),s?.(f);return}a=_}else{const{data:_,error:f}=await k.confirmPayment(o.value.paymentIntent.id);if(f){m({type:"PROCESS_ERROR",payload:f}),s?.(f);return}a=_}const c={paymentId:o.value.paymentIntent.id,reference:r.reference||o.value.paymentIntent.reference||o.value.paymentIntent.metadata?.reference||"",amount:o.value.paymentIntent.amount,currency:o.value.paymentIntent.currency,paymentMethod:o.value.selectedMethod,psp:o.value.paymentIntent.recommendedPsp,pspReference:r.pspReference||a?.provider_ref_id||"",status:"success",metadata:r};m({type:"PROCESS_SUCCESS",payload:c}),n?.(c)}catch(a){const c={code:"PAYMENT_FAILED",message:a instanceof Error?a.message:"Payment failed",recoverable:!0,originalError:a};m({type:"PROCESS_ERROR",payload:c}),s?.(c)}}},R=async r=>{await E(r)},V=r=>{m({type:"PROCESS_ERROR",payload:r}),s?.(r)},b=()=>{m({type:"RESET"})},I=async()=>{if(o.value.paymentIntent&&o.value.status!=="success")try{await k.cancelPaymentIntent(o.value.paymentIntent.id)}catch{}m({type:"CLOSE"}),p?.()},S=e.computed(()=>o.value.status),B=e.computed(()=>o.value.paymentIntent),P=e.computed(()=>o.value.selectedMethod),g=e.computed(()=>o.value.error),v=e.computed(()=>o.value.result),M=e.computed(()=>o.value.status==="loading"||o.value.status==="processing"),w=e.computed(()=>o.value.status==="ready"||o.value.status==="method_selected"||o.value.status==="processing"),C=e.computed(()=>o.value.status==="success"),T=e.computed(()=>o.value.error?.recoverable??!1);return{status:e.readonly(S),paymentIntent:e.readonly(B),selectedMethod:e.readonly(P),error:e.readonly(g),result:e.readonly(v),initialize:y,selectMethod:h,processPayment:E,handlePspSuccess:R,handlePspError:V,reset:b,close:I,isLoading:e.readonly(M),isReady:e.readonly(w),isComplete:e.readonly(C),canRetry:e.readonly(T)}}const X={class:"reevit-method-selector"},Z={class:"reevit-amount-display"},ee={class:"reevit-methods-grid"},te=["onClick"],ne={class:"reevit-method-icon"},oe={class:"reevit-method-info"},ae={class:"reevit-method-name"},re={class:"reevit-method-description"},le={class:"reevit-method-radio"},se={key:0,class:"reevit-radio-inner"},j=e.defineComponent({__name:"PaymentMethodSelector",props:{methods:{},selected:{},amount:{},currency:{}},emits:["select"],setup(t,{emit:l}){const n=t,s=l,p=e.computed(()=>[{id:"card",name:"Card",description:"Visa, Mastercard, Maestro",icon:"💳"},{id:"mobile_money",name:"Mobile Money",description:"MTN, Vodafone, AirtelTigo",icon:"📱"},{id:"bank_transfer",name:"Bank Transfer",description:"Transfer directly from your bank",icon:"🏦"}].filter(i=>n.methods.includes(i.id)));return(i,u)=>(e.openBlock(),e.createElementBlock("div",X,[u[0]||(u[0]=e.createElementVNode("h3",{class:"reevit-section-title"},"Select Payment Method",-1)),e.createElementVNode("p",Z," Pay "+e.toDisplayString(e.unref(d.formatAmount)(t.amount,t.currency)),1),e.createElementVNode("div",ee,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,o=>(e.openBlock(),e.createElementBlock("button",{key:o.id,type:"button",class:e.normalizeClass(e.unref(d.cn)("reevit-method-card",t.selected===o.id&&"reevit-method-card--selected")),onClick:k=>s("select",o.id)},[e.createElementVNode("span",ne,e.toDisplayString(o.icon),1),e.createElementVNode("div",oe,[e.createElementVNode("span",ae,e.toDisplayString(o.name),1),e.createElementVNode("span",re,e.toDisplayString(o.description),1)]),e.createElementVNode("div",le,[t.selected===o.id?(e.openBlock(),e.createElementBlock("div",se)):e.createCommentVNode("",!0)])],10,te))),128))])]))}}),ce={class:"reevit-form-group"},ie=["disabled"],ue={class:"reevit-network-selector"},de={class:"reevit-networks-grid"},me=["onClick","disabled"],pe={key:0,class:"reevit-error-message"},ye=["disabled"],ve={key:0,class:"reevit-spinner"},he={key:1},A=e.defineComponent({__name:"MobileMoneyForm",props:{initialPhone:{},loading:{type:Boolean}},emits:["submit"],setup(t,{emit:l}){const n=t,s=l,p=e.ref(n.initialPhone||""),i=e.ref(null),u=e.ref(null);e.watch(p,m=>{const y=d.detectNetwork(m);y&&(i.value=y),u.value&&(u.value=null)});const o=()=>{if(!d.validatePhone(p.value)){u.value="Please enter a valid phone number";return}if(!i.value){u.value="Please select your mobile network";return}s("submit",{phone:p.value,network:i.value})},k=[{id:"mtn",name:"MTN",color:"#FFCC00"},{id:"vodafone",name:"Vodafone",color:"#E60000"},{id:"airteltigo",name:"AirtelTigo",color:"#005596"}];return(m,y)=>(e.openBlock(),e.createElementBlock("form",{class:"reevit-momo-form",onSubmit:e.withModifiers(o,["prevent"])},[e.createElementVNode("div",ce,[y[1]||(y[1]=e.createElementVNode("label",{class:"reevit-label",for:"reevit-phone"},"Phone Number",-1)),e.withDirectives(e.createElementVNode("input",{id:"reevit-phone","onUpdate:modelValue":y[0]||(y[0]=h=>p.value=h),type:"tel",class:e.normalizeClass(["reevit-input",{"reevit-input--error":u.value&&!e.unref(d.validatePhone)(p.value)}]),placeholder:"e.g. 024 123 4567",disabled:t.loading,autocomplete:"tel"},null,10,ie),[[e.vModelText,p.value]])]),e.createElementVNode("div",ue,[y[2]||(y[2]=e.createElementVNode("label",{class:"reevit-label"},"Select Network",-1)),e.createElementVNode("div",de,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(k,h=>e.createElementVNode("button",{key:h.id,type:"button",class:e.normalizeClass(e.unref(d.cn)("reevit-network-btn",i.value===h.id&&"reevit-network-btn--selected")),onClick:E=>i.value=h.id,disabled:t.loading},[e.createElementVNode("div",{class:"reevit-network-dot",style:e.normalizeStyle({backgroundColor:h.color})},null,4),e.createTextVNode(" "+e.toDisplayString(h.name),1)],10,me)),64))])]),u.value?(e.openBlock(),e.createElementBlock("p",pe,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"submit",class:"reevit-submit-btn",disabled:t.loading||!p.value},[t.loading?(e.openBlock(),e.createElementBlock("span",ve)):(e.openBlock(),e.createElementBlock("span",he,"Continue"))],8,ye),y[3]||(y[3]=e.createElementVNode("p",{class:"reevit-secure-text"}," 🔒 Secure mobile money payment via Reevit ",-1))],32))}}),D=new Map;function N(t,l){const n=D.get(l);if(n)return n;const s=new Promise((p,i)=>{if(document.getElementById(l)){p();return}const u=document.createElement("script");u.id=l,u.src=t,u.async=!0,u.onload=()=>p(),u.onerror=()=>i(new Error(`Failed to load ${l} script`)),document.head.appendChild(u)});return D.set(l,s),s}function K(){return N("https://js.paystack.co/v1/inline.js","paystack-script")}function L(){return N("https://checkout.hubtel.com/js/hubtel-checkout.js","hubtel-script")}function z(){return N("https://checkout.flutterwave.com/v3.js","flutterwave-script")}function U(){return N("https://js.stripe.com/v3/","stripe-script")}function x(){return N("https://sdk.monnify.com/plugin/monnify.js","monnify-script")}async function H(t){if(await K(),!window.PaystackPop)throw new Error("Paystack script not loaded");window.PaystackPop.setup({key:t.key,email:t.email,amount:t.amount,currency:t.currency,ref:t.ref,metadata:t.metadata,callback:t.onSuccess,onClose:t.onClose}).openIframe()}async function q(t){if(await L(),!window.HubtelCheckout)throw new Error("Hubtel script not loaded");window.HubtelCheckout.initPay({clientId:t.clientId,purchaseDescription:t.purchaseDescription,amount:t.amount,callbackUrl:t.callbackUrl,customerPhone:t.customerPhone,customerEmail:t.customerEmail,onSuccess:t.onSuccess,onClose:t.onClose})}async function Y(t){if(await z(),!window.FlutterwaveCheckout)throw new Error("Flutterwave script not loaded");window.FlutterwaveCheckout({public_key:t.public_key,tx_ref:t.tx_ref,amount:t.amount,currency:t.currency,customer:t.customer,payment_options:t.payment_options,customizations:t.customizations,callback:t.callback,onclose:t.onclose})}async function G(t){if(await U(),!window.Stripe)throw new Error("Stripe.js not loaded");return window.Stripe(t)}async function fe(t){const n=await(await G(t.publishableKey)).confirmPayment({elements:t.elements,clientSecret:t.clientSecret,redirect:"if_required"});n.error?t.onError({message:n.error.message||"Payment failed"}):n.paymentIntent&&t.onSuccess({paymentIntentId:n.paymentIntent.id,status:n.paymentIntent.status})}async function ke(t){if(await x(),!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:l=>{l.status==="SUCCESS"?t.onSuccess({transactionReference:l.transactionReference,paymentReference:l.paymentReference,...l}):t.onError?.({message:l.message||"Payment failed"})},onClose:t.onClose})}async function be(t,l){t.onInitiated();try{const n=await fetch(l,{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 i=(await n.json().catch(()=>({}))).message||"Failed to initiate M-Pesa payment";return t.onError({message:i}),{status:"failed",message:i}}const s=await n.json();return{status:"initiated",message:"Please check your phone and enter your M-Pesa PIN to complete the payment.",transactionId:s.checkout_request_id||s.transaction_id}}catch(n){const s=n instanceof Error?n.message:"Network error";return t.onError({message:s}),{status:"failed",message:s}}}const Ee=["disabled"],Se={key:0,class:"reevit-spinner"},Pe={class:"reevit-modal-body"},we={key:0,class:"reevit-loading-state"},Ce={key:1,class:"reevit-error-state"},_e={key:2,class:"reevit-success-state"},Ne={key:1,class:"reevit-method-form-container"},Ie={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(t,{emit:l}){const n=t,s=l,{status:p,paymentIntent:i,selectedMethod:u,error:o,isLoading:k,isReady:m,initialize:y,selectMethod:h,handlePspSuccess:E,handlePspError:R,close:V}=F({config:{publicKey:n.publicKey,amount:n.amount,currency:n.currency,email:n.email,phone:n.phone,reference:n.reference,metadata:n.metadata,paymentMethods:n.paymentMethods,initialPaymentIntent:n.initialPaymentIntent},apiBaseUrl:n.apiBaseUrl,onSuccess:r=>s("success",r),onError:r=>s("error",r),onClose:()=>s("close")}),b=e.ref(n.isOpen??!1);e.watch(()=>n.isOpen,r=>{r!==void 0&&(b.value=r)});const I=()=>{b.value=!0,!i.value&&p.value==="idle"&&y()};e.watch([b,i,u],([r,a,c])=>{r&&a&&c&&c==="card"&&P(null)});const S=()=>{b.value=!1,V()},B=r=>{h(r)},P=async r=>{if(!i.value)return;const a=i.value.recommendedPsp;try{a==="paystack"?await H({key:n.publicKey,email:n.email||"",amount:n.amount,currency:n.currency,ref:i.value.id,onSuccess:c=>E(c),onClose:()=>{}}):a==="hubtel"?await q({clientId:n.publicKey,purchaseDescription:`Payment for ${n.amount} ${n.currency}`,amount:n.amount,customerPhone:r?.phone||n.phone,customerEmail:n.email,onSuccess:c=>E(c),onClose:()=>{}}):a==="flutterwave"&&await Y({public_key:n.publicKey,tx_ref:i.value.id,amount:n.amount,currency:n.currency,customer:{email:n.email||"",phone_number:r?.phone||n.phone},callback:c=>E(c),onclose:()=>{}})}catch(c){R({code:"BRIDGE_ERROR",message:c instanceof Error?c.message:"Failed to open payment gateway"})}},g=e.computed(()=>d.createThemeVariables(n.theme||{}));e.watch(b,r=>{r?document.body.style.overflow="hidden":document.body.style.overflow=""}),e.onUnmounted(()=>{document.body.style.overflow=""});const v=e.computed(()=>p.value),M=e.computed(()=>o.value),w=e.computed(()=>u.value),C=e.computed(()=>k.value),T=e.computed(()=>m.value);return(r,a)=>(e.openBlock(),e.createElementBlock("div",{class:"reevit-sdk-container",style:e.normalizeStyle(g.value)},[e.renderSlot(r.$slots,"default",{open:I,isLoading:C.value},()=>[e.createElementVNode("button",{type:"button",class:"reevit-pay-button",onClick:I,disabled:C.value},[C.value?(e.openBlock(),e.createElementBlock("span",Se)):e.renderSlot(r.$slots,"button-text",{key:1},()=>[a[1]||(a[1]=e.createTextVNode("Pay Now",-1))])],8,Ee)]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[b.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"reevit-modal-overlay",onClick:e.withModifiers(S,["self"])},[e.createElementVNode("div",{class:e.normalizeClass(["reevit-modal-content",{"reevit-modal--dark":n.theme?.darkMode}])},[e.createElementVNode("button",{class:"reevit-modal-close",onClick:S,"aria-label":"Close"}," × "),a[9]||(a[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",Pe,[v.value==="loading"?(e.openBlock(),e.createElementBlock("div",we,[...a[2]||(a[2]=[e.createElementVNode("div",{class:"reevit-spinner reevit-spinner--large"},null,-1),e.createElementVNode("p",null,"Initializing payment...",-1)])])):v.value==="failed"&&M.value?(e.openBlock(),e.createElementBlock("div",Ce,[a[3]||(a[3]=e.createElementVNode("div",{class:"reevit-error-icon"},"⚠️",-1)),a[4]||(a[4]=e.createElementVNode("h3",null,"Payment Failed",-1)),e.createElementVNode("p",null,e.toDisplayString(M.value.message),1),e.createElementVNode("button",{class:"reevit-retry-btn",onClick:a[0]||(a[0]=c=>e.unref(y)())},"Retry")])):v.value==="success"?(e.openBlock(),e.createElementBlock("div",_e,[a[5]||(a[5]=e.createElementVNode("div",{class:"reevit-success-icon"},"✅",-1)),a[6]||(a[6]=e.createElementVNode("h3",null,"Payment Successful",-1)),a[7]||(a[7]=e.createElementVNode("p",null,"Thank you for your payment.",-1)),e.createElementVNode("button",{class:"reevit-done-btn",onClick:S},"Done")])):T.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[v.value==="ready"||v.value==="method_selected"||v.value==="processing"?(e.openBlock(),e.createBlock(j,{key:0,methods:n.paymentMethods||["card","mobile_money"],selected:w.value,amount:n.amount,currency:n.currency,onSelect:B},null,8,["methods","selected","amount","currency"])):e.createCommentVNode("",!0),(v.value==="method_selected"||v.value==="processing")&&w.value==="mobile_money"?(e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(A,{"initial-phone":n.phone,loading:v.value==="processing",onSubmit:P},null,8,["initial-phone","loading"])])):e.createCommentVNode("",!0),(v.value==="method_selected"||v.value==="processing")&&w.value==="card"?(e.openBlock(),e.createElementBlock("div",Ie,[a[8]||(a[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:P,disabled:v.value==="processing"},[v.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)]),a[10]||(a[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:()=>d.ReevitAPIClient});Object.defineProperty(exports,"cn",{enumerable:!0,get:()=>d.cn});Object.defineProperty(exports,"createReevitClient",{enumerable:!0,get:()=>d.createReevitClient});Object.defineProperty(exports,"detectCountryFromCurrency",{enumerable:!0,get:()=>d.detectCountryFromCurrency});Object.defineProperty(exports,"detectNetwork",{enumerable:!0,get:()=>d.detectNetwork});Object.defineProperty(exports,"formatAmount",{enumerable:!0,get:()=>d.formatAmount});Object.defineProperty(exports,"formatPhone",{enumerable:!0,get:()=>d.formatPhone});Object.defineProperty(exports,"validatePhone",{enumerable:!0,get:()=>d.validatePhone});exports.MobileMoneyForm=A;exports.PaymentMethodSelector=j;exports.ReevitCheckout=Be;exports.confirmStripePayment=fe;exports.createStripeInstance=G;exports.initiateMPesaSTKPush=be;exports.loadFlutterwaveScript=z;exports.loadHubtelScript=L;exports.loadMonnifyScript=x;exports.loadPaystackScript=K;exports.loadStripeScript=U;exports.openFlutterwaveModal=Y;exports.openHubtelPopup=q;exports.openMonnifyModal=ke;exports.openPaystackPopup=H;exports.useReevit=F;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),d=require("@reevit/core");function X(t){const s=t.toLowerCase();return s.includes("paystack")?"paystack":s.includes("hubtel")?"hubtel":s.includes("flutterwave")?"flutterwave":"paystack"}function Z(t,s){return{id:t.id,clientSecret:t.client_secret,pspPublicKey:t.psp_public_key,amount:t.amount,currency:t.currency,status:t.status,recommendedPsp:X(t.provider),availableMethods:s.paymentMethods||["card","mobile_money"],reference:t.reference||s.reference,connectionId:t.connection_id,provider:t.provider,feeAmount:t.fee_amount,feeCurrency:t.fee_currency,netAmount:t.net_amount,metadata:s.metadata}}function F(t){const{config:s,onSuccess:n,onError:i,onClose:p,onStateChange:l,apiBaseUrl:u}=t,a=e.ref(d.createInitialState());if(s.initialPaymentIntent){const r=s.initialPaymentIntent;a.value={...a.value,status:"ready",paymentIntent:r,selectedMethod:r.availableMethods?.length===1?r.availableMethods[0]:null}}const b=new d.ReevitAPIClient({publicKey:s.publicKey,baseUrl:u}),m=r=>{a.value=d.reevitReducer(a.value,r)};e.watch(()=>a.value.status,r=>{l?.(r)});const y=async r=>{m({type:"INIT_START"});try{const o=s.reference||d.generateReference(),c=d.detectCountryFromCurrency(s.currency),E=r||s.paymentMethods?.[0]||"card",{data:f,error:O}=await b.createPaymentIntent({...s,reference:o},E,c);if(O){m({type:"INIT_ERROR",payload:O}),i?.(O);return}if(!f){const $={code:"INIT_FAILED",message:"No data received from API",recoverable:!0};m({type:"INIT_ERROR",payload:$}),i?.($);return}const W=Z(f,{...s,reference:o});m({type:"INIT_SUCCESS",payload:W})}catch(o){const c={code:"INIT_FAILED",message:o instanceof Error?o.message:"Failed to initialize checkout",recoverable:!0,originalError:o};m({type:"INIT_ERROR",payload:c}),i?.(c)}},h=r=>{m({type:"SELECT_METHOD",payload:r})},k=async r=>{if(!(!a.value.paymentIntent||!a.value.selectedMethod)){m({type:"PROCESS_START"});try{let o;if(a.value.paymentIntent.clientSecret){const{data:E,error:f}=await b.confirmPaymentIntent(a.value.paymentIntent.id,a.value.paymentIntent.clientSecret);if(f){m({type:"PROCESS_ERROR",payload:f}),i?.(f);return}o=E}else{const{data:E,error:f}=await b.confirmPayment(a.value.paymentIntent.id);if(f){m({type:"PROCESS_ERROR",payload:f}),i?.(f);return}o=E}const c={paymentId:a.value.paymentIntent.id,reference:r.reference||a.value.paymentIntent.reference||a.value.paymentIntent.metadata?.reference||"",amount:a.value.paymentIntent.amount,currency:a.value.paymentIntent.currency,paymentMethod:a.value.selectedMethod,psp:a.value.paymentIntent.recommendedPsp,pspReference:r.pspReference||o?.provider_ref_id||"",status:"success",metadata:r};m({type:"PROCESS_SUCCESS",payload:c}),n?.(c)}catch(o){const c={code:"PAYMENT_FAILED",message:o instanceof Error?o.message:"Payment failed",recoverable:!0,originalError:o};m({type:"PROCESS_ERROR",payload:c}),i?.(c)}}},S=async r=>{await k(r)},V=r=>{m({type:"PROCESS_ERROR",payload:r}),i?.(r)},P=()=>{m({type:"RESET"})},M=async()=>{if(a.value.paymentIntent&&a.value.status!=="success")try{await b.cancelPaymentIntent(a.value.paymentIntent.id)}catch{}m({type:"CLOSE"}),p?.()},w=e.computed(()=>a.value.status),B=e.computed(()=>a.value.paymentIntent),C=e.computed(()=>a.value.selectedMethod),g=e.computed(()=>a.value.error),v=e.computed(()=>a.value.result),R=e.computed(()=>a.value.status==="loading"||a.value.status==="processing"),_=e.computed(()=>a.value.status==="ready"||a.value.status==="method_selected"||a.value.status==="processing"),N=e.computed(()=>a.value.status==="success"),T=e.computed(()=>a.value.error?.recoverable??!1);return{status:e.readonly(w),paymentIntent:e.readonly(B),selectedMethod:e.readonly(C),error:e.readonly(g),result:e.readonly(v),initialize:y,selectMethod:h,processPayment:k,handlePspSuccess:S,handlePspError:V,reset:P,close:M,isLoading:e.readonly(R),isReady:e.readonly(_),isComplete:e.readonly(N),canRetry:e.readonly(T)}}const ee={class:"reevit-method-selector"},te={class:"reevit-amount-display"},ne={class:"reevit-methods-grid"},oe=["onClick"],ae={class:"reevit-method-icon"},re={class:"reevit-method-info"},se={class:"reevit-method-name"},le={class:"reevit-method-description"},ce={class:"reevit-method-radio"},ie={key:0,class:"reevit-radio-inner"},K=e.defineComponent({__name:"PaymentMethodSelector",props:{methods:{},selected:{},amount:{},currency:{}},emits:["select"],setup(t,{emit:s}){const n=t,i=s,p=e.computed(()=>[{id:"card",name:"Card",description:"Visa, Mastercard, Maestro",icon:"💳"},{id:"mobile_money",name:"Mobile Money",description:"MTN, Vodafone, AirtelTigo",icon:"📱"},{id:"bank_transfer",name:"Bank Transfer",description:"Transfer directly from your bank",icon:"🏦"}].filter(l=>n.methods.includes(l.id)));return(l,u)=>(e.openBlock(),e.createElementBlock("div",ee,[u[0]||(u[0]=e.createElementVNode("h3",{class:"reevit-section-title"},"Select Payment Method",-1)),e.createElementVNode("p",te," Pay "+e.toDisplayString(e.unref(d.formatAmount)(t.amount,t.currency)),1),e.createElementVNode("div",ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,a=>(e.openBlock(),e.createElementBlock("button",{key:a.id,type:"button",class:e.normalizeClass(e.unref(d.cn)("reevit-method-card",t.selected===a.id&&"reevit-method-card--selected")),onClick:b=>i("select",a.id)},[e.createElementVNode("span",ae,e.toDisplayString(a.icon),1),e.createElementVNode("div",re,[e.createElementVNode("span",se,e.toDisplayString(a.name),1),e.createElementVNode("span",le,e.toDisplayString(a.description),1)]),e.createElementVNode("div",ce,[t.selected===a.id?(e.openBlock(),e.createElementBlock("div",ie)):e.createCommentVNode("",!0)])],10,oe))),128))])]))}}),ue={class:"reevit-form-group"},de=["disabled"],me={class:"reevit-network-selector"},pe={class:"reevit-networks-grid"},ye=["onClick","disabled"],ve={key:0,class:"reevit-error-message"},he=["disabled"],fe={key:0,class:"reevit-spinner"},be={key:1},j=e.defineComponent({__name:"MobileMoneyForm",props:{initialPhone:{},loading:{type:Boolean}},emits:["submit"],setup(t,{emit:s}){const n=t,i=s,p=e.ref(n.initialPhone||""),l=e.ref(null),u=e.ref(null);e.watch(p,m=>{const y=d.detectNetwork(m);y&&(l.value=y),u.value&&(u.value=null)});const a=()=>{if(!d.validatePhone(p.value)){u.value="Please enter a valid phone number";return}if(!l.value){u.value="Please select your mobile network";return}i("submit",{phone:p.value,network:l.value})},b=[{id:"mtn",name:"MTN",color:"#FFCC00"},{id:"vodafone",name:"Vodafone",color:"#E60000"},{id:"airteltigo",name:"AirtelTigo",color:"#005596"}];return(m,y)=>(e.openBlock(),e.createElementBlock("form",{class:"reevit-momo-form",onSubmit:e.withModifiers(a,["prevent"])},[e.createElementVNode("div",ue,[y[1]||(y[1]=e.createElementVNode("label",{class:"reevit-label",for:"reevit-phone"},"Phone Number",-1)),e.withDirectives(e.createElementVNode("input",{id:"reevit-phone","onUpdate:modelValue":y[0]||(y[0]=h=>p.value=h),type:"tel",class:e.normalizeClass(["reevit-input",{"reevit-input--error":u.value&&!e.unref(d.validatePhone)(p.value)}]),placeholder:"e.g. 024 123 4567",disabled:t.loading,autocomplete:"tel"},null,10,de),[[e.vModelText,p.value]])]),e.createElementVNode("div",me,[y[2]||(y[2]=e.createElementVNode("label",{class:"reevit-label"},"Select Network",-1)),e.createElementVNode("div",pe,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(b,h=>e.createElementVNode("button",{key:h.id,type:"button",class:e.normalizeClass(e.unref(d.cn)("reevit-network-btn",l.value===h.id&&"reevit-network-btn--selected")),onClick:k=>l.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,ye)),64))])]),u.value?(e.openBlock(),e.createElementBlock("p",ve,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"submit",class:"reevit-submit-btn",disabled:t.loading||!p.value},[t.loading?(e.openBlock(),e.createElementBlock("span",fe)):(e.openBlock(),e.createElementBlock("span",be,"Continue"))],8,he),y[3]||(y[3]=e.createElementVNode("p",{class:"reevit-secure-text"}," 🔒 Secure mobile money payment via Reevit ",-1))],32))}}),D=new Map;function I(t,s){const n=D.get(s);if(n)return n;const i=new Promise((p,l)=>{if(document.getElementById(s)){p();return}const u=document.createElement("script");u.id=s,u.src=t,u.async=!0,u.onload=()=>p(),u.onerror=()=>l(new Error(`Failed to load ${s} script`)),document.head.appendChild(u)});return D.set(s,i),i}function A(){return I("https://js.paystack.co/v1/inline.js","paystack-script")}function L(){return I("https://checkout-v3.hubtel.com/js/checkout.js","hubtel-script")}function U(){return I("https://checkout.flutterwave.com/v3.js","flutterwave-script")}function z(){return I("https://js.stripe.com/v3/","stripe-script")}function x(){return I("https://sdk.monnify.com/plugin/monnify.js","monnify-script")}async function H(t){if(await A(),!window.PaystackPop)throw new Error("Paystack script not loaded");window.PaystackPop.setup({key:t.key,email:t.email,amount:t.amount,currency:t.currency,ref:t.ref,metadata:t.metadata,callback:t.onSuccess,onClose:t.onClose}).openIframe()}async function q(t){if(await L(),!window.HubtelCheckout)throw new Error("Hubtel script not loaded");window.HubtelCheckout.initPay({clientId:t.clientId,purchaseDescription:t.purchaseDescription,amount:t.amount,callbackUrl:t.callbackUrl,customerPhone:t.customerPhone,customerEmail:t.customerEmail,onSuccess:t.onSuccess,onClose:t.onClose})}async function Y(t){if(await U(),!window.FlutterwaveCheckout)throw new Error("Flutterwave script not loaded");window.FlutterwaveCheckout({public_key:t.public_key,tx_ref:t.tx_ref,amount:t.amount,currency:t.currency,customer:t.customer,payment_options:t.payment_options,customizations:t.customizations,callback:t.callback,onclose:t.onclose})}async function G(t){if(await z(),!window.Stripe)throw new Error("Stripe.js not loaded");return window.Stripe(t)}async function ke(t){const n=await(await G(t.publishableKey)).confirmPayment({elements:t.elements,clientSecret:t.clientSecret,redirect:"if_required"});n.error?t.onError({message:n.error.message||"Payment failed"}):n.paymentIntent&&t.onSuccess({paymentIntentId:n.paymentIntent.id,status:n.paymentIntent.status})}async function J(t){if(await x(),!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:s=>{s.status==="SUCCESS"?t.onSuccess({transactionReference:s.transactionReference,paymentReference:s.paymentReference,...s}):t.onError?.({message:s.message||"Payment failed"})},onClose:t.onClose})}async function Q(t,s){t.onInitiated();try{const n=await fetch(s,{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 l=(await n.json().catch(()=>({}))).message||"Failed to initiate M-Pesa payment";return t.onError({message:l}),{status:"failed",message:l}}const i=await n.json();return{status:"initiated",message:"Please check your phone and enter your M-Pesa PIN to complete the payment.",transactionId:i.checkout_request_id||i.transaction_id}}catch(n){const i=n instanceof Error?n.message:"Network error";return t.onError({message:i}),{status:"failed",message:i}}}const Ee=["disabled"],Pe={key:0,class:"reevit-spinner"},Se={class:"reevit-modal-body"},we={key:0,class:"reevit-loading-state"},Ce={key:1,class:"reevit-error-state"},_e={key:2,class:"reevit-success-state"},Ne={key:1,class:"reevit-method-form-container"},Ie={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(t,{emit:s}){const n=t,i=s,{status:p,paymentIntent:l,selectedMethod:u,error:a,isLoading:b,isReady:m,initialize:y,selectMethod:h,handlePspSuccess:k,handlePspError:S,close:V}=F({config:{publicKey:n.publicKey,amount:n.amount,currency:n.currency,email:n.email,phone:n.phone,reference:n.reference,metadata:n.metadata,paymentMethods:n.paymentMethods,initialPaymentIntent:n.initialPaymentIntent},apiBaseUrl:n.apiBaseUrl,onSuccess:r=>i("success",r),onError:r=>i("error",r),onClose:()=>i("close")}),P=e.ref(n.isOpen??!1);e.watch(()=>n.isOpen,r=>{r!==void 0&&(P.value=r)});const M=()=>{P.value=!0,!l.value&&p.value==="idle"&&y()};e.watch([P,l,u],([r,o,c])=>{r&&o&&c&&c==="card"&&C(null)});const w=()=>{P.value=!1,V()},B=r=>{h(r)},C=async r=>{if(!l.value)return;const o=l.value.recommendedPsp;try{if(o==="paystack")await H({key:n.publicKey,email:n.email||"",amount:n.amount,currency:n.currency,ref:l.value.id,onSuccess:c=>k(c),onClose:()=>{}});else if(o==="hubtel")await q({clientId:n.publicKey,purchaseDescription:`Payment for ${n.amount} ${n.currency}`,amount:n.amount,customerPhone:r?.phone||n.phone,customerEmail:n.email,onSuccess:c=>k(c),onClose:()=>{}});else if(o==="flutterwave")await Y({public_key:n.publicKey,tx_ref:l.value.id,amount:n.amount,currency:n.currency,customer:{email:n.email||"",phone_number:r?.phone||n.phone},callback:c=>k(c),onclose:()=>{}});else if(o==="monnify")await J({apiKey:l.value.pspPublicKey||n.publicKey,contractCode:n.metadata?.contract_code||n.publicKey,amount:n.amount,currency:n.currency,reference:l.value.reference||l.value.id,customerName:n.metadata?.customer_name||n.email||"",customerEmail:n.email||"",customerPhone:r?.phone||n.phone,metadata:n.metadata,onSuccess:c=>k(c),onClose:()=>{}});else if(o==="mpesa"){const c=`${n.apiBaseUrl||"https://api.reevit.io"}/v1/payments/${l.value.id}/mpesa`;await Q({phoneNumber:r?.phone||n.phone||"",amount:n.amount,reference:l.value.reference||l.value.id,description:`Payment ${l.value.reference||""}`,onInitiated:()=>{},onSuccess:E=>k(E),onError:E=>S({code:"MPESA_ERROR",message:E.message})},c)}else S(o==="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 "${o}" is not supported in this checkout.`})}catch(c){S({code:"BRIDGE_ERROR",message:c instanceof Error?c.message:"Failed to open payment gateway"})}},g=e.computed(()=>d.createThemeVariables(n.theme||{}));e.watch(P,r=>{r?document.body.style.overflow="hidden":document.body.style.overflow=""}),e.onUnmounted(()=>{document.body.style.overflow=""});const v=e.computed(()=>p.value),R=e.computed(()=>a.value),_=e.computed(()=>u.value),N=e.computed(()=>b.value),T=e.computed(()=>m.value);return(r,o)=>(e.openBlock(),e.createElementBlock("div",{class:"reevit-sdk-container",style:e.normalizeStyle(g.value)},[e.renderSlot(r.$slots,"default",{open:M,isLoading:N.value},()=>[e.createElementVNode("button",{type:"button",class:"reevit-pay-button",onClick:M,disabled:N.value},[N.value?(e.openBlock(),e.createElementBlock("span",Pe)):e.renderSlot(r.$slots,"button-text",{key:1},()=>[o[1]||(o[1]=e.createTextVNode("Pay Now",-1))])],8,Ee)]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[P.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"reevit-modal-overlay",onClick:e.withModifiers(w,["self"])},[e.createElementVNode("div",{class:e.normalizeClass(["reevit-modal-content",{"reevit-modal--dark":n.theme?.darkMode}])},[e.createElementVNode("button",{class:"reevit-modal-close",onClick:w,"aria-label":"Close"}," × "),o[9]||(o[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",Se,[v.value==="loading"?(e.openBlock(),e.createElementBlock("div",we,[...o[2]||(o[2]=[e.createElementVNode("div",{class:"reevit-spinner reevit-spinner--large"},null,-1),e.createElementVNode("p",null,"Initializing payment...",-1)])])):v.value==="failed"&&R.value?(e.openBlock(),e.createElementBlock("div",Ce,[o[3]||(o[3]=e.createElementVNode("div",{class:"reevit-error-icon"},"⚠️",-1)),o[4]||(o[4]=e.createElementVNode("h3",null,"Payment Failed",-1)),e.createElementVNode("p",null,e.toDisplayString(R.value.message),1),e.createElementVNode("button",{class:"reevit-retry-btn",onClick:o[0]||(o[0]=c=>e.unref(y)())},"Retry")])):v.value==="success"?(e.openBlock(),e.createElementBlock("div",_e,[o[5]||(o[5]=e.createElementVNode("div",{class:"reevit-success-icon"},"✅",-1)),o[6]||(o[6]=e.createElementVNode("h3",null,"Payment Successful",-1)),o[7]||(o[7]=e.createElementVNode("p",null,"Thank you for your payment.",-1)),e.createElementVNode("button",{class:"reevit-done-btn",onClick:w},"Done")])):T.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[v.value==="ready"||v.value==="method_selected"||v.value==="processing"?(e.openBlock(),e.createBlock(K,{key:0,methods:n.paymentMethods||["card","mobile_money"],selected:_.value,amount:n.amount,currency:n.currency,onSelect:B},null,8,["methods","selected","amount","currency"])):e.createCommentVNode("",!0),(v.value==="method_selected"||v.value==="processing")&&_.value==="mobile_money"?(e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(j,{"initial-phone":n.phone,loading:v.value==="processing",onSubmit:C},null,8,["initial-phone","loading"])])):e.createCommentVNode("",!0),(v.value==="method_selected"||v.value==="processing")&&_.value==="card"?(e.openBlock(),e.createElementBlock("div",Ie,[o[8]||(o[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:C,disabled:v.value==="processing"},[v.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)]),o[10]||(o[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:()=>d.ReevitAPIClient});Object.defineProperty(exports,"cn",{enumerable:!0,get:()=>d.cn});Object.defineProperty(exports,"createReevitClient",{enumerable:!0,get:()=>d.createReevitClient});Object.defineProperty(exports,"detectCountryFromCurrency",{enumerable:!0,get:()=>d.detectCountryFromCurrency});Object.defineProperty(exports,"detectNetwork",{enumerable:!0,get:()=>d.detectNetwork});Object.defineProperty(exports,"formatAmount",{enumerable:!0,get:()=>d.formatAmount});Object.defineProperty(exports,"formatPhone",{enumerable:!0,get:()=>d.formatPhone});Object.defineProperty(exports,"validatePhone",{enumerable:!0,get:()=>d.validatePhone});exports.MobileMoneyForm=j;exports.PaymentMethodSelector=K;exports.ReevitCheckout=Be;exports.confirmStripePayment=ke;exports.createStripeInstance=G;exports.initiateMPesaSTKPush=Q;exports.loadFlutterwaveScript=U;exports.loadHubtelScript=L;exports.loadMonnifyScript=x;exports.loadPaystackScript=A;exports.loadStripeScript=z;exports.openFlutterwaveModal=Y;exports.openHubtelPopup=q;exports.openMonnifyModal=J;exports.openPaystackPopup=H;exports.useReevit=F;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as g, watch as O, computed as h, readonly as _, defineComponent as z, createElementBlock as m, openBlock as d, createElementVNode as r, toDisplayString as I, unref as D, Fragment as H, renderList as W, normalizeClass as U, createCommentVNode as E, withModifiers as X, withDirectives as ae, vModelText as oe, createTextVNode as Z, normalizeStyle as ee, onUnmounted as re, renderSlot as Y, createBlock as G, Teleport as se, createVNode as ie } from "vue";
|
|
2
2
|
import { createInitialState as le, ReevitAPIClient as ce, generateReference as ue, detectCountryFromCurrency as de, reevitReducer as me, formatAmount as pe, cn as te, detectNetwork as ye, validatePhone as J, createThemeVariables as ve } from "@reevit/core";
|
|
3
|
-
import { ReevitAPIClient as yt, cn as vt, createReevitClient as ht, detectCountryFromCurrency as ft, detectNetwork as bt, formatAmount as
|
|
3
|
+
import { ReevitAPIClient as yt, cn as vt, createReevitClient as ht, detectCountryFromCurrency as ft, detectNetwork as bt, formatAmount as St, formatPhone as Pt, validatePhone as kt } from "@reevit/core";
|
|
4
4
|
function he(e) {
|
|
5
5
|
const s = e.toLowerCase();
|
|
6
6
|
return s.includes("paystack") ? "paystack" : s.includes("hubtel") ? "hubtel" : s.includes("flutterwave") ? "flutterwave" : "paystack";
|
|
@@ -25,148 +25,148 @@ function fe(e, s) {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
function be(e) {
|
|
28
|
-
const { config: s, onSuccess: t, onError:
|
|
28
|
+
const { config: s, onSuccess: t, onError: c, onClose: y, onStateChange: i, apiBaseUrl: u } = e, a = g(le());
|
|
29
29
|
if (s.initialPaymentIntent) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
...
|
|
30
|
+
const o = s.initialPaymentIntent;
|
|
31
|
+
a.value = {
|
|
32
|
+
...a.value,
|
|
33
33
|
status: "ready",
|
|
34
|
-
paymentIntent:
|
|
35
|
-
selectedMethod:
|
|
34
|
+
paymentIntent: o,
|
|
35
|
+
selectedMethod: o.availableMethods?.length === 1 ? o.availableMethods[0] : null
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
const
|
|
38
|
+
const P = new ce({
|
|
39
39
|
publicKey: s.publicKey,
|
|
40
40
|
baseUrl: u
|
|
41
|
-
}), p = (
|
|
42
|
-
|
|
41
|
+
}), p = (o) => {
|
|
42
|
+
a.value = me(a.value, o);
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
() =>
|
|
46
|
-
(
|
|
47
|
-
|
|
44
|
+
O(
|
|
45
|
+
() => a.value.status,
|
|
46
|
+
(o) => {
|
|
47
|
+
i?.(o);
|
|
48
48
|
}
|
|
49
49
|
);
|
|
50
|
-
const v = async (
|
|
50
|
+
const v = async (o) => {
|
|
51
51
|
p({ type: "INIT_START" });
|
|
52
52
|
try {
|
|
53
|
-
const
|
|
54
|
-
{ ...s, reference:
|
|
55
|
-
|
|
53
|
+
const n = s.reference || ue(), l = de(s.currency), w = o || s.paymentMethods?.[0] || "card", { data: S, error: V } = await P.createPaymentIntent(
|
|
54
|
+
{ ...s, reference: n },
|
|
55
|
+
w,
|
|
56
56
|
l
|
|
57
57
|
);
|
|
58
58
|
if (V) {
|
|
59
|
-
p({ type: "INIT_ERROR", payload: V }),
|
|
59
|
+
p({ type: "INIT_ERROR", payload: V }), c?.(V);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
if (!
|
|
62
|
+
if (!S) {
|
|
63
63
|
const q = {
|
|
64
64
|
code: "INIT_FAILED",
|
|
65
65
|
message: "No data received from API",
|
|
66
66
|
recoverable: !0
|
|
67
67
|
};
|
|
68
|
-
p({ type: "INIT_ERROR", payload: q }),
|
|
68
|
+
p({ type: "INIT_ERROR", payload: q }), c?.(q);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const ne = fe(
|
|
71
|
+
const ne = fe(S, { ...s, reference: n });
|
|
72
72
|
p({ type: "INIT_SUCCESS", payload: ne });
|
|
73
|
-
} catch (
|
|
73
|
+
} catch (n) {
|
|
74
74
|
const l = {
|
|
75
75
|
code: "INIT_FAILED",
|
|
76
|
-
message:
|
|
76
|
+
message: n instanceof Error ? n.message : "Failed to initialize checkout",
|
|
77
77
|
recoverable: !0,
|
|
78
|
-
originalError:
|
|
78
|
+
originalError: n
|
|
79
79
|
};
|
|
80
|
-
p({ type: "INIT_ERROR", payload: l }),
|
|
80
|
+
p({ type: "INIT_ERROR", payload: l }), c?.(l);
|
|
81
81
|
}
|
|
82
|
-
}, b = (
|
|
83
|
-
p({ type: "SELECT_METHOD", payload:
|
|
84
|
-
},
|
|
85
|
-
if (!(!
|
|
82
|
+
}, b = (o) => {
|
|
83
|
+
p({ type: "SELECT_METHOD", payload: o });
|
|
84
|
+
}, k = async (o) => {
|
|
85
|
+
if (!(!a.value.paymentIntent || !a.value.selectedMethod)) {
|
|
86
86
|
p({ type: "PROCESS_START" });
|
|
87
87
|
try {
|
|
88
|
-
let
|
|
89
|
-
if (
|
|
90
|
-
const { data:
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
let n;
|
|
89
|
+
if (a.value.paymentIntent.clientSecret) {
|
|
90
|
+
const { data: w, error: S } = await P.confirmPaymentIntent(
|
|
91
|
+
a.value.paymentIntent.id,
|
|
92
|
+
a.value.paymentIntent.clientSecret
|
|
93
93
|
);
|
|
94
|
-
if (
|
|
95
|
-
p({ type: "PROCESS_ERROR", payload:
|
|
94
|
+
if (S) {
|
|
95
|
+
p({ type: "PROCESS_ERROR", payload: S }), c?.(S);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
n = w;
|
|
99
99
|
} else {
|
|
100
|
-
const { data:
|
|
101
|
-
if (
|
|
102
|
-
p({ type: "PROCESS_ERROR", payload:
|
|
100
|
+
const { data: w, error: S } = await P.confirmPayment(a.value.paymentIntent.id);
|
|
101
|
+
if (S) {
|
|
102
|
+
p({ type: "PROCESS_ERROR", payload: S }), c?.(S);
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
n = w;
|
|
106
106
|
}
|
|
107
107
|
const l = {
|
|
108
|
-
paymentId:
|
|
109
|
-
reference:
|
|
110
|
-
amount:
|
|
111
|
-
currency:
|
|
112
|
-
paymentMethod:
|
|
113
|
-
psp:
|
|
114
|
-
pspReference:
|
|
108
|
+
paymentId: a.value.paymentIntent.id,
|
|
109
|
+
reference: o.reference || a.value.paymentIntent.reference || a.value.paymentIntent.metadata?.reference || "",
|
|
110
|
+
amount: a.value.paymentIntent.amount,
|
|
111
|
+
currency: a.value.paymentIntent.currency,
|
|
112
|
+
paymentMethod: a.value.selectedMethod,
|
|
113
|
+
psp: a.value.paymentIntent.recommendedPsp,
|
|
114
|
+
pspReference: o.pspReference || n?.provider_ref_id || "",
|
|
115
115
|
status: "success",
|
|
116
|
-
metadata:
|
|
116
|
+
metadata: o
|
|
117
117
|
};
|
|
118
118
|
p({ type: "PROCESS_SUCCESS", payload: l }), t?.(l);
|
|
119
|
-
} catch (
|
|
119
|
+
} catch (n) {
|
|
120
120
|
const l = {
|
|
121
121
|
code: "PAYMENT_FAILED",
|
|
122
|
-
message:
|
|
122
|
+
message: n instanceof Error ? n.message : "Payment failed",
|
|
123
123
|
recoverable: !0,
|
|
124
|
-
originalError:
|
|
124
|
+
originalError: n
|
|
125
125
|
};
|
|
126
|
-
p({ type: "PROCESS_ERROR", payload: l }),
|
|
126
|
+
p({ type: "PROCESS_ERROR", payload: l }), c?.(l);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
},
|
|
130
|
-
await
|
|
131
|
-
},
|
|
132
|
-
p({ type: "PROCESS_ERROR", payload:
|
|
133
|
-
},
|
|
129
|
+
}, R = async (o) => {
|
|
130
|
+
await k(o);
|
|
131
|
+
}, L = (o) => {
|
|
132
|
+
p({ type: "PROCESS_ERROR", payload: o }), c?.(o);
|
|
133
|
+
}, C = () => {
|
|
134
134
|
p({ type: "RESET" });
|
|
135
|
-
},
|
|
136
|
-
if (
|
|
135
|
+
}, F = async () => {
|
|
136
|
+
if (a.value.paymentIntent && a.value.status !== "success")
|
|
137
137
|
try {
|
|
138
|
-
await
|
|
138
|
+
await P.cancelPaymentIntent(a.value.paymentIntent.id);
|
|
139
139
|
} catch {
|
|
140
140
|
}
|
|
141
141
|
p({ type: "CLOSE" }), y?.();
|
|
142
|
-
},
|
|
143
|
-
() =>
|
|
144
|
-
),
|
|
145
|
-
() =>
|
|
146
|
-
),
|
|
142
|
+
}, M = h(() => a.value.status), B = h(() => a.value.paymentIntent), T = h(() => a.value.selectedMethod), j = h(() => a.value.error), f = h(() => a.value.result), A = h(
|
|
143
|
+
() => a.value.status === "loading" || a.value.status === "processing"
|
|
144
|
+
), $ = h(
|
|
145
|
+
() => a.value.status === "ready" || a.value.status === "method_selected" || a.value.status === "processing"
|
|
146
|
+
), N = h(() => a.value.status === "success"), x = h(() => a.value.error?.recoverable ?? !1);
|
|
147
147
|
return {
|
|
148
148
|
// State (readonly refs)
|
|
149
|
-
status:
|
|
150
|
-
paymentIntent:
|
|
151
|
-
selectedMethod:
|
|
152
|
-
error:
|
|
153
|
-
result:
|
|
149
|
+
status: _(M),
|
|
150
|
+
paymentIntent: _(B),
|
|
151
|
+
selectedMethod: _(T),
|
|
152
|
+
error: _(j),
|
|
153
|
+
result: _(f),
|
|
154
154
|
// Actions
|
|
155
155
|
initialize: v,
|
|
156
156
|
selectMethod: b,
|
|
157
|
-
processPayment:
|
|
158
|
-
handlePspSuccess:
|
|
159
|
-
handlePspError:
|
|
160
|
-
reset:
|
|
161
|
-
close:
|
|
157
|
+
processPayment: k,
|
|
158
|
+
handlePspSuccess: R,
|
|
159
|
+
handlePspError: L,
|
|
160
|
+
reset: C,
|
|
161
|
+
close: F,
|
|
162
162
|
// Computed
|
|
163
|
-
isLoading:
|
|
164
|
-
isReady:
|
|
165
|
-
isComplete:
|
|
166
|
-
canRetry:
|
|
163
|
+
isLoading: _(A),
|
|
164
|
+
isReady: _($),
|
|
165
|
+
isComplete: _(N),
|
|
166
|
+
canRetry: _(x)
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
const
|
|
169
|
+
const Se = { class: "reevit-method-selector" }, Pe = { class: "reevit-amount-display" }, ke = { class: "reevit-methods-grid" }, we = ["onClick"], _e = { class: "reevit-method-icon" }, Ce = { class: "reevit-method-info" }, Ee = { class: "reevit-method-name" }, Ie = { class: "reevit-method-description" }, Re = { class: "reevit-method-radio" }, Me = {
|
|
170
170
|
key: 0,
|
|
171
171
|
class: "reevit-radio-inner"
|
|
172
172
|
}, Te = /* @__PURE__ */ z({
|
|
@@ -179,7 +179,7 @@ const ke = { class: "reevit-method-selector" }, we = { class: "reevit-amount-dis
|
|
|
179
179
|
},
|
|
180
180
|
emits: ["select"],
|
|
181
181
|
setup(e, { emit: s }) {
|
|
182
|
-
const t = e,
|
|
182
|
+
const t = e, c = s, y = h(() => [
|
|
183
183
|
{
|
|
184
184
|
id: "card",
|
|
185
185
|
name: "Card",
|
|
@@ -198,36 +198,36 @@ const ke = { class: "reevit-method-selector" }, we = { class: "reevit-amount-dis
|
|
|
198
198
|
description: "Transfer directly from your bank",
|
|
199
199
|
icon: "🏦"
|
|
200
200
|
}
|
|
201
|
-
].filter((
|
|
202
|
-
return (
|
|
203
|
-
u[0] || (u[0] =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
(d(!0), m(H, null, W(y.value, (
|
|
207
|
-
key:
|
|
201
|
+
].filter((i) => t.methods.includes(i.id)));
|
|
202
|
+
return (i, u) => (d(), m("div", Se, [
|
|
203
|
+
u[0] || (u[0] = r("h3", { class: "reevit-section-title" }, "Select Payment Method", -1)),
|
|
204
|
+
r("p", Pe, " Pay " + I(D(pe)(e.amount, e.currency)), 1),
|
|
205
|
+
r("div", ke, [
|
|
206
|
+
(d(!0), m(H, null, W(y.value, (a) => (d(), m("button", {
|
|
207
|
+
key: a.id,
|
|
208
208
|
type: "button",
|
|
209
|
-
class:
|
|
210
|
-
onClick: (
|
|
209
|
+
class: U(D(te)("reevit-method-card", e.selected === a.id && "reevit-method-card--selected")),
|
|
210
|
+
onClick: (P) => c("select", a.id)
|
|
211
211
|
}, [
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
r("span", _e, I(a.icon), 1),
|
|
213
|
+
r("div", Ce, [
|
|
214
|
+
r("span", Ee, I(a.name), 1),
|
|
215
|
+
r("span", Ie, I(a.description), 1)
|
|
216
216
|
]),
|
|
217
|
-
|
|
218
|
-
e.selected ===
|
|
217
|
+
r("div", Re, [
|
|
218
|
+
e.selected === a.id ? (d(), m("div", Me)) : E("", !0)
|
|
219
219
|
])
|
|
220
|
-
], 10,
|
|
220
|
+
], 10, we))), 128))
|
|
221
221
|
])
|
|
222
222
|
]));
|
|
223
223
|
}
|
|
224
|
-
}), $e = { class: "reevit-form-group" }, Ne = ["disabled"], ge = { class: "reevit-network-selector" }, Oe = { class: "reevit-networks-grid" },
|
|
224
|
+
}), $e = { class: "reevit-form-group" }, Ne = ["disabled"], ge = { class: "reevit-network-selector" }, Oe = { class: "reevit-networks-grid" }, De = ["onClick", "disabled"], Ke = {
|
|
225
225
|
key: 0,
|
|
226
226
|
class: "reevit-error-message"
|
|
227
|
-
},
|
|
227
|
+
}, Fe = ["disabled"], Ae = {
|
|
228
228
|
key: 0,
|
|
229
229
|
class: "reevit-spinner"
|
|
230
|
-
},
|
|
230
|
+
}, Ue = { key: 1 }, Le = /* @__PURE__ */ z({
|
|
231
231
|
__name: "MobileMoneyForm",
|
|
232
232
|
props: {
|
|
233
233
|
initialPhone: {},
|
|
@@ -235,43 +235,43 @@ const ke = { class: "reevit-method-selector" }, we = { class: "reevit-amount-dis
|
|
|
235
235
|
},
|
|
236
236
|
emits: ["submit"],
|
|
237
237
|
setup(e, { emit: s }) {
|
|
238
|
-
const t = e,
|
|
239
|
-
|
|
238
|
+
const t = e, c = s, y = g(t.initialPhone || ""), i = g(null), u = g(null);
|
|
239
|
+
O(y, (p) => {
|
|
240
240
|
const v = ye(p);
|
|
241
|
-
v && (
|
|
241
|
+
v && (i.value = v), u.value && (u.value = null);
|
|
242
242
|
});
|
|
243
|
-
const
|
|
243
|
+
const a = () => {
|
|
244
244
|
if (!J(y.value)) {
|
|
245
245
|
u.value = "Please enter a valid phone number";
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
-
if (!
|
|
248
|
+
if (!i.value) {
|
|
249
249
|
u.value = "Please select your mobile network";
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
c("submit", {
|
|
253
253
|
phone: y.value,
|
|
254
|
-
network:
|
|
254
|
+
network: i.value
|
|
255
255
|
});
|
|
256
|
-
},
|
|
256
|
+
}, P = [
|
|
257
257
|
{ id: "mtn", name: "MTN", color: "#FFCC00" },
|
|
258
258
|
{ id: "vodafone", name: "Vodafone", color: "#E60000" },
|
|
259
259
|
{ id: "airteltigo", name: "AirtelTigo", color: "#005596" }
|
|
260
260
|
];
|
|
261
261
|
return (p, v) => (d(), m("form", {
|
|
262
262
|
class: "reevit-momo-form",
|
|
263
|
-
onSubmit: X(
|
|
263
|
+
onSubmit: X(a, ["prevent"])
|
|
264
264
|
}, [
|
|
265
|
-
|
|
266
|
-
v[1] || (v[1] =
|
|
265
|
+
r("div", $e, [
|
|
266
|
+
v[1] || (v[1] = r("label", {
|
|
267
267
|
class: "reevit-label",
|
|
268
268
|
for: "reevit-phone"
|
|
269
269
|
}, "Phone Number", -1)),
|
|
270
|
-
ae(
|
|
270
|
+
ae(r("input", {
|
|
271
271
|
id: "reevit-phone",
|
|
272
272
|
"onUpdate:modelValue": v[0] || (v[0] = (b) => y.value = b),
|
|
273
273
|
type: "tel",
|
|
274
|
-
class:
|
|
274
|
+
class: U(["reevit-input", { "reevit-input--error": u.value && !D(J)(y.value) }]),
|
|
275
275
|
placeholder: "e.g. 024 123 4567",
|
|
276
276
|
disabled: e.loading,
|
|
277
277
|
autocomplete: "tel"
|
|
@@ -279,63 +279,63 @@ const ke = { class: "reevit-method-selector" }, we = { class: "reevit-amount-dis
|
|
|
279
279
|
[oe, y.value]
|
|
280
280
|
])
|
|
281
281
|
]),
|
|
282
|
-
|
|
283
|
-
v[2] || (v[2] =
|
|
284
|
-
|
|
285
|
-
(d(), m(H, null, W(
|
|
282
|
+
r("div", ge, [
|
|
283
|
+
v[2] || (v[2] = r("label", { class: "reevit-label" }, "Select Network", -1)),
|
|
284
|
+
r("div", Oe, [
|
|
285
|
+
(d(), m(H, null, W(P, (b) => r("button", {
|
|
286
286
|
key: b.id,
|
|
287
287
|
type: "button",
|
|
288
|
-
class:
|
|
289
|
-
onClick: (
|
|
288
|
+
class: U(D(te)("reevit-network-btn", i.value === b.id && "reevit-network-btn--selected")),
|
|
289
|
+
onClick: (k) => i.value = b.id,
|
|
290
290
|
disabled: e.loading
|
|
291
291
|
}, [
|
|
292
|
-
|
|
292
|
+
r("div", {
|
|
293
293
|
class: "reevit-network-dot",
|
|
294
294
|
style: ee({ backgroundColor: b.color })
|
|
295
295
|
}, null, 4),
|
|
296
296
|
Z(" " + I(b.name), 1)
|
|
297
|
-
], 10,
|
|
297
|
+
], 10, De)), 64))
|
|
298
298
|
])
|
|
299
299
|
]),
|
|
300
|
-
u.value ? (d(), m("p",
|
|
301
|
-
|
|
300
|
+
u.value ? (d(), m("p", Ke, I(u.value), 1)) : E("", !0),
|
|
301
|
+
r("button", {
|
|
302
302
|
type: "submit",
|
|
303
303
|
class: "reevit-submit-btn",
|
|
304
304
|
disabled: e.loading || !y.value
|
|
305
305
|
}, [
|
|
306
|
-
e.loading ? (d(), m("span", Ae)) : (d(), m("span",
|
|
307
|
-
], 8,
|
|
308
|
-
v[3] || (v[3] =
|
|
306
|
+
e.loading ? (d(), m("span", Ae)) : (d(), m("span", Ue, "Continue"))
|
|
307
|
+
], 8, Fe),
|
|
308
|
+
v[3] || (v[3] = r("p", { class: "reevit-secure-text" }, " 🔒 Secure mobile money payment via Reevit ", -1))
|
|
309
309
|
], 32));
|
|
310
310
|
}
|
|
311
311
|
}), Q = /* @__PURE__ */ new Map();
|
|
312
|
-
function
|
|
312
|
+
function K(e, s) {
|
|
313
313
|
const t = Q.get(s);
|
|
314
314
|
if (t) return t;
|
|
315
|
-
const
|
|
315
|
+
const c = new Promise((y, i) => {
|
|
316
316
|
if (document.getElementById(s)) {
|
|
317
317
|
y();
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
320
|
const u = document.createElement("script");
|
|
321
|
-
u.id = s, u.src = e, u.async = !0, u.onload = () => y(), u.onerror = () =>
|
|
321
|
+
u.id = s, u.src = e, u.async = !0, u.onload = () => y(), u.onerror = () => i(new Error(`Failed to load ${s} script`)), document.head.appendChild(u);
|
|
322
322
|
});
|
|
323
|
-
return Q.set(s,
|
|
323
|
+
return Q.set(s, c), c;
|
|
324
324
|
}
|
|
325
325
|
function Be() {
|
|
326
|
-
return
|
|
326
|
+
return K("https://js.paystack.co/v1/inline.js", "paystack-script");
|
|
327
327
|
}
|
|
328
328
|
function je() {
|
|
329
|
-
return
|
|
329
|
+
return K("https://checkout-v3.hubtel.com/js/checkout.js", "hubtel-script");
|
|
330
330
|
}
|
|
331
331
|
function xe() {
|
|
332
|
-
return
|
|
332
|
+
return K("https://checkout.flutterwave.com/v3.js", "flutterwave-script");
|
|
333
333
|
}
|
|
334
334
|
function Ve() {
|
|
335
|
-
return
|
|
335
|
+
return K("https://js.stripe.com/v3/", "stripe-script");
|
|
336
336
|
}
|
|
337
337
|
function ze() {
|
|
338
|
-
return
|
|
338
|
+
return K("https://sdk.monnify.com/plugin/monnify.js", "monnify-script");
|
|
339
339
|
}
|
|
340
340
|
async function He(e) {
|
|
341
341
|
if (await Be(), !window.PaystackPop)
|
|
@@ -385,7 +385,7 @@ async function Ge(e) {
|
|
|
385
385
|
throw new Error("Stripe.js not loaded");
|
|
386
386
|
return window.Stripe(e);
|
|
387
387
|
}
|
|
388
|
-
async function
|
|
388
|
+
async function ut(e) {
|
|
389
389
|
const t = await (await Ge(e.publishableKey)).confirmPayment({
|
|
390
390
|
elements: e.elements,
|
|
391
391
|
clientSecret: e.clientSecret,
|
|
@@ -396,7 +396,7 @@ async function lt(e) {
|
|
|
396
396
|
status: t.paymentIntent.status
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
|
-
async function
|
|
399
|
+
async function Je(e) {
|
|
400
400
|
if (await ze(), !window.MonnifySDK)
|
|
401
401
|
throw new Error("Monnify SDK not loaded");
|
|
402
402
|
window.MonnifySDK.initialize({
|
|
@@ -421,7 +421,7 @@ async function ct(e) {
|
|
|
421
421
|
onClose: e.onClose
|
|
422
422
|
});
|
|
423
423
|
}
|
|
424
|
-
async function
|
|
424
|
+
async function Qe(e, s) {
|
|
425
425
|
e.onInitiated();
|
|
426
426
|
try {
|
|
427
427
|
const t = await fetch(s, {
|
|
@@ -435,42 +435,42 @@ async function ut(e, s) {
|
|
|
435
435
|
})
|
|
436
436
|
});
|
|
437
437
|
if (!t.ok) {
|
|
438
|
-
const
|
|
439
|
-
return e.onError({ message:
|
|
438
|
+
const i = (await t.json().catch(() => ({}))).message || "Failed to initiate M-Pesa payment";
|
|
439
|
+
return e.onError({ message: i }), { status: "failed", message: i };
|
|
440
440
|
}
|
|
441
|
-
const
|
|
441
|
+
const c = await t.json();
|
|
442
442
|
return {
|
|
443
443
|
status: "initiated",
|
|
444
444
|
message: "Please check your phone and enter your M-Pesa PIN to complete the payment.",
|
|
445
|
-
transactionId:
|
|
445
|
+
transactionId: c.checkout_request_id || c.transaction_id
|
|
446
446
|
};
|
|
447
447
|
} catch (t) {
|
|
448
|
-
const
|
|
449
|
-
return e.onError({ message:
|
|
448
|
+
const c = t instanceof Error ? t.message : "Network error";
|
|
449
|
+
return e.onError({ message: c }), { status: "failed", message: c };
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
const
|
|
452
|
+
const We = ["disabled"], Xe = {
|
|
453
453
|
key: 0,
|
|
454
454
|
class: "reevit-spinner"
|
|
455
|
-
},
|
|
455
|
+
}, Ze = { class: "reevit-modal-body" }, et = {
|
|
456
456
|
key: 0,
|
|
457
457
|
class: "reevit-loading-state"
|
|
458
|
-
},
|
|
458
|
+
}, tt = {
|
|
459
459
|
key: 1,
|
|
460
460
|
class: "reevit-error-state"
|
|
461
|
-
},
|
|
461
|
+
}, nt = {
|
|
462
462
|
key: 2,
|
|
463
463
|
class: "reevit-success-state"
|
|
464
|
-
},
|
|
464
|
+
}, at = {
|
|
465
465
|
key: 1,
|
|
466
466
|
class: "reevit-method-form-container"
|
|
467
|
-
},
|
|
467
|
+
}, ot = {
|
|
468
468
|
key: 2,
|
|
469
469
|
class: "reevit-card-info"
|
|
470
|
-
},
|
|
470
|
+
}, rt = ["disabled"], st = {
|
|
471
471
|
key: 0,
|
|
472
472
|
class: "reevit-spinner"
|
|
473
|
-
},
|
|
473
|
+
}, it = { key: 1 }, dt = /* @__PURE__ */ z({
|
|
474
474
|
__name: "ReevitCheckout",
|
|
475
475
|
props: {
|
|
476
476
|
publicKey: {},
|
|
@@ -488,18 +488,18 @@ const Je = ["disabled"], Qe = {
|
|
|
488
488
|
},
|
|
489
489
|
emits: ["success", "error", "close"],
|
|
490
490
|
setup(e, { emit: s }) {
|
|
491
|
-
const t = e,
|
|
491
|
+
const t = e, c = s, {
|
|
492
492
|
status: y,
|
|
493
|
-
paymentIntent:
|
|
493
|
+
paymentIntent: i,
|
|
494
494
|
selectedMethod: u,
|
|
495
|
-
error:
|
|
496
|
-
isLoading:
|
|
495
|
+
error: a,
|
|
496
|
+
isLoading: P,
|
|
497
497
|
isReady: p,
|
|
498
498
|
initialize: v,
|
|
499
499
|
selectMethod: b,
|
|
500
|
-
handlePspSuccess:
|
|
501
|
-
handlePspError:
|
|
502
|
-
close:
|
|
500
|
+
handlePspSuccess: k,
|
|
501
|
+
handlePspError: R,
|
|
502
|
+
close: L
|
|
503
503
|
} = be({
|
|
504
504
|
config: {
|
|
505
505
|
publicKey: t.publicKey,
|
|
@@ -513,186 +513,225 @@ const Je = ["disabled"], Qe = {
|
|
|
513
513
|
initialPaymentIntent: t.initialPaymentIntent
|
|
514
514
|
},
|
|
515
515
|
apiBaseUrl: t.apiBaseUrl,
|
|
516
|
-
onSuccess: (
|
|
517
|
-
onError: (
|
|
518
|
-
onClose: () =>
|
|
519
|
-
}),
|
|
520
|
-
|
|
521
|
-
|
|
516
|
+
onSuccess: (o) => c("success", o),
|
|
517
|
+
onError: (o) => c("error", o),
|
|
518
|
+
onClose: () => c("close")
|
|
519
|
+
}), C = g(t.isOpen ?? !1);
|
|
520
|
+
O(() => t.isOpen, (o) => {
|
|
521
|
+
o !== void 0 && (C.value = o);
|
|
522
522
|
});
|
|
523
|
-
const
|
|
524
|
-
|
|
523
|
+
const F = () => {
|
|
524
|
+
C.value = !0, !i.value && y.value === "idle" && v();
|
|
525
525
|
};
|
|
526
|
-
|
|
527
|
-
|
|
526
|
+
O([C, i, u], ([o, n, l]) => {
|
|
527
|
+
o && n && l && l === "card" && T(null);
|
|
528
528
|
});
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
}, B = (
|
|
532
|
-
b(
|
|
533
|
-
},
|
|
534
|
-
if (!
|
|
535
|
-
const
|
|
529
|
+
const M = () => {
|
|
530
|
+
C.value = !1, L();
|
|
531
|
+
}, B = (o) => {
|
|
532
|
+
b(o);
|
|
533
|
+
}, T = async (o) => {
|
|
534
|
+
if (!i.value) return;
|
|
535
|
+
const n = i.value.recommendedPsp;
|
|
536
536
|
try {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
amount: t.amount,
|
|
541
|
-
currency: t.currency,
|
|
542
|
-
ref: c.value.id,
|
|
543
|
-
onSuccess: (l) => _(l),
|
|
544
|
-
onClose: () => {
|
|
545
|
-
}
|
|
546
|
-
}) : a === "hubtel" ? await qe({
|
|
547
|
-
clientId: t.publicKey,
|
|
548
|
-
purchaseDescription: `Payment for ${t.amount} ${t.currency}`,
|
|
549
|
-
amount: t.amount,
|
|
550
|
-
customerPhone: r?.phone || t.phone,
|
|
551
|
-
customerEmail: t.email,
|
|
552
|
-
onSuccess: (l) => _(l),
|
|
553
|
-
onClose: () => {
|
|
554
|
-
}
|
|
555
|
-
}) : a === "flutterwave" && await Ye({
|
|
556
|
-
public_key: t.publicKey,
|
|
557
|
-
tx_ref: c.value.id,
|
|
558
|
-
amount: t.amount,
|
|
559
|
-
currency: t.currency,
|
|
560
|
-
customer: {
|
|
537
|
+
if (n === "paystack")
|
|
538
|
+
await He({
|
|
539
|
+
key: t.publicKey,
|
|
561
540
|
email: t.email || "",
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
541
|
+
amount: t.amount,
|
|
542
|
+
currency: t.currency,
|
|
543
|
+
ref: i.value.id,
|
|
544
|
+
onSuccess: (l) => k(l),
|
|
545
|
+
onClose: () => {
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
else if (n === "hubtel")
|
|
549
|
+
await qe({
|
|
550
|
+
clientId: t.publicKey,
|
|
551
|
+
purchaseDescription: `Payment for ${t.amount} ${t.currency}`,
|
|
552
|
+
amount: t.amount,
|
|
553
|
+
customerPhone: o?.phone || t.phone,
|
|
554
|
+
customerEmail: t.email,
|
|
555
|
+
onSuccess: (l) => k(l),
|
|
556
|
+
onClose: () => {
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
else if (n === "flutterwave")
|
|
560
|
+
await Ye({
|
|
561
|
+
public_key: t.publicKey,
|
|
562
|
+
tx_ref: i.value.id,
|
|
563
|
+
amount: t.amount,
|
|
564
|
+
currency: t.currency,
|
|
565
|
+
customer: {
|
|
566
|
+
email: t.email || "",
|
|
567
|
+
phone_number: o?.phone || t.phone
|
|
568
|
+
},
|
|
569
|
+
callback: (l) => k(l),
|
|
570
|
+
onclose: () => {
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
else if (n === "monnify")
|
|
574
|
+
await Je({
|
|
575
|
+
apiKey: i.value.pspPublicKey || t.publicKey,
|
|
576
|
+
contractCode: t.metadata?.contract_code || t.publicKey,
|
|
577
|
+
amount: t.amount,
|
|
578
|
+
currency: t.currency,
|
|
579
|
+
reference: i.value.reference || i.value.id,
|
|
580
|
+
customerName: t.metadata?.customer_name || t.email || "",
|
|
581
|
+
customerEmail: t.email || "",
|
|
582
|
+
customerPhone: o?.phone || t.phone,
|
|
583
|
+
metadata: t.metadata,
|
|
584
|
+
onSuccess: (l) => k(l),
|
|
585
|
+
onClose: () => {
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
else if (n === "mpesa") {
|
|
589
|
+
const l = `${t.apiBaseUrl || "https://api.reevit.io"}/v1/payments/${i.value.id}/mpesa`;
|
|
590
|
+
await Qe({
|
|
591
|
+
phoneNumber: o?.phone || t.phone || "",
|
|
592
|
+
amount: t.amount,
|
|
593
|
+
reference: i.value.reference || i.value.id,
|
|
594
|
+
description: `Payment ${i.value.reference || ""}`,
|
|
595
|
+
onInitiated: () => {
|
|
596
|
+
},
|
|
597
|
+
onSuccess: (w) => k(w),
|
|
598
|
+
onError: (w) => R({ code: "MPESA_ERROR", message: w.message })
|
|
599
|
+
}, l);
|
|
600
|
+
} else R(n === "stripe" ? {
|
|
601
|
+
code: "STRIPE_NOT_IMPLEMENTED",
|
|
602
|
+
message: "Stripe integration requires custom Elements setup. Please use the React SDK or implement custom Stripe Elements."
|
|
603
|
+
} : {
|
|
604
|
+
code: "UNSUPPORTED_PSP",
|
|
605
|
+
message: `Payment provider "${n}" is not supported in this checkout.`
|
|
567
606
|
});
|
|
568
607
|
} catch (l) {
|
|
569
|
-
|
|
608
|
+
R({
|
|
570
609
|
code: "BRIDGE_ERROR",
|
|
571
610
|
message: l instanceof Error ? l.message : "Failed to open payment gateway"
|
|
572
611
|
});
|
|
573
612
|
}
|
|
574
613
|
}, j = h(() => ve(t.theme || {}));
|
|
575
|
-
|
|
576
|
-
|
|
614
|
+
O(C, (o) => {
|
|
615
|
+
o ? document.body.style.overflow = "hidden" : document.body.style.overflow = "";
|
|
577
616
|
}), re(() => {
|
|
578
617
|
document.body.style.overflow = "";
|
|
579
618
|
});
|
|
580
|
-
const f = h(() => y.value),
|
|
581
|
-
return (
|
|
619
|
+
const f = h(() => y.value), A = h(() => a.value), $ = h(() => u.value), N = h(() => P.value), x = h(() => p.value);
|
|
620
|
+
return (o, n) => (d(), m("div", {
|
|
582
621
|
class: "reevit-sdk-container",
|
|
583
622
|
style: ee(j.value)
|
|
584
623
|
}, [
|
|
585
|
-
Y(
|
|
586
|
-
open:
|
|
587
|
-
isLoading:
|
|
624
|
+
Y(o.$slots, "default", {
|
|
625
|
+
open: F,
|
|
626
|
+
isLoading: N.value
|
|
588
627
|
}, () => [
|
|
589
|
-
|
|
628
|
+
r("button", {
|
|
590
629
|
type: "button",
|
|
591
630
|
class: "reevit-pay-button",
|
|
592
|
-
onClick:
|
|
593
|
-
disabled:
|
|
631
|
+
onClick: F,
|
|
632
|
+
disabled: N.value
|
|
594
633
|
}, [
|
|
595
|
-
|
|
596
|
-
|
|
634
|
+
N.value ? (d(), m("span", Xe)) : Y(o.$slots, "button-text", { key: 1 }, () => [
|
|
635
|
+
n[1] || (n[1] = Z("Pay Now", -1))
|
|
597
636
|
])
|
|
598
|
-
], 8,
|
|
637
|
+
], 8, We)
|
|
599
638
|
]),
|
|
600
639
|
(d(), G(se, { to: "body" }, [
|
|
601
|
-
|
|
640
|
+
C.value ? (d(), m("div", {
|
|
602
641
|
key: 0,
|
|
603
642
|
class: "reevit-modal-overlay",
|
|
604
|
-
onClick: X(
|
|
643
|
+
onClick: X(M, ["self"])
|
|
605
644
|
}, [
|
|
606
|
-
|
|
607
|
-
class:
|
|
645
|
+
r("div", {
|
|
646
|
+
class: U(["reevit-modal-content", { "reevit-modal--dark": t.theme?.darkMode }])
|
|
608
647
|
}, [
|
|
609
|
-
|
|
648
|
+
r("button", {
|
|
610
649
|
class: "reevit-modal-close",
|
|
611
|
-
onClick:
|
|
650
|
+
onClick: M,
|
|
612
651
|
"aria-label": "Close"
|
|
613
652
|
}, " × "),
|
|
614
|
-
|
|
615
|
-
|
|
653
|
+
n[9] || (n[9] = r("div", { class: "reevit-modal-header" }, [
|
|
654
|
+
r("img", {
|
|
616
655
|
src: "https://i.imgur.com/bzUR5Lm.png",
|
|
617
656
|
alt: "Reevit",
|
|
618
657
|
class: "reevit-modal__logo"
|
|
619
658
|
})
|
|
620
659
|
], -1)),
|
|
621
|
-
|
|
622
|
-
f.value === "loading" ? (d(), m("div",
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
])])) : f.value === "failed" &&
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
660
|
+
r("div", Ze, [
|
|
661
|
+
f.value === "loading" ? (d(), m("div", et, [...n[2] || (n[2] = [
|
|
662
|
+
r("div", { class: "reevit-spinner reevit-spinner--large" }, null, -1),
|
|
663
|
+
r("p", null, "Initializing payment...", -1)
|
|
664
|
+
])])) : f.value === "failed" && A.value ? (d(), m("div", tt, [
|
|
665
|
+
n[3] || (n[3] = r("div", { class: "reevit-error-icon" }, "⚠️", -1)),
|
|
666
|
+
n[4] || (n[4] = r("h3", null, "Payment Failed", -1)),
|
|
667
|
+
r("p", null, I(A.value.message), 1),
|
|
668
|
+
r("button", {
|
|
630
669
|
class: "reevit-retry-btn",
|
|
631
|
-
onClick:
|
|
670
|
+
onClick: n[0] || (n[0] = (l) => D(v)())
|
|
632
671
|
}, "Retry")
|
|
633
|
-
])) : f.value === "success" ? (d(), m("div",
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
672
|
+
])) : f.value === "success" ? (d(), m("div", nt, [
|
|
673
|
+
n[5] || (n[5] = r("div", { class: "reevit-success-icon" }, "✅", -1)),
|
|
674
|
+
n[6] || (n[6] = r("h3", null, "Payment Successful", -1)),
|
|
675
|
+
n[7] || (n[7] = r("p", null, "Thank you for your payment.", -1)),
|
|
676
|
+
r("button", {
|
|
638
677
|
class: "reevit-done-btn",
|
|
639
|
-
onClick:
|
|
678
|
+
onClick: M
|
|
640
679
|
}, "Done")
|
|
641
680
|
])) : x.value ? (d(), m(H, { key: 3 }, [
|
|
642
681
|
f.value === "ready" || f.value === "method_selected" || f.value === "processing" ? (d(), G(Te, {
|
|
643
682
|
key: 0,
|
|
644
683
|
methods: t.paymentMethods || ["card", "mobile_money"],
|
|
645
|
-
selected:
|
|
684
|
+
selected: $.value,
|
|
646
685
|
amount: t.amount,
|
|
647
686
|
currency: t.currency,
|
|
648
687
|
onSelect: B
|
|
649
|
-
}, null, 8, ["methods", "selected", "amount", "currency"])) :
|
|
650
|
-
(f.value === "method_selected" || f.value === "processing") &&
|
|
651
|
-
ie(
|
|
688
|
+
}, null, 8, ["methods", "selected", "amount", "currency"])) : E("", !0),
|
|
689
|
+
(f.value === "method_selected" || f.value === "processing") && $.value === "mobile_money" ? (d(), m("div", at, [
|
|
690
|
+
ie(Le, {
|
|
652
691
|
"initial-phone": t.phone,
|
|
653
692
|
loading: f.value === "processing",
|
|
654
|
-
onSubmit:
|
|
693
|
+
onSubmit: T
|
|
655
694
|
}, null, 8, ["initial-phone", "loading"])
|
|
656
|
-
])) :
|
|
657
|
-
(f.value === "method_selected" || f.value === "processing") &&
|
|
658
|
-
|
|
659
|
-
|
|
695
|
+
])) : E("", !0),
|
|
696
|
+
(f.value === "method_selected" || f.value === "processing") && $.value === "card" ? (d(), m("div", ot, [
|
|
697
|
+
n[8] || (n[8] = r("p", { class: "reevit-info-text" }, "You will be redirected to our secure payment partner to complete your card payment.", -1)),
|
|
698
|
+
r("button", {
|
|
660
699
|
class: "reevit-submit-btn",
|
|
661
|
-
onClick:
|
|
700
|
+
onClick: T,
|
|
662
701
|
disabled: f.value === "processing"
|
|
663
702
|
}, [
|
|
664
|
-
f.value === "processing" ? (d(), m("span",
|
|
665
|
-
], 8,
|
|
666
|
-
])) :
|
|
667
|
-
], 64)) :
|
|
703
|
+
f.value === "processing" ? (d(), m("span", st)) : (d(), m("span", it, "Proceed to Card Payment"))
|
|
704
|
+
], 8, rt)
|
|
705
|
+
])) : E("", !0)
|
|
706
|
+
], 64)) : E("", !0)
|
|
668
707
|
]),
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
708
|
+
n[10] || (n[10] = r("div", { class: "reevit-modal-footer" }, [
|
|
709
|
+
r("div", { class: "reevit-trust-badges" }, [
|
|
710
|
+
r("span", null, "PCI DSS Compliant"),
|
|
711
|
+
r("span", null, "•"),
|
|
712
|
+
r("span", null, "SSL Secure")
|
|
674
713
|
])
|
|
675
714
|
], -1))
|
|
676
715
|
], 2)
|
|
677
|
-
])) :
|
|
716
|
+
])) : E("", !0)
|
|
678
717
|
]))
|
|
679
718
|
], 4));
|
|
680
719
|
}
|
|
681
720
|
});
|
|
682
721
|
export {
|
|
683
|
-
|
|
722
|
+
Le as MobileMoneyForm,
|
|
684
723
|
Te as PaymentMethodSelector,
|
|
685
724
|
yt as ReevitAPIClient,
|
|
686
725
|
dt as ReevitCheckout,
|
|
687
726
|
vt as cn,
|
|
688
|
-
|
|
727
|
+
ut as confirmStripePayment,
|
|
689
728
|
ht as createReevitClient,
|
|
690
729
|
Ge as createStripeInstance,
|
|
691
730
|
ft as detectCountryFromCurrency,
|
|
692
731
|
bt as detectNetwork,
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
732
|
+
St as formatAmount,
|
|
733
|
+
Pt as formatPhone,
|
|
734
|
+
Qe as initiateMPesaSTKPush,
|
|
696
735
|
xe as loadFlutterwaveScript,
|
|
697
736
|
je as loadHubtelScript,
|
|
698
737
|
ze as loadMonnifyScript,
|
|
@@ -700,8 +739,8 @@ export {
|
|
|
700
739
|
Ve as loadStripeScript,
|
|
701
740
|
Ye as openFlutterwaveModal,
|
|
702
741
|
qe as openHubtelPopup,
|
|
703
|
-
|
|
742
|
+
Je as openMonnifyModal,
|
|
704
743
|
He as openPaystackPopup,
|
|
705
744
|
be as useReevit,
|
|
706
|
-
|
|
745
|
+
kt as validatePhone
|
|
707
746
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reevit/vue",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Unified Payment Widget for Vue 3 Applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"vue": "^3.3.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@reevit/core": "^0.3.
|
|
47
|
+
"@reevit/core": "^0.3.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^20.0.0",
|