1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1685],{11685:(e,r,t)=>{t.r(r),t.d(r,{CheckoutFormStripe:()=>f});var d=t(37876),s=t(52913),i=t(14232),a=t(14169),n=t(30647),o=t(25407),l=t(85182),c=t(75132),p=t(49268),m=t(20547),h=t(3934),x=t(13283),u=t(13480),g=t(67948);function f(){let{t:e}=(0,s.A)(),r=(0,x.FU)(),{customer:t}=(0,m.cN)(),{location:f}=(0,h.zy)(),C=r.values.payment,[y,j]=(0,i.useState)([]),[S,F]=(0,i.useState)(!1),[b,E]=(0,i.useState)(null),[w,k]=(0,i.useState)(!1),v={useStoredCard:e("forms:useStoredCard"),addNewCard:e("forms:addNewCard"),standardCard:e("forms:standardCard"),loadingCards:e("forms:loadingCards"),savedCards:e("forms:savedCards")};(0,i.useEffect)(()=>{t?.custom?.fields?.stripeCustomerId&&f?.country&&z()},[t?.custom?.fields?.stripeCustomerId,f?.country]);let z=async e=>{if(t?.custom?.fields?.stripeCustomerId&&f?.country||e)try{F(!0);let r=await fetch("/api/customer/list-payment-methods",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({country:f?.country,stripeCustomerId:t?.custom?.fields?.stripeCustomerId||e})}),d=await r.json();if(d.error)throw Error(d.error.message);if(j(d?.cards||[]),d?.cards?.length>0){let e=d.cards.find(e=>e.isStandard);M(e?.id||d.cards[0].id,d.cards)}}catch(e){(0,g.Oz)({errorMessage:e instanceof Error?e.message:String(e),errorType:"api_error"})}finally{F(!1)}},M=(e,t)=>{E(e);let d=t.find(r=>r.id===e);d&&r.setFieldValue("payment.stripePaymentMethod",{id:d.id,card:{last4:d.last4,brand:d.brand}})},P=async(e,t,d)=>{await z(d),E(e),r.setFieldValue("payment.stripePaymentMethod",{id:e,card:{last4:t.card?.last4,brand:t.card?.brand}})},N=y.length>0,W=y.find(e=>e.isStandard);return C.stripePaymentMethod&&N?(0,d.jsxs)(a.s,{align:"center",gap:"lg",children:[(0,d.jsx)(u.u6m,{color:"#fa5252",size:"2em"}),(0,d.jsxs)(n.E,{children:["**** **** **** ",C.stripePaymentMethod?.card?.last4||W?.last4]}),(0,d.jsx)(o.$,{onClick:()=>{r.setFieldValue("payment.stripePaymentMethod",void 0),E(null)},children:e("cart:manageCreditCard")})]}):(0,d.jsxs)(a.s,{direction:"column",gap:"lg",w:"100%",children:[N&&(0,d.jsxs)(l.B,{spacing:"md",children:[(0,d.jsxs)(n.E,{size:"18px",fw:700,mb:"xs",style:{lineHeight:"22px",letterSpacing:"0%"},children:[v.savedCards," (",y.length,")"]}),S?(0,d.jsx)(n.E,{c:"dimmed",children:v.loadingCards}):(0,d.jsx)(l.B,{spacing:"sm",children:y.map((r,t,s)=>(0,d.jsx)(c.Z,{padding:"md",withBorder:!0,style:{cursor:"pointer",borderColor:b===r.id?"var(--mantine-color-blue-6)":"#e9ecef",borderWidth:b===r.id?"2px":"1px",backgroundColor:r.isStandard?"#E9F6EC":"#FEFEFE"},onClick:()=>M(r.id,s),children:(0,d.jsxs)(a.s,{align:"center",justify:"space-between",children:[(0,d.jsxs)(a.s,{align:"center",gap:"md",children:[(0,d.jsx)("div",{style:{backgroundColor:"#CCEFFF",padding:"4px 8px",borderRadius:"4px",fontSize:"16px",fontWeight:"700",textAlign:"center"},children:r.brand.toUpperCase()}),(0,d.jsxs)(a.s,{direction:"column",children:[(0,d.jsxs)(n.E,{fw:600,size:"22px",style:{lineHeight:"24px",letterSpacing:"0%"},children:["**** **** **** ",r.last4]}),(0,d.jsx)(n.E,{size:"18px",c:"dimmed",style:{fontWeight:400,lineHeight:"24px",letterSpacing:"0%"},children:r.name}),(0,d.jsxs)(n.E,{size:"18px",c:"dimmed",style:{fontWeight:400,lineHeight:"24px",letterSpacing:"0%"},children:[e("forms:validUntil")," ",r.expiryDate]})]})]}),(0,d.jsxs)(a.s,{direction:"row",gap:"xs",align:"flex-end",children:[r.isStandard&&(0,d.jsx)("div",{style:{backgroundColor:"#49AC33",color:"white",padding:"6px 12px",borderRadius:"27px",fontSize:"16px",fontWeight:"400"},children:e("forms:standardCard")}),(0,d.jsx)("div",{style:{backgroundColor:r.isStandard?"#FFFFFF":"#F0F0F0",padding:"6px 12px",borderRadius:"27px",fontSize:"16px",fontWeight:"400"},children:e("forms:creditCard")})]})]})},r.id))}),(0,d.jsxs)(n.E,{onClick:()=>k(!0),style:{cursor:"pointer",fontSize:"16px",color:"#495057",textDecoration:"underline"},children:["+ ",v.addNewCard]})]}),(w||!N)&&(0,d.jsx)(p.default,{setShowAddCartForm:()=>{k(!1),z()},selectNewCard:P,isFirstPaymentMethod:!N}),r.errors["payment.stripePaymentMethod"]&&(0,d.jsx)(n.E,{color:"red",children:r.errors["payment.stripePaymentMethod"]})]})}}}]);
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.