paygate-checkout-sdk 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -801,5 +801,5 @@ to {
|
|
|
801
801
|
width: 100%;
|
|
802
802
|
height: 600px;
|
|
803
803
|
border: 0;
|
|
804
|
-
`,CA=e=>{let{userData:t,config:n,onSuccess:r,onError:a}=e;var o,i,l,s,u,c;const{showSnackbar:A,SnackbarUI:g}=mc(),[f,d]=_.useState(!1),[p,h]=_.useState(""),[B,C]=_.useState(!1),[v,y]=_.useState({number:"",expiryMonth:"",expiryYear:"",cvv:"",cardHolderName:"",productDescription:""}),[b,w]=_.useState(""),[I,E]=_.useState("FORM"),[x,Q]=_.useState(["","","",""]),[M,R]=_.useState(["","","","","",""]),[D,k]=_.useState("AUTH"),[j,P]=_.useState(""),[Y,O]=_.useState(""),[G,N]=_.useState(!1),[F,z]=_.useState("AUTH"),[T,L]=_.useState(""),[U,H]=_.useState(""),[V,W]=_.useState(!1),[X,q]=_.useState(!1),[K,Z]=_.useState("AUTH"),[$,ee]=_.useState(""),[te,ne]=_.useState(""),[re,ae]=_.useState(!1),[oe,ie]=_.useState(!1),[le,se]=_.useState(""),[ue,ce]=_.useState("FORM"),[Ae,ge]=_.useState(""),[fe,de]=_.useState(""),[pe,he]=_.useState(""),[me,Be]=_.useState({message:"",success:!1}),[Ce,ve]=_.useState(),[ye,be]=_.useState(),[we,Ie]=_.useState(),[Ee,xe]=_.useState(!1),[Qe,Me]=_.useState(0),[Re,Se]=_.useState([]),[De,ke]=_.useState(),[je,Pe]=_.useState(null),[Ye,Oe]=_.useState(!1),[Ge,Ne]=_.useState(!1),[Fe,ze]=_.useState(!1),Te=_.useRef([]),Le=_.useRef(null),Ue=_.useRef(null),He=_.useRef(null),Ve=_.useRef(null),We=_.useRef(null),Xe=_.useRef(null),[qe,Ke]=_.useState(!1),[Ze,Je]=_.useState(null),_e=_.useRef(null),$e=_.useRef(null),et=Xu(null!==(o=null==t?void 0:t.merchantPublicKey)&&void 0!==o?o:""),tt="live"===(null===(i=null==n?void 0:n.environment)||void 0===i?void 0:i.toLowerCase())?"prod":"dev",nt=[{label:"Bank card",value:"CARD",icon:Dn},{label:"USSD",value:"USSD",icon:kn},{label:"Bank transfer",value:"BANKTRANSFER",icon:jn},{label:"NQR",value:"NQR",icon:Pn},{label:"Pay with Opay",value:"OPAY",icon:Nn},{label:"Pay with PalmPay",value:"PALMPAY",icon:Ln},{label:"Pay with Kuda",value:"KUDA",icon:Wn},{label:"Mobile Money",value:"MOBILEMONEY",icon:Lu}],rt={visa:m.jsx(Zu,{}),mastercard:m.jsx(Ju,{}),verve:m.jsx(_u,{}),"american-express":m.jsx($u,{}),discover:m.jsx(ec,{})},at=e=>{const{name:t,value:n}=e.target;if("number"===t){const e=n.replace(/\D/g,"").slice(0,19),t=e.replace(/(.{4})/g,"$1 ").trim();y(e=>Object.assign(Object.assign({},e),{number:t}));const r=J(e),a=(e=>{const t=e.replace(/\s+/g,"").slice(0,6);return/^5061\d{2}/.test(t)||/^5078\d{2}/.test(t)||/^6500\d{2}/.test(t)||/^628051/.test(t)})(e);return a?Pe("verve"):r.length?Pe(r[0].type):Pe(null),void(e.length>=16&&Le.current&&Le.current.focus())}if("expiryMonth"===t){const e=n.replace(/\D/g,"").slice(0,2);return y(t=>Object.assign(Object.assign({},t),{expiryMonth:e})),void(2===e.length&&Ue.current&&Ue.current.focus())}if("expiryYear"===t){const e=n.replace(/\D/g,"").slice(0,2),t=v.expiryYear;return y(t=>Object.assign(Object.assign({},t),{expiryYear:e})),2===e.length&&He.current&&He.current.focus(),void(1===t.length&&""===e&&Le.current&&Le.current.focus())}if("cvv"===t){const e="american-express"===je?4:3,t=n.replace(/\D/g,"").slice(0,e),r=v.cvv;return y(e=>Object.assign(Object.assign({},e),{cvv:t})),void(1===r.length&&""===t&&Ue.current&&Ue.current.focus())}y(e=>Object.assign(Object.assign({},e),{[t]:n}))},ot=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e,n,r,a,o,i,l,s,u;const c=x.join(""),g=v.number.replaceAll(" ","")||(null===(e=Ve.current)||void 0===e?void 0:e.value.replaceAll(" ",""));ie(!0);try{const e={client_transaction_reference:null==t?void 0:t.transactionRef,amount:parseFloat(t.amount.toString()),currency:t.currencyCode,card_number:g,card_expiry_month:v.expiryMonth||(null===(n=Le.current)||void 0===n?void 0:n.value),card_expiry_year:`20${v.expiryYear||(null===(r=Ue.current)||void 0===r?void 0:r.value)}`,card_cvv:v.cvv||(null===(a=He.current)||void 0===a?void 0:a.value),card_pin:"verve"===je?c:void 0,card_holder_name:v.cardHolderName||(null===(o=We.current)||void 0===o?void 0:o.value),customer_email:t.email,customer_phone_number:"+"+t.phoneNumber,customer_address:t.customerAddress,customer_first_name:t.firstName,customer_last_name:t.lastName,customer_city:t.customerCity,customer_state:t.customerState,customer_country:t.customerCountry,customer_postal_code:t.customerPostalCode,payment_description:v.productDescription,device_signature:t.deviceSignature,ip_address:t.ipAddress,metadata_order_id:t.metadataOrderId,metadata_product_info:t.metadataProductInfo},i=yield lo.post(`https://card.${tt}.mypaygate.co/api/v1/checkout-sdk/charge`,e,{headers:{"Content-Type":"application/json","X-Business-API-Key":"SK-24-5871083f656e4572-yTKxOX7-k6UI3eVFBm8mfNP0VIrE5A8R"}});i.status&&Ie(i.data)}catch(e){console.error("Payment Error:",(null===(i=e.response)||void 0===i?void 0:i.data)||e.message),Ie(null===(l=e.response)||void 0===l?void 0:l.data),A("error",null===(s=e.response)||void 0===s?void 0:s.data.error_code,null===(u=e.response)||void 0===u?void 0:u.data.message)}finally{ie(!1)}}),[x]),it=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e,n,r,a,o;ie(!0);try{const{data:o}=yield lo.post(`https://subsidiary.${tt}.mypaygate.co/collection/v1/simulate-payin`,{requestHeader:{clientId:"",requestType:"GHS"===(null===(e=t.transactionCurrency)||void 0===e?void 0:e.toUpperCase())?"GH":(null===(n=t.transactionCurrency)||void 0===n?void 0:n.toUpperCase())+"-Collections"},transactionReference:null==t?void 0:t.transactionRef,transactionCountry:"GHA"===(null===(r=t.countryCode)||void 0===r?void 0:r.toUpperCase())?"GH":null===(a=t.countryCode)||void 0===a?void 0:a.toUpperCase()},{headers:{Accept:"application/json","Content-Type":"application/json"}});return"success"==o.responseMessage.toLowerCase()&&ze(!0),o}catch(e){console.error("Simulate PayIn Error:",(null===(o=e.response)||void 0===o?void 0:o.data)||e.message)}finally{ie(!1)}}),[null==t?void 0:t.transactionRef]),lt=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e,n,r,a;ie(!0);try{const{data:a}=yield lo.post(`https://subsidiary.${tt}.mypaygate.co/collection/v1/payin`,{requestHeader:{clientId:t.clientId,requestType:"Collections"},customerName:t.firstName+t.lastName,customerEmail:t.email,customerNumber:Ae,transactionReference:null==t?void 0:t.transactionRef,transactionDescription:"",transactionAmount:t.amount,transactionCurrency:t.transactionCurrency,transactionCountry:"GHA"===(null===(e=t.countryCode)||void 0===e?void 0:e.toUpperCase())?"GH":"GMB"===(null===(n=t.countryCode)||void 0===n?void 0:n.toUpperCase())?"GM":null===(r=t.countryCode)||void 0===r?void 0:r.toUpperCase(),successUrl:"",errorUrl:"",cancelUrl:"",operatorCode:null!=fe?fe:"",webhookUrl:""},{headers:{Accept:"application/json","X-module":Wu(t.amount,null==t?void 0:t.transactionRef,Ae.toString()),"X-business":et,"X-app":"checkout","Content-Type":"application/json"}});ve(a),(null==a?void 0:a.paymentCompletionRequired)&&(he(null==a?void 0:a.paymentCompletionUrl),q(!0)),"GMD"!==t.currencyCode&&"failed"!==a.responseDetails.responseMessage.toLowerCase()?ce("CALL"):A("error",a.responseDetails.failedReason,"Please check your account details and try again")}catch(e){console.error("PayIn Error:",(null===(a=e.response)||void 0===a?void 0:a.data)||e.message)}finally{ie(!1)}}),[Ae]),st=()=>S(void 0,void 0,void 0,function*(){var e,n;let r;ie(!0),t.transactionRef&&(r=Xu(t.transactionRef));const a=Xu(null!==(e=t.merchantPublicKey)&&void 0!==e?e:""),o={requestHeader:{clientId:"",requestType:"GH-Collections"},transactionReference:t.transactionRef,transactionCountry:"GH"};try{const{data:e}=yield lo.post(`https://subsidiary.${tt}.mypaygate.co/collection/v1/check-status`,o,{headers:{Accept:"application/json","Content-Type":"application/json","X-module":r,"X-business":a,"X-app":"checkout"}});return"SUCCESS"!==e.serverResponse.responseDetails.responseMessage?ce("FAILED"):ce("SUCCESS"),e}catch(e){throw console.error("Error checking status:",(null===(n=e.response)||void 0===n?void 0:n.data)||e.message),e}finally{ie(!1)}}),ut=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e;try{const n=`https://va.${tt}.mypaygate.co/api/v1/account/dynamic/generate`,r={creationRef:null==t?void 0:t.transactionRef,source:"CHECKOUT",category:"Collection",channel:"Bank Transfer",currency:null==t?void 0:t.currencyCode,firstName:null==t?void 0:t.firstName,lastName:null==t?void 0:t.lastName,email:null==t?void 0:t.email,phone:null==t?void 0:t.phoneNumber,amount:null===(e=null==ye?void 0:ye.data)||void 0===e?void 0:e.transaction_amount},a=yield lo.post(n,r,{headers:{"x-api-key":et}});ke(a.data)}catch(e){console.error("handleVirtualAccount error --\x3e ",e)}}),[null===(l=null==ye?void 0:ye.data)||void 0===l?void 0:l.transaction_amount,null==t?void 0:t.email,null==t?void 0:t.firstName,null==t?void 0:t.lastName,null==t?void 0:t.phoneNumber]),ct=_.useCallback(()=>{if(t.transactionRef)return Xe.current=t.transactionRef,t.transactionRef},[t.transactionRef]),At=_.useCallback(()=>S(void 0,void 0,void 0,function*(){try{const e={redirect_url:null==t?void 0:t.redirectUrl,merchant_key:"",merchant_reference:null==t?void 0:t.merchantReference,biller_name:"",branch_id:"",payment_link_id:"",transaction_reference:null==t?void 0:t.transactionRef,checkout_amount:null==t?void 0:t.amount,currency_code:null==t?void 0:t.currencyCode,first_name:null==t?void 0:t.firstName,last_name:null==t?void 0:t.lastName,email_address:null==t?void 0:t.email,phone_number:null==t?void 0:t.phoneNumber,country_code:null==t?void 0:t.countryCode,payment_channel:"",additional_details:{}},{data:n}=yield lo.post(`https://checkout-be.${tt}.mypaygate.co/checkout`,e,{headers:{"Content-Type":"application/json",Authorization:et}});n.status&&be(n)}catch(e){console.error("")}}),[]),gt=()=>{y({number:"",expiryMonth:"",expiryYear:"",cvv:"",cardHolderName:"",productDescription:""}),Q(["","","",""]),R(["","","","","",""]),w(""),k("AUTH"),P(""),O(""),N(!1),z("AUTH"),L(""),H(""),W(!1),Z("AUTH"),ee(""),ne(""),ae(!1),se(""),ce("FORM"),ge(""),de(""),Be({message:"",success:!1}),ve(void 0),ke(void 0),C(!1),Je(null),Ke(!1),Ne(!1),Oe(!1),xe(!1),Me(0),ze(!1)},ft=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e;try{const n=`https://va.${tt}.mypaygate.co/api/v1/account/funding/simulate`,{data:r}=yield lo.post(n,{accountReference:null==t?void 0:t.transactionRef,amount:null===(e=null==ye?void 0:ye.data)||void 0===e?void 0:e.transaction_amount},{headers:{"x-api-key":et}});Be(r)}catch(e){console.error("fund_virtual_account error --\x3e ",e)}}),[De]),dt=_.useCallback(e=>S(void 0,void 0,void 0,function*(){try{const n=`https://card.${tt}.mypaygate.co/api/v1/checkout-sdk/complete-otp`,r={transaction_reference:Xe.current,otp_code:e};"SUCCESSFUL"===(yield lo.post(n,r,{headers:{"Content-Type":"application/json","X-Internal-API-Key":"checkout-sdk-key-101112","X-Business-API-Key":t.merchantPublicKey}})).data.status&&Ne(!0)}catch(e){console.error("handleOtp error -> ",e)}}),[]),pt=()=>{var e,t,n,r,a,o;const i=v.number.replace(/\s/g,"")||(null===(t=null===(e=Ve.current)||void 0===e?void 0:e.value)||void 0===t?void 0:t.replace(/\s/g,"")),l=v.expiryMonth||(null===(n=Le.current)||void 0===n?void 0:n.value),s=v.expiryYear||(null===(r=Ue.current)||void 0===r?void 0:r.value),u=v.cvv||(null===(a=He.current)||void 0===a?void 0:a.value),c=v.cardHolderName||(null===(o=We.current)||void 0===o?void 0:o.value);return!!i&&i.length>=16&&!!l&&2===l.length&&!!s&&2===s.length&&!!u&&(3===u.length||"american-express"===je&&4===u.length)&&!!c},ht=e=>{if(!(null==e?void 0:e.success)||!e.responseData)return 0;const t=e.responseData.dateExpired,n=e.responseData.expiry;if(t){const e=Date.parse(t.replace(" ","T"));if(!Number.isNaN(e))return Math.max(0,Math.floor((e-Date.now())/1e3))}return"number"==typeof n&&n>0?60*n:0};_.useEffect(()=>{At(),ze(!1)},[]),_.useEffect(()=>{if(De)if(De.success){const e=ht(De);Me(e),xe(e>0)}else xe(!1)},[De]),_.useEffect(()=>{if(!Ee)return;const e=setInterval(()=>{Me(t=>t<=1?(clearInterval(e),xe(!1),0):t-1)},1e3);return()=>clearInterval(e)},[Ee]),_.useEffect(()=>{var e,t,n;let r=null!==(n=null===(t=null===(e=null==ye?void 0:ye.data)||void 0===e?void 0:e.payment_options)||void 0===t?void 0:t.map(e=>e.paymentOption))&&void 0!==n?n:[];Se(r),h(r[0])},[ye]),_.useEffect(()=>{"BANKTRANSFER"===p?(xe(!1),ut()):(xe(!1),Me(0))},[p,ut]),_.useEffect(()=>{if(!(null==De?void 0:De.success))return void xe(!1);const e=ht(De);Me(e),xe(e>0)},[De]),_.useEffect(()=>{(null==we?void 0:we.status)&&"verve"===je?C(!0):"PENDING_3DS"===(null==we?void 0:we.status)&&(null==we?void 0:we.redirect_url_3ds)?(Je(null==we?void 0:we.redirect_url_3ds),Ke(!0),A("info","3DS authentication","3DS authentication required. Please complete the challenge below.")):("SUCCESSFUL"===(null==we?void 0:we.status)&&Ne(!0),"FAILED"===(null==we?void 0:we.status)&&(Oe(!0),setTimeout(()=>{gt(),Oe(!1)},3e3)))},[we]),_.useEffect(()=>{("SUCCESS"===ue||me.success)&&(A("info","Redirection Notification","You will be redirected in 10 seconds"),null==r||r(),setTimeout(()=>{if((null==t?void 0:t.redirectUrl)&&(null==t?void 0:t.transactionRef)){const e=new URL(null==t?void 0:t.redirectUrl);e.searchParams.set("transactionRef",null==t?void 0:t.transactionRef),window.open(e,"_self")}},1e4))},[me,ue]),_.useEffect(()=>{null==t||t.webhookUrl},[]);const mt=()=>m.jsxs(uA,Object.assign({bold:!0},{children:[m.jsx(cA,{children:"Total Amount"}),m.jsx(AA,{children:Ku((null==De?void 0:De.responseData.amountExpected)?null==De?void 0:De.responseData.amountExpected:t.amount,t.currencyCode)})]})),Bt=()=>m.jsxs(dA,{children:[m.jsx(mA,{}),m.jsx(pA,Object.assign({size:"18px",weight:500,style:{marginTop:"30px"}},{children:"Initializing SDK..."})),m.jsx(pA,Object.assign({size:"14px",weight:300},{children:"Setting up your secure payment environment."}))]});return ye?m.jsxs(m.Fragment,{children:[!Ge&&!Ye&&!qe&&!Ze&&!X&&m.jsxs(Ic,{children:[m.jsxs(Ec,{children:[m.jsxs(xc,Object.assign({open:f},{children:[m.jsx(Fc,{children:"Make Payment"}),m.jsx(Tc,{}),nt.filter(e=>Re.includes(e.value)).map(e=>{const t=e.icon,n=p===e.value;return m.jsxs(Rc,Object.assign({selected:n,onClick:()=>{gt(),h(e.value),E("FORM")},style:{backgroundColor:n?"#DED8FB":"transparent"}},{children:["string"==typeof t?m.jsx("img",{src:t||"/placeholder.svg",alt:`${e.label} icon`,style:{width:24,height:24,marginRight:8}}):m.jsx(t,{style:{marginRight:8,fontWeight:500},color:n?"#28119C":"#52525B"}),e.label]}),e.value)})]})),m.jsxs(Sc,{children:[m.jsxs(zc,{children:[m.jsx(Mc,Object.assign({onClick:()=>d(!0)},{children:m.jsx(Hu,{})})),"OTP"===K||"OTP"===F||"OTP"===D?m.jsxs(eA,{children:[m.jsx(oA,{children:"Enter OTP"}),m.jsxs(iA,{children:["A 6-digit code has been sent to your phone number"," "]})]}):"CARD"===p?m.jsxs(eA,{children:[m.jsx(_c,{children:"Pay with bank card"}),m.jsx($c,{children:"Enter your card details to pay"})]}):"USSD"===p?m.jsxs(eA,{children:[m.jsx(_c,{children:"Pay with USSD"}),m.jsx($c,{children:"Select a bank to get the USSD code"})]}):m.jsxs(eA,{children:[m.jsx(_c,{children:"Pay via transfer"}),m.jsx($c,{children:"Make the transfer to the account below"})]})]}),!["OPAY","PALMPAY","KUDA","MOBILEMONEY"].includes(p)&&"PIN"!==I&&m.jsx(mt,{}),Re.includes("CARD")&&"FORM"===I&&"CARD"===p&&m.jsx(m.Fragment,{children:!qe&&!Ze&&!X&&m.jsxs(m.Fragment,{children:[m.jsx(Vc,{children:"Card Number"}),m.jsxs(Pc,{children:[m.jsx(jc,{name:"number",placeholder:"0000 0000 0000 0000",value:v.number,onChange:at,ref:Ve,style:{marginBottom:"0"}}),je?rt[je]:m.jsx(tc,{})]}),m.jsxs(lA,{children:[m.jsxs("div",{children:[m.jsx(Vc,{children:"Expiry Date"}),m.jsxs("div",Object.assign({style:{display:"flex",width:"100px",justifyContent:"space-between",alignItems:"center",maxWidth:"100px"}},{children:[m.jsx(sA,Object.assign({width:"40px",style:{maxWidth:"30px",minWidth:"30px"},withSlash:!0},{children:m.jsx(kc,{name:"expiryMonth",placeholder:"MM",maxLength:2,ref:Le,value:v.expiryMonth,onChange:at,style:{marginBottom:"0"}})})),m.jsx(sA,Object.assign({width:"40px",style:{maxWidth:"30px",minWidth:"30px"}},{children:m.jsx(kc,{name:"expiryYear",placeholder:"YY",maxLength:2,ref:Ue,value:v.expiryYear,onChange:at,style:{marginBottom:"0"}})}))]}))]}),m.jsxs(sA,Object.assign({width:"50px",style:{paddingRight:"24px",maxWidth:"50px",minWidth:"50px"}},{children:[m.jsx(Vc,{children:"CVV"}),m.jsx(kc,{name:"cvv",placeholder:"CVV",maxLength:4,ref:He,value:v.cvv,onChange:at,style:{marginBottom:"0"}})]}))]}),m.jsx(Vc,{children:"Card Holder Name"}),m.jsx(kc,{name:"cardHolderName",type:"text",placeholder:"Card Holder Name",value:v.cardHolderName,onChange:at,ref:We,style:{marginBottom:"0"}}),m.jsx(Vc,{children:"Description"}),m.jsx(kc,{name:"productDescription",type:"text",placeholder:"Product Description Optional",value:v.productDescription,onChange:at}),m.jsx(Yc,Object.assign({onClick:()=>{"verve"===je?E("PIN"):ot()},disabled:oe||!pt(),isDisable:oe||!pt()},{children:oe?"Loading...":"Confirm"}))]})}),"PIN"===I&&"verve"===je&&m.jsx(m.Fragment,{children:!B&&m.jsxs(m.Fragment,{children:[m.jsx(Dc,Object.assign({style:{width:"100%",textAlign:"center"}},{children:"Card Pin"})),m.jsx(Gc,{children:x.map((e,t)=>m.jsx(Nc,{ref:e=>{Te.current[t]=e},type:"password",maxLength:1,value:e,onChange:e=>{var n;((e,t)=>{const n=[...x];n[e]=t,Q(n)})(t,e.target.value),e.target.value&&t<x.length-1&&(null===(n=Te.current[t+1])||void 0===n||n.focus())}},t))}),!(null==we?void 0:we.message.includes("Duplicate transaction reference"))&&m.jsx(Yc,Object.assign({onClick:()=>{ot()},disabled:oe},{children:oe?"Loading...":"Confirm"}))]})}),B&&m.jsx(Tu,{setIsOtpModal:C,setOtp:R,otp:M,paymentMethod:"CARD",handleOtp:dt}),(null==we?void 0:we.message.includes("Duplicate transaction reference"))&&m.jsx(Yc,Object.assign({onClick:()=>{ct(),ot()},disabled:oe},{children:oe?"Loading...":"Try Again"})),Re.includes("USSD")&&"USSD"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsx(Dc,{children:"Choose bank"}),m.jsx(xo,{selected:b,onChange:w,currency:"GH"}),b&&m.jsxs(m.Fragment,{children:[m.jsxs(Oc,{children:[m.jsx("span",{children:"*737*000*1234#"}),m.jsx(qn,{})]}),m.jsx("p",Object.assign({style:{fontSize:"14px",marginTop:"8px",textAlign:"center",color:"#666666"}},{children:"Tap on the code to dial"})),m.jsx(Yc,{children:"I have made this payment"})]})]}),Re.includes("BANKTRANSFER")&&"FORM"===I&&"BANKTRANSFER"===p&&m.jsxs(m.Fragment,{children:[!me.success&&m.jsx(Dc,{children:"Transfer to the account below"}),me.success?m.jsxs(Wc,Object.assign({style:{textAlign:"center"}},{children:[m.jsx(Uu,{}),m.jsx("h3",{children:me.message}),m.jsx("p",Object.assign({style:{color:"#666666",fontSize:"14px"}},{children:"Your payment has been successfully completed"}))]})):m.jsxs(Wc,{children:[m.jsxs(Xc,Object.assign({$isLast:!1},{children:[m.jsx("span",Object.assign({className:"label"},{children:"ACCOUNT NUMBER"})),m.jsxs("span",Object.assign({className:"value"},{children:[null===(s=null==De?void 0:De.responseData)||void 0===s?void 0:s.accountNumber,m.jsx(qn,{})]}))]})),m.jsxs(Xc,Object.assign({$isLast:!1},{children:[m.jsx("span",Object.assign({className:"label"},{children:"BANK NAME"})),m.jsx("span",Object.assign({className:"value"},{children:null===(u=null==De?void 0:De.responseData)||void 0===u?void 0:u.bankName}))]})),m.jsxs(qc,{children:[m.jsx(Qo,{}),m.jsx("span",{children:"Account number only valid for this transaction"})]})]}),!me.success&&m.jsxs(m.Fragment,{children:[m.jsxs(Kc,{children:[m.jsx(Mo,{}),m.jsx("span",{children:Qe>0?(e=>{const t=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`})(Qe):"Expired"})]}),m.jsx(Yc,Object.assign({onClick:()=>ft(),disabled:Qe<=0},{children:"I have made this payment"}))]})]}),Re.includes("NQR")&&"NQR"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsx(Dc,Object.assign({style:{textAlign:"center"}},{children:"Scan the QR code to make payment"})),m.jsx(Zc,{children:m.jsx(Ro,{})}),m.jsx(Yc,{children:"I have made this payment"})]}),Re.includes("OPAY")&&"OPAY"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsxs(Lc,Object.assign({style:{flexDirection:"column",alignItems:"flex-start"}},{children:[m.jsx(mt,{}),m.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",width:"100%",marginTop:8}},{children:[m.jsx("span",Object.assign({style:{color:"#71717A"}},{children:"Merchant Name"})),m.jsx("span",Object.assign({style:{fontWeight:600}},{children:null==t?void 0:t.merchantName}))]}))]})),m.jsx("div",Object.assign({style:{textAlign:"center",marginBottom:24,display:"flex",alignItems:"center",justifyContent:"center",width:"100%"}},{children:m.jsx("img",{src:jo||"/placeholder.svg",alt:""})})),"AUTH"===D&&m.jsxs(m.Fragment,{children:[m.jsx("p",Object.assign({style:{textAlign:"center",marginBottom:24}},{children:"Click the button below to authenticate with your bank"})),m.jsx(Yc,Object.assign({onClick:()=>k("CREDS")},{children:"Authenticate"}))]}),"CREDS"===D&&m.jsxs(Jc,{children:[m.jsx(tA,{placeholder:"Enter Your Ten Digit Phone Number",value:j,onChange:e=>P(e.target.value)}),m.jsxs(nA,{children:[m.jsx(tA,{type:G?"text":"password",placeholder:"Enter your 6-digit Opay password",value:Y,onChange:e=>O(e.target.value)}),m.jsx(rA,Object.assign({onClick:()=>N(e=>!e)},{children:m.jsx(xu,{icon:G?Po:Yo,color:"#979797",fontWeight:500})}))]}),m.jsx(aA,Object.assign({disabled:!(j&&6===Y.length),onClick:()=>k("OTP"),style:{borderRadius:"24px"}},{children:"Next"}))]}),"OTP"===D&&m.jsx(Tu,{otp:M,setOtp:R,setIsOtpModal:e=>{e||(h("CARD"),E("FORM"),k("AUTH"))},paymentMethod:"OPAY"})]}),Re.includes("PALMPAY")&&"PALMPAY"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsxs(Lc,Object.assign({style:{flexDirection:"column",alignItems:"flex-start"}},{children:[m.jsx(mt,{}),m.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",width:"100%",marginTop:8}},{children:[m.jsx("span",Object.assign({style:{color:"#71717A"}},{children:"Merchant Name"})),m.jsx("span",Object.assign({style:{fontWeight:600}},{children:null==t?void 0:t.merchantName}))]}))]})),m.jsx("div",Object.assign({style:{textAlign:"center",marginBottom:24,display:"flex",alignItems:"center",justifyContent:"center",width:"100%"}},{children:m.jsx("img",{src:Du||"/placeholder.svg",alt:"PalmpayIcon"})})),"AUTH"===F&&m.jsxs(m.Fragment,{children:[m.jsx("p",Object.assign({style:{textAlign:"center",marginBottom:24}},{children:"Click the button below to authenticate with your bank"})),m.jsx(Yc,Object.assign({onClick:()=>z("CREDS")},{children:"Authenticate"}))]}),"CREDS"===F&&m.jsxs(Jc,{children:[m.jsx(tA,{placeholder:"Enter Your Ten Digit Phone Number",value:T,onChange:e=>L(e.target.value)}),m.jsxs(nA,{children:[m.jsx(tA,{type:V?"text":"password",placeholder:"Enter your 6-digit Password for your PalmPay account",value:U,onChange:e=>H(e.target.value)}),m.jsx(rA,Object.assign({onClick:()=>W(e=>!e)},{children:m.jsx(xu,{icon:V?Po:Yo,color:"#979797"})}))]}),m.jsx(aA,Object.assign({disabled:!(T&&6===U.length),onClick:()=>z("OTP"),style:{borderRadius:"24px"}},{children:"Next"}))]}),"OTP"===F&&m.jsx(Tu,{otp:M,setOtp:R,setIsOtpModal:e=>{e||(h("CARD"),E("FORM"),z("AUTH"))},paymentMethod:"PALMPAY"})]}),Re.includes("KUDA")&&"KUDA"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsxs(Lc,Object.assign({style:{flexDirection:"column",alignItems:"flex-start"}},{children:[m.jsx(mt,{}),m.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",width:"100%",marginTop:8}},{children:[m.jsx("span",Object.assign({style:{color:"#71717A"}},{children:"Merchant Name"})),m.jsx("span",Object.assign({style:{fontWeight:600}},{children:null==t?void 0:t.merchantName}))]}))]})),m.jsx("div",Object.assign({style:{textAlign:"center",marginBottom:24,display:"flex",alignItems:"center",justifyContent:"center",width:"100%"}},{children:m.jsx("img",{src:Yu||"/placeholder.svg",alt:"Kuda"})})),"AUTH"===K&&m.jsxs(m.Fragment,{children:[m.jsx("p",Object.assign({style:{textAlign:"center",marginBottom:24}},{children:"Click the button below to authenticate with your bank"})),m.jsx(Yc,Object.assign({onClick:()=>Z("CREDS")},{children:"Authenticate"}))]}),"CREDS"===K&&m.jsxs(Jc,{children:[m.jsx(tA,{placeholder:"Enter Your Email",value:$,onChange:e=>ee(e.target.value)}),m.jsxs(nA,{children:[m.jsx(tA,{type:re?"text":"password",placeholder:"Enter Your Password",value:te,onChange:e=>ne(e.target.value)}),m.jsx(rA,Object.assign({onClick:()=>ae(e=>!e)},{children:m.jsx(xu,{icon:re?Po:Yo,color:"#979797"})}))]}),m.jsx(aA,Object.assign({disabled:!($&&te.length>0),onClick:()=>Z("SELECT"),style:{borderRadius:"24px"}},{children:"Next"}))]}),"SELECT"===K&&m.jsxs(Jc,Object.assign({style:{border:"2px solid transparent",borderRadius:16,padding:"0px 20px"}},{children:[[{id:"WALLET",label:"Wallet",balance:"470,000"},{id:"OWEALTH",label:"Owealth",balance:"470,000"}].map(e=>m.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 24px",fontWeight:500,color:"#52525B",cursor:"pointer",width:"90%"},onClick:()=>se(e.id)},{children:[m.jsxs("label",Object.assign({style:{display:"flex",alignItems:"center",gap:8,color:"#52525B",fontWeight:400}},{children:[m.jsx("input",{type:"radio",name:"kudaAcct",checked:le===e.id,readOnly:!0}),e.label]})),m.jsx("span",{children:e.balance})]}),e.id)),m.jsx(aA,Object.assign({style:{margin:"24px",backgroundColor:"#41276D",borderRadius:"24px"},disabled:!le,onClick:()=>Z("OTP")},{children:"Pay Now"}))]})),"OTP"===K&&m.jsx(Tu,{otp:M,setOtp:R,setIsOtpModal:e=>{e||(h("CARD"),E("FORM"),Z("AUTH"))},paymentMethod:"KUDA"})]}),Re.includes("MOBILEMONEY")&&"MOBILEMONEY"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsx(mt,{}),"FORM"===ue&&m.jsxs(m.Fragment,{children:[m.jsx("label",Object.assign({style:{display:"block",fontWeight:400,marginBottom:8,color:"#454D54",fontSize:"14px"}},{children:"Choose Network"})),m.jsx(Vu,{selected:fe,onChange:e=>{de(e)},currency:null!==(c=null==t?void 0:t.countryCode)&&void 0!==c?c:"GHA"}),m.jsx("label",Object.assign({style:{display:"block",fontWeight:400,marginBottom:8,color:"#999999",fontSize:"14px"}},{children:"Phone number"})),m.jsx(kc,{type:"text",placeholder:"9012345678",value:Ae,onChange:e=>ge(e.target.value)}),m.jsx(Yc,Object.assign({onClick:()=>{lt()},disabled:!fe||Ae.length<10||oe,isDisable:!fe||Ae.length<10||oe},{children:oe?"Loading...":"Confirm"}))]}),"CALL"===ue&&"GMD"!==t.currencyCode&&"failed"!==(null==Ce?void 0:Ce.responseDetails.responseMessage.toLowerCase())&&m.jsxs(m.Fragment,{children:[m.jsxs("div",Object.assign({style:{textAlign:"center",margin:"40px 0"}},{children:[m.jsx("div",Object.assign({style:{width:80,height:80,borderRadius:"50%",backgroundColor:"#4f46e5",display:"flex",justifyContent:"center",alignItems:"center",margin:"0 auto 20px"}},{children:m.jsx("span",Object.assign({style:{fontSize:32,color:"white"}},{children:"📞"}))})),m.jsx("p",Object.assign({style:{color:"#a1a1aa",fontSize:"14px"}},{children:"Please kindly complete the payment on your mobile phone"}))]})),!Fe&&"dev"===tt&&"GMD"!==t.currencyCode&&m.jsx(Yc,Object.assign({onClick:()=>{it()}},{children:"Verify Payment"})),"dev"===tt&&Fe&&"GMD"!==t.currencyCode&&m.jsx(Yc,Object.assign({onClick:()=>{st()}},{children:"I have made this payment"})),"prod"===tt&&"GMD"!==t.currencyCode&&m.jsx(Yc,Object.assign({onClick:()=>{st()}},{children:"I have made this payment"}))]}),"SUCCESS"===ue&&m.jsxs("div",Object.assign({style:{textAlign:"center"}},{children:[m.jsx(Uu,{}),m.jsx("h3",{children:"Transaction Successful"}),m.jsx("p",Object.assign({style:{color:"#666666",fontSize:"14px"}},{children:"Your payment has been successfully completed"}))]})),"FAILED"===ue&&m.jsxs("div",Object.assign({style:{textAlign:"center",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column"}},{children:[m.jsx(vc,{children:"✕"}),m.jsx("h3",{children:"Transaction Failed"}),m.jsx("p",Object.assign({style:{color:"#666666",fontSize:"14px"}},{children:"Your payment was not successful"})),m.jsx(aA,Object.assign({onClick:()=>{h("MOBILEMONEY"),ce("FORM"),de(""),ge("")},style:{marginTop:24}},{children:"Try Again"}))]}))]})]})]}),m.jsxs(gA,{children:[m.jsx("span",Object.assign({style:{fontWeight:600,color:"rgb(40, 17, 156)"}},{children:"We accept:"})),m.jsxs(fA,{children:[m.jsx(Zu,{width:"40",height:"30"}),m.jsx(Ju,{width:"40",height:"30"}),m.jsx(_u,{width:"40",height:"30"}),m.jsx($u,{width:"40",height:"30"}),m.jsx(ec,{width:"40",height:"30"})]})]}),m.jsxs(Uc,{children:[m.jsx(Xn,{}),m.jsxs(Hc,{children:[m.jsx("span",Object.assign({style:{fontWeight:400,margin:"0px 5px",color:"#000"}},{children:"secured by"})),m.jsx("span",Object.assign({style:{color:"#28119C"}},{children:"Blusalt"}))]})]}),f&&m.jsx(Qc,{onClick:()=>d(!1)})]}),Ge&&m.jsx(Bc,{reason:null==we?void 0:we.message,merchantSiteUrl:null==t?void 0:t.redirectUrl,transactionRef:null==t?void 0:t.transactionRef,onSuccess:r}),Ye&&m.jsx(wc,{reason:null==we?void 0:we.message,merchantSiteUrl:null==t?void 0:t.redirectUrl,handleReset:gt,handleSelectedMethod:()=>{E("FORM"),h("CARD")},onError:a}),qe&&Ze&&m.jsx(Ic,{children:m.jsx(BA,{ref:_e,src:Ze,allow:"fullscreen"})}),X&&pe&&m.jsx(Ic,{children:m.jsx(BA,{ref:$e,src:pe,allow:"fullscreen"})}),g()]}):m.jsx(Bt,{})},vA={setup:e=>{const{targetId:t,props:n}=e,r=document.getElementById(t);r?M.render?M.render(m.jsx(CA,Object.assign({},n)),r):console.error("Paygate SDK: No valid ReactDOM rendering method found."):console.error(`Paygate SDK: Element with id "${t}" not found.`)}};"undefined"!=typeof window&&(window.PaygateCheckoutSDK=window.PaygateCheckoutSDK||{PaygateSdk:vA})}();
|
|
804
|
+
`,CA=e=>{let{userData:t,config:n,onSuccess:r,onError:a}=e;var o,i,l,s,u,c;const{showSnackbar:A,SnackbarUI:g}=mc(),[f,d]=_.useState(!1),[p,h]=_.useState(""),[B,C]=_.useState(!1),[v,y]=_.useState({number:"",expiryMonth:"",expiryYear:"",cvv:"",cardHolderName:"",productDescription:""}),[b,w]=_.useState(""),[I,E]=_.useState("FORM"),[x,Q]=_.useState(["","","",""]),[M,R]=_.useState(["","","","","",""]),[D,k]=_.useState("AUTH"),[j,P]=_.useState(""),[Y,O]=_.useState(""),[G,N]=_.useState(!1),[F,z]=_.useState("AUTH"),[T,L]=_.useState(""),[U,H]=_.useState(""),[V,W]=_.useState(!1),[X,q]=_.useState(!1),[K,Z]=_.useState("AUTH"),[$,ee]=_.useState(""),[te,ne]=_.useState(""),[re,ae]=_.useState(!1),[oe,ie]=_.useState(!1),[le,se]=_.useState(""),[ue,ce]=_.useState("FORM"),[Ae,ge]=_.useState(""),[fe,de]=_.useState(""),[pe,he]=_.useState(""),[me,Be]=_.useState({message:"",success:!1}),[Ce,ve]=_.useState(),[ye,be]=_.useState(),[we,Ie]=_.useState(),[Ee,xe]=_.useState(!1),[Qe,Me]=_.useState(0),[Re,Se]=_.useState([]),[De,ke]=_.useState(),[je,Pe]=_.useState(null),[Ye,Oe]=_.useState(!1),[Ge,Ne]=_.useState(!1),[Fe,ze]=_.useState(!1),Te=_.useRef([]),Le=_.useRef(null),Ue=_.useRef(null),He=_.useRef(null),Ve=_.useRef(null),We=_.useRef(null),Xe=_.useRef(null),[qe,Ke]=_.useState(!1),[Ze,Je]=_.useState(null),_e=_.useRef(null),$e=_.useRef(null),et=Xu(null!==(o=null==t?void 0:t.merchantPublicKey)&&void 0!==o?o:""),tt="live"===(null===(i=null==n?void 0:n.environment)||void 0===i?void 0:i.toLowerCase())?"prod":"dev",nt=[{label:"Bank card",value:"CARD",icon:Dn},{label:"USSD",value:"USSD",icon:kn},{label:"Bank transfer",value:"BANKTRANSFER",icon:jn},{label:"NQR",value:"NQR",icon:Pn},{label:"Pay with Opay",value:"OPAY",icon:Nn},{label:"Pay with PalmPay",value:"PALMPAY",icon:Ln},{label:"Pay with Kuda",value:"KUDA",icon:Wn},{label:"Mobile Money",value:"MOBILEMONEY",icon:Lu}],rt={visa:m.jsx(Zu,{}),mastercard:m.jsx(Ju,{}),verve:m.jsx(_u,{}),"american-express":m.jsx($u,{}),discover:m.jsx(ec,{})},at=e=>{const{name:t,value:n}=e.target;if("number"===t){const e=n.replace(/\D/g,"").slice(0,19),t=e.replace(/(.{4})/g,"$1 ").trim();y(e=>Object.assign(Object.assign({},e),{number:t}));const r=J(e),a=(e=>{const t=e.replace(/\s+/g,"").slice(0,6);return/^5061\d{2}/.test(t)||/^5078\d{2}/.test(t)||/^6500\d{2}/.test(t)||/^628051/.test(t)})(e);return a?Pe("verve"):r.length?Pe(r[0].type):Pe(null),void(e.length>=16&&Le.current&&Le.current.focus())}if("expiryMonth"===t){const e=n.replace(/\D/g,"").slice(0,2);return y(t=>Object.assign(Object.assign({},t),{expiryMonth:e})),void(2===e.length&&Ue.current&&Ue.current.focus())}if("expiryYear"===t){const e=n.replace(/\D/g,"").slice(0,2),t=v.expiryYear;return y(t=>Object.assign(Object.assign({},t),{expiryYear:e})),2===e.length&&He.current&&He.current.focus(),void(1===t.length&&""===e&&Le.current&&Le.current.focus())}if("cvv"===t){const e="american-express"===je?4:3,t=n.replace(/\D/g,"").slice(0,e),r=v.cvv;return y(e=>Object.assign(Object.assign({},e),{cvv:t})),void(1===r.length&&""===t&&Ue.current&&Ue.current.focus())}y(e=>Object.assign(Object.assign({},e),{[t]:n}))},ot=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e,n,r,a,o,i,l,s,u;const c=x.join(""),g=v.number.replaceAll(" ","")||(null===(e=Ve.current)||void 0===e?void 0:e.value.replaceAll(" ",""));ie(!0);try{const e={client_transaction_reference:null==t?void 0:t.transactionRef,amount:parseFloat(t.amount.toString()),currency:t.currencyCode,card_number:g,card_expiry_month:v.expiryMonth||(null===(n=Le.current)||void 0===n?void 0:n.value),card_expiry_year:`20${v.expiryYear||(null===(r=Ue.current)||void 0===r?void 0:r.value)}`,card_cvv:v.cvv||(null===(a=He.current)||void 0===a?void 0:a.value),card_pin:"verve"===je?c:void 0,card_holder_name:v.cardHolderName||(null===(o=We.current)||void 0===o?void 0:o.value),customer_email:t.email,customer_phone_number:"+"+t.phoneNumber,customer_address:t.customerAddress,customer_first_name:t.firstName,customer_last_name:t.lastName,customer_city:t.customerCity,customer_state:t.customerState,customer_country:t.customerCountry,customer_postal_code:t.customerPostalCode,payment_description:v.productDescription,device_signature:t.deviceSignature,ip_address:t.ipAddress,metadata_order_id:t.metadataOrderId,metadata_product_info:t.metadataProductInfo},i=yield lo.post(`https://card.${tt}.mypaygate.co/api/v1/checkout-sdk/charge`,e,{headers:{"Content-Type":"application/json","X-Business-API-Key":"SK-24-5871083f656e4572-yTKxOX7-k6UI3eVFBm8mfNP0VIrE5A8R"}});i.status&&Ie(i.data)}catch(e){console.error("Payment Error:",(null===(i=e.response)||void 0===i?void 0:i.data)||e.message),Ie(null===(l=e.response)||void 0===l?void 0:l.data),A("error",null===(s=e.response)||void 0===s?void 0:s.data.error_code,null===(u=e.response)||void 0===u?void 0:u.data.message)}finally{ie(!1)}}),[x]),it=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e,n,r,a,o;ie(!0);try{const{data:o}=yield lo.post(`https://subsidiary.${tt}.mypaygate.co/collection/v1/simulate-payin`,{requestHeader:{clientId:"",requestType:"GHS"===(null===(e=t.transactionCurrency)||void 0===e?void 0:e.toUpperCase())?"GH":(null===(n=t.transactionCurrency)||void 0===n?void 0:n.toUpperCase())+"-Collections"},transactionReference:null==t?void 0:t.transactionRef,transactionCountry:"GHA"===(null===(r=t.countryCode)||void 0===r?void 0:r.toUpperCase())?"GH":null===(a=t.countryCode)||void 0===a?void 0:a.toUpperCase()},{headers:{Accept:"application/json","Content-Type":"application/json"}});return"success"==o.responseMessage.toLowerCase()&&ze(!0),o}catch(e){console.error("Simulate PayIn Error:",(null===(o=e.response)||void 0===o?void 0:o.data)||e.message)}finally{ie(!1)}}),[null==t?void 0:t.transactionRef]),lt=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e,n,r,a,o;ie(!0);try{const{data:o}=yield lo.post(`https://subsidiary.${tt}.mypaygate.co/collection/v1/payin`,{requestHeader:{clientId:t.clientId,requestType:"Collections"},customerName:t.firstName+t.lastName,customerEmail:t.email,customerNumber:Ae,transactionReference:null==t?void 0:t.transactionRef,transactionDescription:"",transactionAmount:t.amount,transactionCurrency:t.transactionCurrency,transactionCountry:"GHA"===(null===(e=t.countryCode)||void 0===e?void 0:e.toUpperCase())?"GH":"GMB"===(null===(n=t.countryCode)||void 0===n?void 0:n.toUpperCase())?"GM":null===(r=t.countryCode)||void 0===r?void 0:r.toUpperCase(),successUrl:"",errorUrl:"",cancelUrl:"",operatorCode:null!=fe?fe:"",webhookUrl:null!==(a=null==t?void 0:t.webhookUrl)&&void 0!==a?a:""},{headers:{Accept:"application/json","X-module":Wu(t.amount,null==t?void 0:t.transactionRef,Ae.toString()),"X-business":et,"X-app":"checkout","Content-Type":"application/json"}});ve(o),(null==o?void 0:o.paymentCompletionRequired)&&(he(null==o?void 0:o.paymentCompletionUrl),q(!0)),"GMD"!==t.currencyCode&&"failed"!==o.responseDetails.responseMessage.toLowerCase()?ce("CALL"):A("error",o.responseDetails.failedReason,"Please check your account details and try again")}catch(e){console.error("PayIn Error:",(null===(o=e.response)||void 0===o?void 0:o.data)||e.message)}finally{ie(!1)}}),[Ae]),st=()=>S(void 0,void 0,void 0,function*(){var e,n;let r;ie(!0),t.transactionRef&&(r=Xu(t.transactionRef));const a=Xu(null!==(e=t.merchantPublicKey)&&void 0!==e?e:""),o={requestHeader:{clientId:"",requestType:"GH-Collections"},transactionReference:t.transactionRef,transactionCountry:"GH"};try{const{data:e}=yield lo.post(`https://subsidiary.${tt}.mypaygate.co/collection/v1/check-status`,o,{headers:{Accept:"application/json","Content-Type":"application/json","X-module":r,"X-business":a,"X-app":"checkout"}});return"SUCCESS"!==e.serverResponse.responseDetails.responseMessage?ce("FAILED"):ce("SUCCESS"),e}catch(e){throw console.error("Error checking status:",(null===(n=e.response)||void 0===n?void 0:n.data)||e.message),e}finally{ie(!1)}}),ut=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e;try{const n=`https://va.${tt}.mypaygate.co/api/v1/account/dynamic/generate`,r={creationRef:null==t?void 0:t.transactionRef,source:"CHECKOUT",category:"Collection",channel:"Bank Transfer",currency:null==t?void 0:t.currencyCode,firstName:null==t?void 0:t.firstName,lastName:null==t?void 0:t.lastName,email:null==t?void 0:t.email,phone:null==t?void 0:t.phoneNumber,amount:null===(e=null==ye?void 0:ye.data)||void 0===e?void 0:e.transaction_amount},a=yield lo.post(n,r,{headers:{"x-api-key":et}});ke(a.data)}catch(e){console.error("handleVirtualAccount error --\x3e ",e)}}),[null===(l=null==ye?void 0:ye.data)||void 0===l?void 0:l.transaction_amount,null==t?void 0:t.email,null==t?void 0:t.firstName,null==t?void 0:t.lastName,null==t?void 0:t.phoneNumber]),ct=_.useCallback(()=>{if(t.transactionRef)return Xe.current=t.transactionRef,t.transactionRef},[t.transactionRef]),At=_.useCallback(()=>S(void 0,void 0,void 0,function*(){try{const e={redirect_url:null==t?void 0:t.redirectUrl,merchant_key:"",merchant_reference:null==t?void 0:t.merchantReference,biller_name:"",branch_id:"",payment_link_id:"",transaction_reference:null==t?void 0:t.transactionRef,checkout_amount:null==t?void 0:t.amount,currency_code:null==t?void 0:t.currencyCode,first_name:null==t?void 0:t.firstName,last_name:null==t?void 0:t.lastName,email_address:null==t?void 0:t.email,phone_number:null==t?void 0:t.phoneNumber,country_code:null==t?void 0:t.countryCode,payment_channel:"",additional_details:{}},{data:n}=yield lo.post(`https://checkout-be.${tt}.mypaygate.co/checkout`,e,{headers:{"Content-Type":"application/json",Authorization:et}});n.status&&be(n)}catch(e){console.error("")}}),[]),gt=()=>{y({number:"",expiryMonth:"",expiryYear:"",cvv:"",cardHolderName:"",productDescription:""}),Q(["","","",""]),R(["","","","","",""]),w(""),k("AUTH"),P(""),O(""),N(!1),z("AUTH"),L(""),H(""),W(!1),Z("AUTH"),ee(""),ne(""),ae(!1),se(""),ce("FORM"),ge(""),de(""),Be({message:"",success:!1}),ve(void 0),ke(void 0),C(!1),Je(null),Ke(!1),Ne(!1),Oe(!1),xe(!1),Me(0),ze(!1)},ft=_.useCallback(()=>S(void 0,void 0,void 0,function*(){var e;try{const n=`https://va.${tt}.mypaygate.co/api/v1/account/funding/simulate`,{data:r}=yield lo.post(n,{accountReference:null==t?void 0:t.transactionRef,amount:null===(e=null==ye?void 0:ye.data)||void 0===e?void 0:e.transaction_amount},{headers:{"x-api-key":et}});Be(r)}catch(e){console.error("fund_virtual_account error --\x3e ",e)}}),[De]),dt=_.useCallback(e=>S(void 0,void 0,void 0,function*(){try{const n=`https://card.${tt}.mypaygate.co/api/v1/checkout-sdk/complete-otp`,r={transaction_reference:Xe.current,otp_code:e};"SUCCESSFUL"===(yield lo.post(n,r,{headers:{"Content-Type":"application/json","X-Internal-API-Key":"checkout-sdk-key-101112","X-Business-API-Key":t.merchantPublicKey}})).data.status&&Ne(!0)}catch(e){console.error("handleOtp error -> ",e)}}),[]),pt=()=>{var e,t,n,r,a,o;const i=v.number.replace(/\s/g,"")||(null===(t=null===(e=Ve.current)||void 0===e?void 0:e.value)||void 0===t?void 0:t.replace(/\s/g,"")),l=v.expiryMonth||(null===(n=Le.current)||void 0===n?void 0:n.value),s=v.expiryYear||(null===(r=Ue.current)||void 0===r?void 0:r.value),u=v.cvv||(null===(a=He.current)||void 0===a?void 0:a.value),c=v.cardHolderName||(null===(o=We.current)||void 0===o?void 0:o.value);return!!i&&i.length>=16&&!!l&&2===l.length&&!!s&&2===s.length&&!!u&&(3===u.length||"american-express"===je&&4===u.length)&&!!c},ht=e=>{if(!(null==e?void 0:e.success)||!e.responseData)return 0;const t=e.responseData.dateExpired,n=e.responseData.expiry;if(t){const e=Date.parse(t.replace(" ","T"));if(!Number.isNaN(e))return Math.max(0,Math.floor((e-Date.now())/1e3))}return"number"==typeof n&&n>0?60*n:0};_.useEffect(()=>{At(),ze(!1)},[]),_.useEffect(()=>{if(De)if(De.success){const e=ht(De);Me(e),xe(e>0)}else xe(!1)},[De]),_.useEffect(()=>{if(!Ee)return;const e=setInterval(()=>{Me(t=>t<=1?(clearInterval(e),xe(!1),0):t-1)},1e3);return()=>clearInterval(e)},[Ee]),_.useEffect(()=>{var e,t,n;let r=null!==(n=null===(t=null===(e=null==ye?void 0:ye.data)||void 0===e?void 0:e.payment_options)||void 0===t?void 0:t.map(e=>e.paymentOption))&&void 0!==n?n:[];Se(r),h(r[0])},[ye]),_.useEffect(()=>{"BANKTRANSFER"===p?(xe(!1),ut()):(xe(!1),Me(0))},[p,ut]),_.useEffect(()=>{if(!(null==De?void 0:De.success))return void xe(!1);const e=ht(De);Me(e),xe(e>0)},[De]),_.useEffect(()=>{(null==we?void 0:we.status)&&"verve"===je?C(!0):"PENDING_3DS"===(null==we?void 0:we.status)&&(null==we?void 0:we.redirect_url_3ds)?(Je(null==we?void 0:we.redirect_url_3ds),Ke(!0),A("info","3DS authentication","3DS authentication required. Please complete the challenge below.")):("SUCCESSFUL"===(null==we?void 0:we.status)&&Ne(!0),"FAILED"===(null==we?void 0:we.status)&&(Oe(!0),setTimeout(()=>{gt(),Oe(!1)},3e3)))},[we]),_.useEffect(()=>{("SUCCESS"===ue||me.success)&&(A("info","Redirection Notification","You will be redirected in 10 seconds"),null==r||r(),setTimeout(()=>{if((null==t?void 0:t.redirectUrl)&&(null==t?void 0:t.transactionRef)){const e=new URL(null==t?void 0:t.redirectUrl);e.searchParams.set("transactionRef",null==t?void 0:t.transactionRef),window.open(e,"_self")}},1e4))},[me,ue]);const mt=()=>m.jsxs(uA,Object.assign({bold:!0},{children:[m.jsx(cA,{children:"Total Amount"}),m.jsx(AA,{children:Ku((null==De?void 0:De.responseData.amountExpected)?null==De?void 0:De.responseData.amountExpected:t.amount,t.currencyCode)})]})),Bt=()=>m.jsxs(dA,{children:[m.jsx(mA,{}),m.jsx(pA,Object.assign({size:"18px",weight:500,style:{marginTop:"30px"}},{children:"Initializing SDK..."})),m.jsx(pA,Object.assign({size:"14px",weight:300},{children:"Setting up your secure payment environment."}))]});return ye?m.jsxs(m.Fragment,{children:[!Ge&&!Ye&&!qe&&!Ze&&!X&&m.jsxs(Ic,{children:[m.jsxs(Ec,{children:[m.jsxs(xc,Object.assign({open:f},{children:[m.jsx(Fc,{children:"Make Payment"}),m.jsx(Tc,{}),nt.filter(e=>Re.includes(e.value)).map(e=>{const t=e.icon,n=p===e.value;return m.jsxs(Rc,Object.assign({selected:n,onClick:()=>{gt(),h(e.value),E("FORM")},style:{backgroundColor:n?"#DED8FB":"transparent"}},{children:["string"==typeof t?m.jsx("img",{src:t||"/placeholder.svg",alt:`${e.label} icon`,style:{width:24,height:24,marginRight:8}}):m.jsx(t,{style:{marginRight:8,fontWeight:500},color:n?"#28119C":"#52525B"}),e.label]}),e.value)})]})),m.jsxs(Sc,{children:[m.jsxs(zc,{children:[m.jsx(Mc,Object.assign({onClick:()=>d(!0)},{children:m.jsx(Hu,{})})),"OTP"===K||"OTP"===F||"OTP"===D?m.jsxs(eA,{children:[m.jsx(oA,{children:"Enter OTP"}),m.jsxs(iA,{children:["A 6-digit code has been sent to your phone number"," "]})]}):"CARD"===p?m.jsxs(eA,{children:[m.jsx(_c,{children:"Pay with bank card"}),m.jsx($c,{children:"Enter your card details to pay"})]}):"USSD"===p?m.jsxs(eA,{children:[m.jsx(_c,{children:"Pay with USSD"}),m.jsx($c,{children:"Select a bank to get the USSD code"})]}):m.jsxs(eA,{children:[m.jsx(_c,{children:"Pay via transfer"}),m.jsx($c,{children:"Make the transfer to the account below"})]})]}),!["OPAY","PALMPAY","KUDA","MOBILEMONEY"].includes(p)&&"PIN"!==I&&m.jsx(mt,{}),Re.includes("CARD")&&"FORM"===I&&"CARD"===p&&m.jsx(m.Fragment,{children:!qe&&!Ze&&!X&&m.jsxs(m.Fragment,{children:[m.jsx(Vc,{children:"Card Number"}),m.jsxs(Pc,{children:[m.jsx(jc,{name:"number",placeholder:"0000 0000 0000 0000",value:v.number,onChange:at,ref:Ve,style:{marginBottom:"0"}}),je?rt[je]:m.jsx(tc,{})]}),m.jsxs(lA,{children:[m.jsxs("div",{children:[m.jsx(Vc,{children:"Expiry Date"}),m.jsxs("div",Object.assign({style:{display:"flex",width:"100px",justifyContent:"space-between",alignItems:"center",maxWidth:"100px"}},{children:[m.jsx(sA,Object.assign({width:"40px",style:{maxWidth:"30px",minWidth:"30px"},withSlash:!0},{children:m.jsx(kc,{name:"expiryMonth",placeholder:"MM",maxLength:2,ref:Le,value:v.expiryMonth,onChange:at,style:{marginBottom:"0"}})})),m.jsx(sA,Object.assign({width:"40px",style:{maxWidth:"30px",minWidth:"30px"}},{children:m.jsx(kc,{name:"expiryYear",placeholder:"YY",maxLength:2,ref:Ue,value:v.expiryYear,onChange:at,style:{marginBottom:"0"}})}))]}))]}),m.jsxs(sA,Object.assign({width:"50px",style:{paddingRight:"24px",maxWidth:"50px",minWidth:"50px"}},{children:[m.jsx(Vc,{children:"CVV"}),m.jsx(kc,{name:"cvv",placeholder:"CVV",maxLength:4,ref:He,value:v.cvv,onChange:at,style:{marginBottom:"0"}})]}))]}),m.jsx(Vc,{children:"Card Holder Name"}),m.jsx(kc,{name:"cardHolderName",type:"text",placeholder:"Card Holder Name",value:v.cardHolderName,onChange:at,ref:We,style:{marginBottom:"0"}}),m.jsx(Vc,{children:"Description"}),m.jsx(kc,{name:"productDescription",type:"text",placeholder:"Product Description Optional",value:v.productDescription,onChange:at}),m.jsx(Yc,Object.assign({onClick:()=>{"verve"===je?E("PIN"):ot()},disabled:oe||!pt(),isDisable:oe||!pt()},{children:oe?"Loading...":"Confirm"}))]})}),"PIN"===I&&"verve"===je&&m.jsx(m.Fragment,{children:!B&&m.jsxs(m.Fragment,{children:[m.jsx(Dc,Object.assign({style:{width:"100%",textAlign:"center"}},{children:"Card Pin"})),m.jsx(Gc,{children:x.map((e,t)=>m.jsx(Nc,{ref:e=>{Te.current[t]=e},type:"password",maxLength:1,value:e,onChange:e=>{var n;((e,t)=>{const n=[...x];n[e]=t,Q(n)})(t,e.target.value),e.target.value&&t<x.length-1&&(null===(n=Te.current[t+1])||void 0===n||n.focus())}},t))}),!(null==we?void 0:we.message.includes("Duplicate transaction reference"))&&m.jsx(Yc,Object.assign({onClick:()=>{ot()},disabled:oe},{children:oe?"Loading...":"Confirm"}))]})}),B&&m.jsx(Tu,{setIsOtpModal:C,setOtp:R,otp:M,paymentMethod:"CARD",handleOtp:dt}),(null==we?void 0:we.message.includes("Duplicate transaction reference"))&&m.jsx(Yc,Object.assign({onClick:()=>{ct(),ot()},disabled:oe},{children:oe?"Loading...":"Try Again"})),Re.includes("USSD")&&"USSD"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsx(Dc,{children:"Choose bank"}),m.jsx(xo,{selected:b,onChange:w,currency:"GH"}),b&&m.jsxs(m.Fragment,{children:[m.jsxs(Oc,{children:[m.jsx("span",{children:"*737*000*1234#"}),m.jsx(qn,{})]}),m.jsx("p",Object.assign({style:{fontSize:"14px",marginTop:"8px",textAlign:"center",color:"#666666"}},{children:"Tap on the code to dial"})),m.jsx(Yc,{children:"I have made this payment"})]})]}),Re.includes("BANKTRANSFER")&&"FORM"===I&&"BANKTRANSFER"===p&&m.jsxs(m.Fragment,{children:[!me.success&&m.jsx(Dc,{children:"Transfer to the account below"}),me.success?m.jsxs(Wc,Object.assign({style:{textAlign:"center"}},{children:[m.jsx(Uu,{}),m.jsx("h3",{children:me.message}),m.jsx("p",Object.assign({style:{color:"#666666",fontSize:"14px"}},{children:"Your payment has been successfully completed"}))]})):m.jsxs(Wc,{children:[m.jsxs(Xc,Object.assign({$isLast:!1},{children:[m.jsx("span",Object.assign({className:"label"},{children:"ACCOUNT NUMBER"})),m.jsxs("span",Object.assign({className:"value"},{children:[null===(s=null==De?void 0:De.responseData)||void 0===s?void 0:s.accountNumber,m.jsx(qn,{})]}))]})),m.jsxs(Xc,Object.assign({$isLast:!1},{children:[m.jsx("span",Object.assign({className:"label"},{children:"BANK NAME"})),m.jsx("span",Object.assign({className:"value"},{children:null===(u=null==De?void 0:De.responseData)||void 0===u?void 0:u.bankName}))]})),m.jsxs(qc,{children:[m.jsx(Qo,{}),m.jsx("span",{children:"Account number only valid for this transaction"})]})]}),!me.success&&m.jsxs(m.Fragment,{children:[m.jsxs(Kc,{children:[m.jsx(Mo,{}),m.jsx("span",{children:Qe>0?(e=>{const t=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`})(Qe):"Expired"})]}),m.jsx(Yc,Object.assign({onClick:()=>ft(),disabled:Qe<=0},{children:"I have made this payment"}))]})]}),Re.includes("NQR")&&"NQR"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsx(Dc,Object.assign({style:{textAlign:"center"}},{children:"Scan the QR code to make payment"})),m.jsx(Zc,{children:m.jsx(Ro,{})}),m.jsx(Yc,{children:"I have made this payment"})]}),Re.includes("OPAY")&&"OPAY"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsxs(Lc,Object.assign({style:{flexDirection:"column",alignItems:"flex-start"}},{children:[m.jsx(mt,{}),m.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",width:"100%",marginTop:8}},{children:[m.jsx("span",Object.assign({style:{color:"#71717A"}},{children:"Merchant Name"})),m.jsx("span",Object.assign({style:{fontWeight:600}},{children:null==t?void 0:t.merchantName}))]}))]})),m.jsx("div",Object.assign({style:{textAlign:"center",marginBottom:24,display:"flex",alignItems:"center",justifyContent:"center",width:"100%"}},{children:m.jsx("img",{src:jo||"/placeholder.svg",alt:""})})),"AUTH"===D&&m.jsxs(m.Fragment,{children:[m.jsx("p",Object.assign({style:{textAlign:"center",marginBottom:24}},{children:"Click the button below to authenticate with your bank"})),m.jsx(Yc,Object.assign({onClick:()=>k("CREDS")},{children:"Authenticate"}))]}),"CREDS"===D&&m.jsxs(Jc,{children:[m.jsx(tA,{placeholder:"Enter Your Ten Digit Phone Number",value:j,onChange:e=>P(e.target.value)}),m.jsxs(nA,{children:[m.jsx(tA,{type:G?"text":"password",placeholder:"Enter your 6-digit Opay password",value:Y,onChange:e=>O(e.target.value)}),m.jsx(rA,Object.assign({onClick:()=>N(e=>!e)},{children:m.jsx(xu,{icon:G?Po:Yo,color:"#979797",fontWeight:500})}))]}),m.jsx(aA,Object.assign({disabled:!(j&&6===Y.length),onClick:()=>k("OTP"),style:{borderRadius:"24px"}},{children:"Next"}))]}),"OTP"===D&&m.jsx(Tu,{otp:M,setOtp:R,setIsOtpModal:e=>{e||(h("CARD"),E("FORM"),k("AUTH"))},paymentMethod:"OPAY"})]}),Re.includes("PALMPAY")&&"PALMPAY"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsxs(Lc,Object.assign({style:{flexDirection:"column",alignItems:"flex-start"}},{children:[m.jsx(mt,{}),m.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",width:"100%",marginTop:8}},{children:[m.jsx("span",Object.assign({style:{color:"#71717A"}},{children:"Merchant Name"})),m.jsx("span",Object.assign({style:{fontWeight:600}},{children:null==t?void 0:t.merchantName}))]}))]})),m.jsx("div",Object.assign({style:{textAlign:"center",marginBottom:24,display:"flex",alignItems:"center",justifyContent:"center",width:"100%"}},{children:m.jsx("img",{src:Du||"/placeholder.svg",alt:"PalmpayIcon"})})),"AUTH"===F&&m.jsxs(m.Fragment,{children:[m.jsx("p",Object.assign({style:{textAlign:"center",marginBottom:24}},{children:"Click the button below to authenticate with your bank"})),m.jsx(Yc,Object.assign({onClick:()=>z("CREDS")},{children:"Authenticate"}))]}),"CREDS"===F&&m.jsxs(Jc,{children:[m.jsx(tA,{placeholder:"Enter Your Ten Digit Phone Number",value:T,onChange:e=>L(e.target.value)}),m.jsxs(nA,{children:[m.jsx(tA,{type:V?"text":"password",placeholder:"Enter your 6-digit Password for your PalmPay account",value:U,onChange:e=>H(e.target.value)}),m.jsx(rA,Object.assign({onClick:()=>W(e=>!e)},{children:m.jsx(xu,{icon:V?Po:Yo,color:"#979797"})}))]}),m.jsx(aA,Object.assign({disabled:!(T&&6===U.length),onClick:()=>z("OTP"),style:{borderRadius:"24px"}},{children:"Next"}))]}),"OTP"===F&&m.jsx(Tu,{otp:M,setOtp:R,setIsOtpModal:e=>{e||(h("CARD"),E("FORM"),z("AUTH"))},paymentMethod:"PALMPAY"})]}),Re.includes("KUDA")&&"KUDA"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsxs(Lc,Object.assign({style:{flexDirection:"column",alignItems:"flex-start"}},{children:[m.jsx(mt,{}),m.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",width:"100%",marginTop:8}},{children:[m.jsx("span",Object.assign({style:{color:"#71717A"}},{children:"Merchant Name"})),m.jsx("span",Object.assign({style:{fontWeight:600}},{children:null==t?void 0:t.merchantName}))]}))]})),m.jsx("div",Object.assign({style:{textAlign:"center",marginBottom:24,display:"flex",alignItems:"center",justifyContent:"center",width:"100%"}},{children:m.jsx("img",{src:Yu||"/placeholder.svg",alt:"Kuda"})})),"AUTH"===K&&m.jsxs(m.Fragment,{children:[m.jsx("p",Object.assign({style:{textAlign:"center",marginBottom:24}},{children:"Click the button below to authenticate with your bank"})),m.jsx(Yc,Object.assign({onClick:()=>Z("CREDS")},{children:"Authenticate"}))]}),"CREDS"===K&&m.jsxs(Jc,{children:[m.jsx(tA,{placeholder:"Enter Your Email",value:$,onChange:e=>ee(e.target.value)}),m.jsxs(nA,{children:[m.jsx(tA,{type:re?"text":"password",placeholder:"Enter Your Password",value:te,onChange:e=>ne(e.target.value)}),m.jsx(rA,Object.assign({onClick:()=>ae(e=>!e)},{children:m.jsx(xu,{icon:re?Po:Yo,color:"#979797"})}))]}),m.jsx(aA,Object.assign({disabled:!($&&te.length>0),onClick:()=>Z("SELECT"),style:{borderRadius:"24px"}},{children:"Next"}))]}),"SELECT"===K&&m.jsxs(Jc,Object.assign({style:{border:"2px solid transparent",borderRadius:16,padding:"0px 20px"}},{children:[[{id:"WALLET",label:"Wallet",balance:"470,000"},{id:"OWEALTH",label:"Owealth",balance:"470,000"}].map(e=>m.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 24px",fontWeight:500,color:"#52525B",cursor:"pointer",width:"90%"},onClick:()=>se(e.id)},{children:[m.jsxs("label",Object.assign({style:{display:"flex",alignItems:"center",gap:8,color:"#52525B",fontWeight:400}},{children:[m.jsx("input",{type:"radio",name:"kudaAcct",checked:le===e.id,readOnly:!0}),e.label]})),m.jsx("span",{children:e.balance})]}),e.id)),m.jsx(aA,Object.assign({style:{margin:"24px",backgroundColor:"#41276D",borderRadius:"24px"},disabled:!le,onClick:()=>Z("OTP")},{children:"Pay Now"}))]})),"OTP"===K&&m.jsx(Tu,{otp:M,setOtp:R,setIsOtpModal:e=>{e||(h("CARD"),E("FORM"),Z("AUTH"))},paymentMethod:"KUDA"})]}),Re.includes("MOBILEMONEY")&&"MOBILEMONEY"===p&&"FORM"===I&&m.jsxs(m.Fragment,{children:[m.jsx(mt,{}),"FORM"===ue&&m.jsxs(m.Fragment,{children:[m.jsx("label",Object.assign({style:{display:"block",fontWeight:400,marginBottom:8,color:"#454D54",fontSize:"14px"}},{children:"Choose Network"})),m.jsx(Vu,{selected:fe,onChange:e=>{de(e)},currency:null!==(c=null==t?void 0:t.countryCode)&&void 0!==c?c:"GHA"}),m.jsx("label",Object.assign({style:{display:"block",fontWeight:400,marginBottom:8,color:"#999999",fontSize:"14px"}},{children:"Phone number"})),m.jsx(kc,{type:"text",placeholder:"9012345678",value:Ae,onChange:e=>ge(e.target.value)}),m.jsx(Yc,Object.assign({onClick:()=>{lt()},disabled:!fe||Ae.length<10||oe,isDisable:!fe||Ae.length<10||oe},{children:oe?"Loading...":"Confirm"}))]}),"CALL"===ue&&"GMD"!==t.currencyCode&&"failed"!==(null==Ce?void 0:Ce.responseDetails.responseMessage.toLowerCase())&&m.jsxs(m.Fragment,{children:[m.jsxs("div",Object.assign({style:{textAlign:"center",margin:"40px 0"}},{children:[m.jsx("div",Object.assign({style:{width:80,height:80,borderRadius:"50%",backgroundColor:"#4f46e5",display:"flex",justifyContent:"center",alignItems:"center",margin:"0 auto 20px"}},{children:m.jsx("span",Object.assign({style:{fontSize:32,color:"white"}},{children:"📞"}))})),m.jsx("p",Object.assign({style:{color:"#a1a1aa",fontSize:"14px"}},{children:"Please kindly complete the payment on your mobile phone"}))]})),!Fe&&"dev"===tt&&"GMD"!==t.currencyCode&&m.jsx(Yc,Object.assign({onClick:()=>{it()}},{children:"Verify Payment"})),"dev"===tt&&Fe&&"GMD"!==t.currencyCode&&m.jsx(Yc,Object.assign({onClick:()=>{st()}},{children:"I have made this payment"})),"prod"===tt&&"GMD"!==t.currencyCode&&m.jsx(Yc,Object.assign({onClick:()=>{st()}},{children:"I have made this payment"}))]}),"SUCCESS"===ue&&m.jsxs("div",Object.assign({style:{textAlign:"center"}},{children:[m.jsx(Uu,{}),m.jsx("h3",{children:"Transaction Successful"}),m.jsx("p",Object.assign({style:{color:"#666666",fontSize:"14px"}},{children:"Your payment has been successfully completed"}))]})),"FAILED"===ue&&m.jsxs("div",Object.assign({style:{textAlign:"center",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column"}},{children:[m.jsx(vc,{children:"✕"}),m.jsx("h3",{children:"Transaction Failed"}),m.jsx("p",Object.assign({style:{color:"#666666",fontSize:"14px"}},{children:"Your payment was not successful"})),m.jsx(aA,Object.assign({onClick:()=>{h("MOBILEMONEY"),ce("FORM"),de(""),ge("")},style:{marginTop:24}},{children:"Try Again"}))]}))]})]})]}),m.jsxs(gA,{children:[m.jsx("span",Object.assign({style:{fontWeight:600,color:"rgb(40, 17, 156)"}},{children:"We accept:"})),m.jsxs(fA,{children:[m.jsx(Zu,{width:"40",height:"30"}),m.jsx(Ju,{width:"40",height:"30"}),m.jsx(_u,{width:"40",height:"30"}),m.jsx($u,{width:"40",height:"30"}),m.jsx(ec,{width:"40",height:"30"})]})]}),m.jsxs(Uc,{children:[m.jsx(Xn,{}),m.jsxs(Hc,{children:[m.jsx("span",Object.assign({style:{fontWeight:400,margin:"0px 5px",color:"#000"}},{children:"secured by"})),m.jsx("span",Object.assign({style:{color:"#28119C"}},{children:"Blusalt"}))]})]}),f&&m.jsx(Qc,{onClick:()=>d(!1)})]}),Ge&&m.jsx(Bc,{reason:null==we?void 0:we.message,merchantSiteUrl:null==t?void 0:t.redirectUrl,transactionRef:null==t?void 0:t.transactionRef,onSuccess:r}),Ye&&m.jsx(wc,{reason:null==we?void 0:we.message,merchantSiteUrl:null==t?void 0:t.redirectUrl,handleReset:gt,handleSelectedMethod:()=>{E("FORM"),h("CARD")},onError:a}),qe&&Ze&&m.jsx(Ic,{children:m.jsx(BA,{ref:_e,src:Ze,allow:"fullscreen"})}),X&&pe&&m.jsx(Ic,{children:m.jsx(BA,{ref:$e,src:pe,allow:"fullscreen"})}),g()]}):m.jsx(Bt,{})},vA={setup:e=>{const{targetId:t,props:n}=e,r=document.getElementById(t);r?M.render?M.render(m.jsx(CA,Object.assign({},n)),r):console.error("Paygate SDK: No valid ReactDOM rendering method found."):console.error(`Paygate SDK: Element with id "${t}" not found.`)}};"undefined"!=typeof window&&(window.PaygateCheckoutSDK=window.PaygateCheckoutSDK||{PaygateSdk:vA})}();
|
|
805
805
|
//# sourceMappingURL=index.iife.js.map
|