1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3624],{83624:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return x}});var r=n(85893),o=n(67294),i=n(86664),s=n(97894),a=n(87066),u=n(87669),c=n.n(u),d=n(5172),l=n(64187),m=n(93967),p=n.n(m),f=n(47568),h=n(97582),_=n(64487),g=n(54689),S=n(58218),v=n(81783),y=n(96486),C=function(e){var t=e.clientSecret,n=e.onClose,r=e.setLoadingState,s=(0,i.useStripe)(),a=(0,v.Z)().addNewCreditCard,u=(0,o.useState)({}),c=u[0],d=u[1],l=(0,o.useState)(t),m=l[0],p=l[1],C=(0,o.useState)(!1),w=C[0],Z=C[1],k=(0,o.useState)("addAccount"),A=k[0];k[1];var x,E=(0,o.useContext)(S.I).userDetails,b=(0,o.useState)(!1),j=b[0],B=b[1];return(0,o.useEffect)(function(){s&&!j&&s.collectBankAccountForSetup({clientSecret:t,params:{payment_method_type:"us_bank_account",payment_method_data:{billing_details:{name:null==E?void 0:E.contact_name,email:null==E?void 0:E.email}}},expand:["payment_method"]}).then(function(e){var t=e.setupIntent;if(e.error){g.Z.error({message:"Payment Setup Error",description:"An error occurred while setting up your payment. Please try again.",duration:2}),(0,y.isFunction)(n)&&n(),r(!1);return}if("succeeded"===t.status){B(!0),g.Z.success({message:"Bank account saved successfully"}),a({setup_intent_id:null==t?void 0:t.id},null,n),r(!1);return}"requires_confirmation"===t.status?(d({setup_intent_id:null==t?void 0:t.id}),p(null==t?void 0:t.client_secret),r(!0),s.confirmUsBankAccountSetup(t.client_secret).then(function(e){var t=e.setupIntent,o=e.error;if(o){g.Z.error({message:"Bank account setup confirmation failed",description:o.message||"An error occurred during confirmation.",duration:2}),r(!1);return}"requires_payment_method"===t.status?(g.Z.error({message:"Confirmation failed. Attempt again with a different payment method",duration:2}),r(!1)):"succeeded"===t.status&&(B(!0),a({setup_intent_id:null==t?void 0:t.id},null,n),r(!1))}).catch(function(e){g.Z.error({message:"Confirmation Error",description:"An error occurred during confirmation.",duration:2}),r(!1)})):"requires_payment_method"===t.status&&(g.Z.error({message:"Payment method required. Please provide a valid method.",duration:2}),r(!1),(0,y.isFunction)(n)&&n())}).catch(function(e){_.Tb(e),g.Z.error({message:"Setup Error",description:"An error occurred during the setup process.",duration:2}),r(!1)})},[s,t,E,r,n,j]),{handleConfirmationSubmit:(x=(0,f.Z)(function(e){var t,o,i;return(0,h.__generator)(this,function(i){switch(i.label){case 0:if(e.preventDefault(),!s||j)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,s.confirmUsBankAccountSetup(m)];case 2:return o=(t=i.sent()).setupIntent,t.error?(g.Z.error({message:"Confirmation failed",description:"Please try again with a different payment method.",duration:2}),r(!1)):"succeeded"===o.status&&(B(!0),a(c,null,n),Z(!1),r(!1)),[3,4];case 3:return i.sent(),g.Z.error({message:"Confirmation Error",description:"An error occurred during confirmation.",duration:2}),r(!1),[3,4];case 4:return[2]}})}),function(e){return x.apply(this,arguments)}),setShowModal:Z,showModal:w,showForm:A}};function w(e){var t=e.clientSecret,n=e.source,o=e.onClose,s=e.setLoadingState,a=(0,i.useStripe)(),u=(0,i.useElements)(),m=C({clientSecret:t,source:n,onClose:o,setLoadingState:s}),f=m.handleConfirmationSubmit,h=m.showForm,_=m.setShowModal,g=m.showModal;return(0,r.jsx)(r.Fragment,{children:"confirmation"===h&&(0,r.jsx)(l.Z,{open:g,onCancel:function(){_(!1),(0,y.isFunction)(o)&&o()},footer:!1,children:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{children:"Please confirm the mandate to proceed."}),(0,r.jsx)(d.Z,{htmlType:"submit",disabled:!a||!u,id:"submit",className:p()(c().updateBtn,"w-100"),theme:"primary",onClick:f,children:"Confirm"})]})})})}var Z=n(7898),k=n(72246),A=(0,s.loadStripe)("pk_live_51R6BtfG4gl7V24955WGrTtDkAX4ceLcUAAU0o0ifQOu6IWodLf8FLSdxRt08wSNrvTL9LweF7sdnyB3cElujhm47004hRX8dgM"),x=function(e){var t=e.source,n=e.onClose,s=(0,o.useState)(""),u=s[0],c=s[1],d=(0,o.useState)(!1),l=d[0],m=d[1];(0,o.useEffect)(function(){if("checkout"!==t)try{a.Z.post("/api/ERP/customer/stripe_customer",{headers:{sessionid:(0,Z.ej)("sessionid")}}).then(function(e){var t;a.Z.post("/api/stripe/create-setupIntent",{customerId:null===(t=e.data)||void 0===t?void 0:t.stripe_customer_id},{headers:{"Content-Type":"application/json"}}).then(function(e){var t;c(null===(t=e.data)||void 0===t?void 0:t.setupIntent.client_secret)})})}catch(e){console.log(e)}},[]);var p=(0,o.useMemo)(function(){return{clientSecret:u,appearance:{theme:"stripe"}}},[u]);return(0,r.jsx)(r.Fragment,{children:u&&(0,r.jsxs)(i.Elements,{options:p,stripe:A,children:[l&&(0,r.jsx)(k.Z,{}),(0,r.jsx)(w,{clientSecret:u,onClose:n,source:t,setLoadingState:m})]})})}},87669:function(e){e.exports={actionButtonsContainer:"style_actionButtonsContainer__VF8KZ",errorMessage:"style_errorMessage__tY6eP",updateBtn:"style_updateBtn__AEWwi"}}}]); 2//# sourceMappingURL=3624.707c5fef2b498792.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.