1"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[3314],{42534:(e,t,r)=>{r.r(t),r.d(t,{default:()=>w});var a=r(89379),s=r(65043),n=r(50805),o=r(97508),i=r(24141),d=r(41233),l=(r(44356),r(43798)),m=r(28233),h=r(44104),c=r(18689),u=r(71702),p=r(37614),y=r(80045),P=r(77775),g=r(98139),M=r.n(g),_=r(63775);const f={root:"PaymentMethodsForm_root__-1fCv",card:"PaymentMethodsForm_card__rHQyr marketplaceInputStyles",cardError:"PaymentMethodsForm_cardError__Xhgft",error:"PaymentMethodsForm_error__b1XqH",errorMessage:"PaymentMethodsForm_errorMessage__BIEev",paymentHeading:"PaymentMethodsForm_paymentHeading__Xl7Ut",messageHeading:"PaymentMethodsForm_messageHeading__8hMaa",messageLabel:"PaymentMethodsForm_messageLabel__dj1hS",messageOptional:"PaymentMethodsForm_messageOptional__fk-u8",message:"PaymentMethodsForm_message__H0qvH",submitContainer:"PaymentMethodsForm_submitContainer__wjrCs",infoText:"PaymentMethodsForm_infoText__ticq9 h5",submitButton:"PaymentMethodsForm_submitButton__P1-U2",missingStripeKey:"PaymentMethodsForm_missingStripeKey__wmc2g",paymentAddressField:"PaymentMethodsForm_paymentAddressField__O0OE8",formRow:"PaymentMethodsForm_formRow__jyGPf",postalCode:"PaymentMethodsForm_postalCode__7CzHZ",city:"PaymentMethodsForm_city__yhbbL",field:"PaymentMethodsForm_field__dHnKQ"};var b=r(70579);const C=["onSubmit"],S=(e,t)=>{const{message:r,code:a,type:s}=t;if(!a||!s)return e.formatMessage({id:"PaymentMethodsForm.genericError"});const n="validation_error"===s?"PaymentMethodsForm.stripe.validation_error.".concat(a):"PaymentMethodsForm.stripe.".concat(s);return e.formatMessage({id:n,defaultMessage:r})},F={fonts:[{cssSrc:"https://fonts.googleapis.com/css?family=Inter"}]},x={base:{fontFamily:'-apple-system, BlinkMacSystemFont, "Inter var", Helvetica, Arial, sans-serif',fontSize:"undefined"!==typeof window&&window.innerWidth<768?"14px":"16px",fontSmoothing:"antialiased",lineHeight:"24px",letterSpacing:"-0.1px",color:"#4A4A4A","::placeholder":{color:"#B2B2B2"}}},E={error:null,cardValueValid:!1};
1class j extends s.Component{constructor(e){super(e),this.state=E,this.handleCardValueChange=this.handleCardValueChange.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.paymentForm=this.paymentForm.bind(this),this.finalFormAPI=null,this.stripe=null}componentDidMount(){var e,t;if(!window.Stripe)throw new Error("Stripe must be loaded for PaymentMethodsForm");const r=null===(e=this.props.config)||void 0===e||null===(t=e.stripe)||void 0===t?void 0:t.publishableKey;if(r){this.stripe=window.Stripe(r);const e=this.stripe.elements(F);this.card=e.create("card",{style:x}),this.card.mount(this.cardContainer),this.card.addEventListener("change",this.handleCardValueChange),window.addEventListener("resize",(()=>{window.innerWidth<768?this.card.update({style:{base:{fontSize:"14px",lineHeight:"24px"}}}):this.card.update({style:{base:{fontSize:"18px",lineHeight:"24px"}}})}))}}componentWillUnmount(){this.card&&(this.card.removeEventListener("change",this.handleCardValueChange),this.card.unmount())}handleCardValueChange(e){const{intl:t}=this.props,{error:r,complete:a}=e,s=e.value.postalCode;this.finalFormAPI&&this.finalFormAPI.change("postal",s),this.setState((e=>({error:r?S(t,r):null,cardValueValid:a})))}handleSubmit(e){const{onSubmit:t,inProgress:r,formId:a}=this.props,s=!this.state.cardValueValid;if(r||s)return;t({stripe:this.stripe,card:this.card,formId:a,formValues:e})}paymentForm(e){const{className:t,rootClassName:r,inProgress:a,formId:s,intl:n,invalid:o,handleSubmit:d,addPaymentMethodError:l,deletePaymentMethodError:m,createStripeCustomerError:h,handleCardSetupError:u,form:p,config:y}=e;this.finalFormAPI=p;const P=!this.state.cardValueValid,g=o||P||a,_=this.state.error&&!a,C=M()(r||f.root,t),S=M()(f.card,{[f.cardSuccess]:this.state.cardValueValid,[f.cardError]:_}),F=l||m||h||u,x=n.formatMessage({id:"PaymentMethodsForm.genericError"}),E=n.formatMessage({id:"PaymentMethodsForm.billingDetailsNameLabel"}),j=n.formatMessage({id:"PaymentMethodsForm.billingDetailsNamePlaceholder"}),v=n.formatMessage({id:"PaymentMethodsForm.infoText"},{marketplaceName:y.marketplaceName}),A=(0,b.jsx)(c.a1,{intl:n,form:p,fieldId:s,card:this.card,locale:y.localization.locale});return y.stripe.publishableKey?(0,b.jsxs)(c.lV,{className:C,onSubmit:d,children:[(0,b.jsx)("label",{className:f.paymentLabel,htmlFor:"".concat(s,"-card"),children:(0,b.jsx)(i.sA,{id:"PaymentMethodsForm.paymentCardDetails"})}),(0,b.jsx)("div",{className:S,id:"".concat(s,"-card"),ref:e=>{this.cardContainer=e}}),(0,b.jsx)("div",{className:f.infoText,children:v}),_?(0,b.jsx)("span",{className:f.error,children:this.state.error}):null,(0,b.jsxs)("div",{className:f.paymentAddressField,children:[(0,b.jsx)(c.H4,{as:"h3",children:(0,b.jsx)(i.sA,{id:"PaymentMethodsForm.billingDetails"})}),(0,b.jsx)(c.k7,{className:f.field,type:"text",id:"name",name:"name",autoComplete:"cc-name",label:E,placeholder:j}),A]}),(0,b.jsxs)("div",{className:f.submitContainer,children:[F?(0,b.jsx)("span",{className:f.errorMessage,children:F.message?F.message:x}):null,(0,b.jsx)(c.jn,{className:f.submitButton,type:"submit",inProgress:a,disabled:g,children:(0,b.jsx)(i.sA,{id:"PaymentMethodsForm.submitPaymentInfo"})})]})]}):(0,b.jsx)("div",{className:f.missingStripeKey,children:(0,b.jsx)(i.sA,{id:"PaymentMethodsForm.missingStripeKey"})})}render(){const e=this.props,{onSubmit:t}=e,r=(0,y.A)(e,C);return(0,b.jsx)(P.lV,(0,a.A)((0,a.A)({onSubmit:this.handleSubmit},r),{},{render:this.paymentForm}))}}j.defaultProps={className:null,rootClassName:null,inProgress:!1,onSubmit:null,addPaymentMethodError:null,deletePaymentMethodError:null,createStripeCustomerError:null,handleCardSetupError:null,form:null};const v=e=>{const t=(0,_._r)(),r=(0,i.tz)();return(0,b.jsx)(j,(0,a.A)({config:t,intl:r},e))};var A=r(42299);const N={content:"PaymentMethodsPage_content__lIwwv",desktopTopbar:"PaymentMethodsPage_desktopTopbar__2uZ2q",mobileTopbar:"PaymentMethodsPage_mobileTopbar__ClPl1"},I=e=>{const[t,r]=(0,s.useState)(!1),[n,o]=(0,s.useState)(null),{currentUser:l,addPaymentMethodError:m,deletePaymentMethodError:h,createStripeCustomerError:y,handleCardSetupError:P,deletePaymentMethodInProgress:g,onCreateSetupIntent:M,onHandleCardSetup:_,onSavePaymentMethod:f,onDeletePaymentMethod:C,fetchStripeCustomer:S,scrollingDisabled:F,onManageDisableScrolling:x,intl:E,stripeCustomerFetched:j}=e,A=e=>e&&e.attributes?e.attributes.clientSecret:null,I=(e,t)=>{const{name:r,addressLine1:s,addressLine2:n,postal:o,state:i,city:l,country:m}=t,h=s&&o?{address:{city:l,country:m,line1:s,line2:n,postal_code:o,state:i}}:{};return{payment_method_data:{billing_details:(0,a.A)({name:r,email:(0,d.vs)(e).attributes.email},h)}}},w=()=>{C().then((()=>{S()}))},D=E.formatMessage({id:"PaymentMethodsPage.title"}),H=(0,d.vs)(l),V=!!H.id,L=l&&(0,d.wc)(l.stripeCustomer).attributes.stripeCustomerId&&(0,d.iO)(l.stripeCustomer.defaultPaymentMethod).id,k={name:V?"".concat(H.attributes.profile.firstName," ").concat(H.attributes.profile.lastName):null},B=L?(0,d.iO)(l.stripeCustomer.defaultPaymentMethod).attributes.card:null,O="replaceCard"===n||!L,T=!!L;return(0,b.jsx)(c.YW,{title:D,scrollingDisabled:F,children:(0,b.jsx)(c.oM,{topbar:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(u.A,{desktopClassName:N.desktopTopbar,mobileClassName:N.mobileTopbar}),(0,b.jsx)(c.pJ,{currentPage:"PaymentMethodsPage"})]}),sideNav:null,useAccountSettingsNav:!0,currentPage:"PaymentMethodsPage",footer:(0,b.jsx)(p.A,{}),children:(0,b.jsxs)("div",{className:N.content,children:[(0,b.jsx)(c.H3,{as:"h1",children:(0,b.jsx)(i.sA,{id:"PaymentMethodsPage.heading"})}),j?(0,b.jsxs)(b.Fragment,{children:[T?(0,b.jsx)(c.Ep,{card:B,onManageDisableScrolling:x,onChange:o,onDeleteCard:w,deletePaymentMethodInProgress:g}):null,O?(0,b.jsx)(v,{className:N.paymentForm,formId:"PaymentMethodsForm",initialValues:k,onSubmit:e=>{r(!0);const t=(0,d.vs)(l).stripeCustomer,{stripe:a,card:s,formValues:n}=e;M().then((e=>{const t={stripe:a,card:s,setupIntentClientSecret:A(e),paymentParam
1s:I(l,n)};return _(t)})).then((e=>{const r=e.setupIntent.payment_method;return f(t,r)})).then((()=>{S(),r(!1),o("default")})).catch((e=>{console.error(e),r(!1)}))},handleRemovePaymentMethod:w,hasDefaultPaymentMethod:L,addPaymentMethodError:m,deletePaymentMethodError:h,createStripeCustomerError:y,handleCardSetupError:P,inProgress:t}):null]}):null]})})})};I.defaultProps={currentUser:null,addPaymentMethodError:null,deletePaymentMethodError:null,createStripeCustomerError:null,handleCardSetupError:null};const w=(0,n.Zz)((0,o.Ng)((e=>{const{currentUser:t}=e.user,{deletePaymentMethodInProgress:r,addPaymentMethodError:a,deletePaymentMethodError:s,createStripeCustomerError:n}=e.paymentMethods,{stripeCustomerFetched:o}=e.PaymentMethodsPage,{handleCardSetupError:i}=e.stripe;return{currentUser:t,scrollingDisabled:(0,h.kl)(e),deletePaymentMethodInProgress:r,addPaymentMethodError:a,deletePaymentMethodError:s,createStripeCustomerError:n,handleCardSetupError:i,stripeCustomerFetched:o}}),(e=>({onManageDisableScrolling:(t,r)=>e((0,h.l)(t,r)),fetchStripeCustomer:()=>e((0,A.WM)()),onHandleCardSetup:t=>e((0,m.Ii)(t)),onCreateSetupIntent:t=>e((0,A.rk)(t)),onSavePaymentMethod:(t,r)=>e((0,l.fs)(t,r)),onDeletePaymentMethod:t=>e((0,l.PF)(t))}))),i.j4)(I)}}]); 2//# sourceMappingURL=PaymentMethodsPage.cea6a3e5.chunk.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.