PageSourceSearch

https://tije.com/assets/CreditCardDLocalGO-CZ4SaFBN.js

js tije.com collected 2026-10-08 11:27:55 UTC 16,122 bytes, 1 lines download raw bytes

1import{r as u,j as t,R as Le}from"./vendor-react-BzVUCHPd.js";import{s as ye,E as ge}from"./vendor-react-widgets-DfjT2elj.js";import{az as Ge,ab as $e}from"./vendor-mui-icons-m8JTgmi9.js";import{I as K}from"./InputWrapper-BNKZCSez.js";import{I as Pe}from"./Image-DY5CGUYp.js";import{u as Oe,j as ke,i as Ne,h as ze,f as Ue}from"./index-C7ecK4AL.js";import{y as De}from"./IconCustom-DFthY3H8.js";import{u as Be,f as He}from"./vendor-state-Dd9Nlpa9.js";import{u as je}from"./vendor-i18n-date-CyXHEs_w.js";import{$ as j,T as W,af as se,t as be,aA as Ke,a5 as We,P as le,I as Qe,L as Ye,aN as Ve,a3 as te,aM as Je,ad as Xe,ae as Ze}from"./vendor-mui-core-DFPudBFn.js";import{B as Me}from"./BillingForm-DP4AqlbE.js";import{F as qe,a as et}from"./vendor-fontawesome-BIoGpyii.js";import"./vendor-misc-CSJ5cNIV.js";import"./vendor-utils-CrV680bq.js";import"./vendor-router-D8xe-poW.js";import"./vendor-mui-pickers-DLvaRoLQ.js";import"./vendor-icons-DBQaFWLf.js";import"./InfoFormServices-DBRykhXJ.js";import"./vendor-location-forms-XJ_JBO0o.js";const tt=[{value:"DNI",label:"dni"},{value:"PP",label:"passport"}],rt=p=>{var fe;const{paymentMethod:n,installment:v,previewsStepsData:F,currencyCode:L,totalAmount:A,externalId:i,restartPayment:G,ref:Q}=p,{currentProduct:_}=Oe(),{dlocalInitCache:b,setDlocalInitCache:z,paymentError:k}=ke(),{setInterest:w,refreshTotalAmount:g}=Ne(),$=Be(),h=He(e=>e.checkoutReducer.responseDlocal),{t:f}=je(),P=u.useRef(null),U=u.useRef(null),E=u.useRef(null),I=u.useRef(null),[c,ie]=u.useState({docType:"DNI"}),[me,ve]=u.useState([]),[re,oe]=u.useState({}),[ne,ae]=u.useState({}),[m,D]=u.useState({}),[B,Y]=u.useState({}),[de,C]=u.useState(),[_e,V]=u.useState(!1);u.useImperativeHandle(Q,()=>({handleSubmit:Re}));const J=({target:e})=>{const{name:o,value:a}=e;ie(r=>({...r,[o]:a})),D(r=>({...r,[o]:!1})),Y(r=>({...r,[o]:""}))},Te=e=>{w(e&&(e==null?void 0:e.coef)>1?{interestAmount:Number((e==null?void 0:e.interest_amount)||"0"),chargeAmount:Number((e==null?void 0:e.charge_amount)||"0")-Number((e==null?void 0:e.charge_amount_initial)||"0"),interestDisplay:e==null?void 0:e.interest_display,quota:e==null?void 0:e.quota,amountPerQuota:e==null?void 0:e.installment_quota_initial_value}:null),g(e==null?void 0:e.total_amount)};u.useEffect(()=>{we().then(()=>Ae())},[A]),u.useEffect(()=>{const e=ot(v);ve(e),ie(o=>{const r=e.find(d=>d===o.installment)||e[0]||null;return r===o.installment?o:{...o,installment:r}})},[v]),u.useEffect(()=>{typeof c.installment>"u"||Te(c.installment)},[c.installment]),u.useEffect(()=>{var e;if(_e){if(h!=null&&h.merchant_checkout_token){const o=typeof L=="string"?L.toUpperCase():"",a=(((e=_==null?void 0:_.parameters)==null?void 0:e.COUNTRY)||"AR").toUpperCase();if(!o){V(!1),C("No se pudo obtener la moneda del checkout para inicializar DLocalGo.");return}const r={...h,amount:Number(A||0),currency:o,country:a};z(r),V(!1),pe(r==null?void 0:r.merchant_checkout_token);return}h&&Object.keys(h).length===0&&(V(!1),z(null),C(f("checkout.common.createDlocalPaymentError")||"Ha habido un error al iniciar el pago."),G&&G())}},[h]);const we=()=>new Promise((e,o)=>{if(window.dlocalGo){e();return}const r=(ze()||{}).dlocalGoSdkUrl,d=new Set(Array.from(document.querySelectorAll('style, link[rel="stylesheet"]'))),x=document.getElementById("dlocalgo-sdk");if(x){x.addEventListener("load",e);return}const y=document.createElement("script");y.id="dlocalgo-sdk",y.src=r,y.async=!0,y.onload=()=>{document.querySelectorAll('style, link[rel="stylesheet"]').forEach(N=>{d.has(N)||N.remove()}),e()},y.onerror=()=>o(new Error("Error al cargar SDK de DLocalGo")),document.head.appendChild(y)}),Ce=()=>{var e,o,a;return((e=_==null?void 0:_.parameters)==null?void 0:e.API_DLOCALGO_SMARTFIELD_KEY)||((o=n==null?void 0:n.configScript)==null?void 0:o.smartFields_api_key)||((a=n==null?void 0:n.additional_info)==null?void 0:a.smartFields_api_key)||null},X=(e=null)=>{var o,a;return(e==null?void 0:e.merchant_checkout_token)||(b==null?void 0:b.merchant_checkout_token)||(h==null?void 0:h.merchant_checkout_token)||((o=n==null?void 0:n.configScript)==null?void 0:o.merchant_checkout_token)||((a=n==null?void 0:n.additional_info)==null?void 0:a.merchant_checkout_token)||(n==null?void 0:n.merchant_checkout_token)||null},ue=(e="")=>typeof e!="string"?"":e.trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"").replace(/:\d+$/,"").replace(/^www\./i,"").replace(/\./g,"").toLowerCase(),Se=()=>{var r,d;const e=typeof i=="string"?i.trim():"",o=(r=JSON.parse(localStorage.getItem("workUnit")||"{}"))==null?void 0:r.url,a=ue(o)||ue((d=window.location)==null?void 0:d.hostname);return!e||!a?null:`${a}-${e}`},Ae=()=>{var l;const e=typeof L=="string"?L.toUpperCase():"",o=(((l=_==null?void 0:_.parameters)==null?void 0:l.COUNTRY)||"AR").toUpperCase();if(!e){C("No se pudo obtener la moneda del checkout para inicializar DLocalGo.");return}const a=X(b),r=Number((b==null?void 0:b.amount)||0)===Number(A||0),d=((b==null?void 0:b.currency)||"").toUpperCase()===e,x=((b==null?void 0:b.country)||"").toUpperCase()===o;if(a&&r&&d&&x){pe(a);return}const y=localStorage.getItem("jwt"),N={currency:e,amount:Number(A||0),country:o,allow_transparent:!0,order_id:Se()};$(De(y,N)),V(!0)},pe=async(e=null)=>{if(!window.dlocalGo){C("DLocalGo SDK no cargado. Recargue la página.");return}const o=Ce(),a=X({merchant_checkout_token:e});if(!o||!a){C("Faltan credenciales de DLocalGo (apiKey o checkoutToken).");return}try{await window.dlocalGo.initialize(o,a);const r={base:{fontSize:"16px",lineHeight:"20px",color:"#606060","::placeholder":{color:"#606060",opacity:.42},iconColor:"#adbfd3"}},d=window.dlocalGo.fields(),x=d.create("pan",{style:r,placeholder:"xxxx xxxx xxxx xxxx"}),y=d.create("expiration",{style:r}),N=d.create("cvv",{style:r,placeholder:"****"});U.current=x,P.current&&x.mount(P.current),E.current&&y.mount(E.current),I.current&&N.mou
1nt(I.current),x.on("ready",()=>{oe(l=>({...l,number:!0}))}),y.on("ready",()=>{oe(l=>({...l,expiry:!0}))}),N.on("ready",()=>{oe(l=>({...l,cvc:!0}))}),x.on("change",l=>{ae(s=>({...s,number:l.complete})),D(s=>({...s,number:!1})),Y(s=>({...s,number:""}))}),y.on("change",l=>{ae(s=>({...s,expiry:l.complete})),D(s=>({...s,expiry:!1})),Y(s=>({...s,expiry:""}))}),N.on("change",l=>{ae(s=>({...s,cvc:l.complete})),D(s=>({...s,cvc:!1})),Y(s=>({...s,cvc:""}))})}catch{C("Error al inicializar DLocalGo SDK.")}},Re=async(e={})=>{var d,x,y,N,l,s,S,Z,M;const{validateOnly:o=!1}=e,a=U.current;if(!window.dlocalGo||!a)return C("SDK no inicializado."),{status:!1,data:null};const r={};if(ne.number||(r.number=!0),ne.expiry||(r.expiry=!0),ne.cvc||(r.cvc=!0),(d=c.holderName)!=null&&d.trim()||(r.holderName=!0),c.docType||(r.docType=!0),(x=c.docNumber)!=null&&x.trim()||(r.docNumber=!0),c.installment||(r.installment=!0),D(r),Object.keys(r).length>0)return{status:!1,data:null};if(o)return{status:!0,data:{payment:{checkoutToken:X(),amount:A,holderName:(y=c.holderName)==null?void 0:y.trim(),docType:c.docType,docNumber:(N=c.docNumber)==null?void 0:N.trim()},paymentMethod:{name:((l=c.installment)==null?void 0:l.gateway_code)||(n==null?void 0:n.code)||"dlocalgo",installment:c.installment},gateway:"dlocalgo"}};try{return{status:!0,data:{payment:{cardToken:(await window.dlocalGo.createCardToken(a,{name:(s=c.holderName)==null?void 0:s.trim()})).token,checkoutToken:X(),amount:A,holderName:(S=c.holderName)==null?void 0:S.trim(),docType:c.docType,docNumber:(Z=c.docNumber)==null?void 0:Z.trim()},paymentMethod:{name:((M=c.installment)==null?void 0:M.gateway_code)||(n==null?void 0:n.code)||"dlocalgo",installment:c.installment},gateway:"dlocalgo"}}}catch{return C(f("checkout.common.confirmDlocalPaymentError")||"Error al tokenizar la tarjeta."),{status:!1,data:null}}},O=re.number&&re.expiry&&re.cvc,Ee=e=>{var x,y,N;const o=(e==null?void 0:e.installment_amount)||"",r=(l=>{const s=[];let S=0;const Z=/(\d+)\s+(pago(?:s)?|cuota(?:s)?)/ig,M=/(sin\s+inter[eé]s)/ig,q=(ee,ce,H)=>{const T=new RegExp(ee.source,ee.flags);T.lastIndex=H;const R=T.exec(ce);return R?{match:R,index:R.index}:null};for(;S<l.length;){const ee=q(Z,l,S),ce=q(M,l,S),H=[ee,ce].filter(Boolean);if(H.length===0){s.push(l.slice(S));break}let T=H[0];for(const xe of H)xe.index<T.index&&(T=xe);T.index>S&&s.push(l.slice(S,T.index));const{match:R}=T,he=R[0];R.length>=3&&/^(pago|pagos|cuota|cuotas)$/i.test(R[2])?s.push(t.jsxs(Le.Fragment,{children:[t.jsx(te,{component:"span",sx:{fontWeight:700,color:"primary.main",fontSize:"1.7em"},children:R[1]}),t.jsx(te,{component:"span",sx:{fontWeight:700,color:"primary.main"},children:` ${R[2]}`})]},`count-${T.index}`)):s.push(t.jsx(te,{component:"span",sx:{fontWeight:700,color:"primary.main"},children:he},`text-${T.index}`)),S=T.index+he.length}return s})(o),d=[];if(((x=e==null?void 0:e.cft)==null?void 0:x.toLowerCase())!=="consultar"&&!isNaN((y=e==null?void 0:e.cft)==null?void 0:y.replace(",","."))){const l=Ue((N=e.cft)==null?void 0:N.replace(",","."),2);d.push(` - ${f("checkout.common.cft")} ${l}%`)}return t.jsxs("span",{children:[r,d]})},Ie=()=>{var o,a;const e=(a=(o=F==null?void 0:F.FORM_PAYMENT)==null?void 0:o.find(r=>r.event_name==="form_payment"))==null?void 0:a.event_data;return Array.isArray(e)?e[0]||{}:e||{}},Fe=()=>{var o,a,r,d,x;const e=Ie();return((a=(o=e==null?void 0:e.paymentMethod)==null?void 0:o.installment)==null?void 0:a.credit_card_name)||((d=(r=e==null?void 0:e.paymentMethod)==null?void 0:r.installment)==null?void 0:d.bank_name)||((x=e==null?void 0:e.paymentMethod)==null?void 0:x.name)||(n==null?void 0:n.name)||(n==null?void 0:n.code)||""};return t.jsxs(j,{container:!0,spacing:2,className:"credit-card-form",children:[k&&t.jsxs(j,{item:!0,xs:12,className:"row error-payment-container",children:[t.jsx(Ge,{fontSize:"large"}),t.jsx(Pe,{img:`cards/${(fe=Fe())==null?void 0:fe.replaceAll(" ","_")}.png`,alt:"card-logo",className:"card-logo",hideBrokenImage:!0}),t.jsxs("div",{children:[t.jsx(W,{className:"title",children:f("checkout.common.errorPaymentCardGeneric")}),t.jsx(W,{className:"subtitle",children:f("checkout.common.errorPaymentCardMessage")})]})]}),t.jsx(j,{item:!0,xs:12,children:t.jsx(W,{className:"title-section",children:f("checkout.common.enterCardData",{number:""})})}),t.jsx(j,{item:!0,xs:12,children:t.jsxs(K,{label:f("checkout.common.cardNumber"),error:m.number||!1,helperText:B.number||"",children:[!O&&t.jsx(se,{variant:"rounded",height:48,width:"100%"}),t.jsx("div",{ref:P,style:{display:O?"block":"none",border:`1px solid ${m.number?"#d32f2f":"#c4c4c4"}`,borderRadius:"4px",padding:"12px",minHeight:"48px"}})]})}),t.jsx(j,{item:!0,xs:6,children:t.jsxs(K,{label:f("checkout.common.expiry"),error:m.expiry||!1,helperText:B.expiry||"",children:[!O&&t.jsx(se,{variant:"rounded",height:48,width:"100%"}),t.jsx("div",{ref:E,style:{display:O?"block":"none",border:`1px solid ${m.expiry?"#d32f2f":"#c4c4c4"}`,borderRadius:"4px",padding:"12px",minHeight:"48px"}})]})}),t.jsx(j,{item:!0,xs:6,children:t.jsxs(K,{label:f("checkout.common.cvc"),error:m.cvc||!1,helperText:B.cvc||"",children:[!O&&t.jsx(se,{variant:"rounded",height:48,width:"100%"}),t.jsx("div",{ref:I,style:{display:O?"block":"none",border:`1px solid ${m.cvc?"#d32f2f":"#c4c4c4"}`,borderRadius:"4px",padding:"12px",minHeight:"48px"}})]})}),t.jsx(j,{item:!0,xs:12,sm:6,md:6,className:"field-container",children:t.jsx(K,{label:f("checkout.common.holderName"),error:m.holderName||!1,helperText:B.holder
1Name||"",children:t.jsx(be,{fullWidth:!0,name:"holderName",placeholder:f("checkout.common.enterHolderName"),value:c.holderName||"",error:m.holderName||!1,onChange:J})})}),t.jsx(j,{item:!0,xs:12,sm:6,md:6,className:"field-container",children:t.jsx(K,{label:f("checkout.common.documentTypeAndNumber")||"Tipo y número de documento",error:(m==null?void 0:m.docType)||(m==null?void 0:m.docNumber)||!1,helperText:"",children:t.jsxs(j,{container:!0,spacing:2,alignItems:"center",children:[t.jsx(j,{item:!0,xs:5,sm:4,md:4,children:t.jsx(Ke,{fullWidth:!0,size:"small",name:"docType",value:(c==null?void 0:c.docType)||"",error:(m==null?void 0:m.docType)||!1,onChange:J,children:tt.map((e,o)=>t.jsx(We,{value:e.value,children:f(`checkout.common.${e.label}`).toUpperCase()},o))})}),t.jsx(j,{item:!0,xs:7,sm:8,md:8,children:t.jsx(be,{fullWidth:!0,size:"small",name:"docNumber",placeholder:f("checkout.common.documentNumber"),value:(c==null?void 0:c.docNumber)||"",error:(m==null?void 0:m.docNumber)||!1,onChange:J,inputProps:{maxLength:15}})})]})})}),t.jsx(j,{item:!0,xs:12,className:"field-container cuotas-section",children:t.jsxs(le,{variant:"outlined",sx:{width:"100%",boxShadow:"none",p:0},children:[t.jsxs("div",{className:"cuotas-header",style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid #cfcfcf",fontWeight:500,fontSize:"0.9rem"},children:[t.jsx("span",{children:f("checkout.common.quotesCount")||f("checkout.common.quotesCount")}),t.jsx(Qe,{size:"small",disabled:!0,sx:{transform:"rotate(0deg)"},children:t.jsx($e,{fontSize:"small"})})]}),m.installment&&t.jsx(W,{variant:"caption",color:"error",sx:{px:2,pt:1,display:"block"},children:B.installment}),me.length>0&&t.jsx(Ye,{disablePadding:!0,children:me.map((e,o)=>t.jsxs(Ve,{className:`quota-item ${c.installment===e?"selected":""}`,selected:c.installment===e,disableRipple:!0,disableTouchRipple:!0,onClick:()=>J({target:{name:"installment",value:e}}),children:[t.jsx(te,{component:"span",className:"quota-indicator"}),t.jsx(Je,{className:"quota-text",primary:Ee(e)})]},`${(e==null?void 0:e.gateway_code)||"quote"}-${(e==null?void 0:e.quota)||o}-${(e==null?void 0:e.total_amount)||(e==null?void 0:e.installment_amount)||"na"}`))})]})}),t.jsx(Xe,{open:!!de,autoHideDuration:6e3,onClose:()=>C(null),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:t.jsx(Ze,{onClose:()=>C(null),severity:"error",sx:{width:"100%"},children:de})})]})},ot=p=>{if(!p)return[];if(Array.isArray(p==null?void 0:p.bank)){for(const n of p.bank)if(Array.isArray(n==null?void 0:n.credit_cards)){for(const v of n.credit_cards)if(Array.isArray(v==null?void 0:v.quotes)&&v.quotes.length>0)return v.quotes}}return Array.isArray(p==null?void 0:p.quotes)?p.quotes:[]},vt=p=>{var z;const n=p.ref,v=u.useRef(),F=u.useRef(),{t:L}=je(),{paymentError:A}=ke(),{purchaseDetail:i}=Ne();u.useImperativeHandle(n,()=>({handleSubmit:_}));const G=k=>Array.isArray(k)?k.every(Boolean):!!k,Q=async(k,w={})=>{const g=k==null?void 0:k.current,$=(g==null?void 0:g.handleSubmit)||(g==null?void 0:g.inputValidate);if(typeof $!="function")return{status:!1,data:null};const h=await $(w);return{...h||{},status:G(h==null?void 0:h.status)}},_=async(k={})=>{const w=await Q(v,k),g=await Q(F,k);return G(w==null?void 0:w.status)?G(g==null?void 0:g.status)?{status:!0,data:{billing:g.data,payments:[w.data]}}:(ye.scrollTo("billingDLocalGOTo",{smooth:"easeOutQuad"}),{status:!1,data:null}):(ye.scrollTo("creditCardDLocalGOTo",{smooth:"easeOutQuad"}),{status:!1,data:null})},b=()=>{var h,f,P,U;const k=(i==null?void 0:i.totalAmountRealFinal)??(i==null?void 0:i.totalAmountReal)??0,w=((f=(h=i==null?void 0:i.priceDetail)==null?void 0:h.filter(E=>{var I;return((I=E.module)==null?void 0:I.startsWith("ancillary-"))&&E.addToCart}))==null?void 0:f.reduce((E,I)=>E+(I.amountReal||0),0))||0,g=(P=i==null?void 0:i.coupon)!=null&&P.applied?Number(((U=i==null?void 0:i.coupon)==null?void 0:U.total_amount)||0):0,$=g>0?g:k+w;return Number($.toFixed(2))};return t.jsxs(j,{className:"credit-card-container",children:[t.jsx(ge,{name:"creditCardDLocalGOTo",children:t.jsx(le,{className:`paper-form ${A?"error":""}`,children:t.jsx(rt,{ref:v,paymentMethod:p.data,installment:(z=p.data)==null?void 0:z.installment,currencyCode:i==null?void 0:i.currency,totalAmount:b(),previewsStepsData:p.previewsStepsData,externalId:p.externalId,restartPayment:p.restartPayment})})}),t.jsxs(W,{component:"h2",className:"paper-title row mt-1",children:[t.jsx(qe,{icon:et}),L("checkout.common.billingData")]}),t.jsx(ge,{name:"billingDLocalGOTo",className:"billing-container",children:t.jsx(le,{className:"paper-form",children:t.jsx(Me,{ref:F,previewsStepsData:p.previewsStepsData||{},paymentError:A})})})]})};export{vt as default};

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.