PageSourceSearch

https://esperanto.co/assets/CheckoutView-DOz3lYRm.js

js esperanto.co collected 2026-09-25 04:14:06 UTC 11,861 bytes, 1 lines download raw bytes

1import{d as K,b as Y,a as F,v as i,s as X,o as s,f as a,g as t,h as P,w as S,j as g,F as B,k as L,t as n,n as N,C as E,V as H,D,l as y,X as Q,p as _,y as z,_ as W}from"./index-ZjbXsIqu.js";const Z={class:"min-h-screen bg-gray-50"},ee={class:"max-w-3xl mx-auto px-4 py-10"},te={key:0,class:"bg-white rounded-xl shadow-sm p-10 text-center text-gray-400"},oe={key:1,class:"space-y-6"},se={class:"bg-white rounded-xl shadow-sm p-6"},ae=["src"],ne={key:1,class:"w-12 h-12 bg-green-50 rounded-lg flex items-center justify-center"},le={class:"flex-1 min-w-0"},re={class:"font-medium text-gray-800 text-sm truncate"},ie={class:"text-xs text-gray-400"},de={class:"font-semibold text-gray-700 text-sm"},ce={class:"bg-white rounded-xl shadow-sm p-6"},ue={class:"space-y-3"},pe=["value"],me={class:"flex-1"},ge={class:"font-medium text-gray-800 text-sm"},be={class:"text-xs text-gray-400"},ve={class:"font-semibold text-gray-700 text-sm"},xe={key:0,class:"bg-white rounded-xl shadow-sm p-6"},ye={class:"space-y-3"},_e={class:"bg-white rounded-xl shadow-sm p-6"},fe={class:"bg-white rounded-xl shadow-sm p-6"},he={class:"flex justify-between text-sm text-gray-600 mb-2"},ke={class:"flex justify-between text-sm text-gray-600 mb-2"},we={class:"flex justify-between text-sm text-gray-600 mb-2"},je={class:"flex justify-between text-lg font-bold text-gray-800 pt-3 border-t"},Ce={class:"text-green-600"},Pe={key:1,class:"bg-yellow-50 border border-yellow-200 rounded-xl p-6 text-center"},Se={class:"text-xs text-yellow-600 mt-2"},Ee={key:2},Ve=["disabled"],Ae={key:0},Me={key:1},Te={key:1,class:"bg-white rounded-xl shadow-sm p-6"},De={key:0,class:"text-center py-6"},Ie={key:1,class:"text-center py-6"},Re={key:2},Be={key:0,class:"p-4 mb-4 bg-red-50 border border-red-200 rounded-lg flex items-center gap-2"},Le={class:"text-red-700 text-sm"},Ne={key:3,class:"text-red-500 text-sm text-center"},O="danki_cart",ze=.19,$e=K({__name:"CheckoutView",setup(Oe){const U="APP_USR-d35ad4f1-135c-43fc-baee-3732f375ca40";Y();const V=F(),$=_(()=>!!V.user),f=i(JSON.parse(localStorage.getItem(O)||"[]")),d=i("pickup"),h=i(""),p=i(""),A=i(""),b=i(!1),k=i(""),v=i(""),w=i(""),m=i(""),I=[{key:"pickup",label:"Recoger en Bogotá",desc:"Coordinar punto de encuentro",cost:0},{key:"bogota",label:"Envío en Bogotá",desc:"Entrega a domicilio en Bogotá",cost:15e3},{key:"other",label:"Envío nacional",desc:"Otras ciudades de Colombia",cost:25e3}],M=_(()=>f.value.reduce((r,e)=>r+e.price*e.quantity,0)),j=_(()=>I.find(r=>r.key===d.value)?.cost??0),R=_(()=>Math.round((M.value+j.value)*ze)),C=_(()=>M.value+j.value+R.value),q={cc_rejected_bad_filled_card_number:"El número de tarjeta es incorrecto.",cc_rejected_bad_filled_date:"La fecha de vencimiento es incorrecta.",cc_rejected_bad_filled_other:"Algún dato de la tarjeta es incorrecto.",cc_rejected_bad_filled_security_code:"El código de seguridad (CVV) es incorrecto.",cc_rejected_call_for_authorize:"Debes autorizar el pago con tu banco.",cc_rejected_card_disabled:"Tu tarjeta está deshabilitada. Contacta a tu banco.",cc_rejected_high_risk:"Pago rechazado por seguridad. Usa otra tarjeta.",cc_rejected_insufficient_amount:"Tu tarjeta no tiene fondos suficientes.",cc_rejected_max_attempts:"Límite de intentos. Usa otra tarjeta.",cc_rejected_other_reason:"Tu banco rechazó el pago. Contacta a tu banco o usa otra tarjeta."};async function G(){b.value=!0,k.value="";try{const{data:r}=await z.post("/vendejo/mendoj",{items:f.value.map(e=>({productId:e.productId,quantity:e.quantity})),shippingMethod:d.value,contactPhone:h.value,shippingAddress:p.value,customerNote:A.value});v.value=r.id,localStorage.removeItem(O),await J()}catch(r){k.value=r.response?.data?.message||"Error al crear el pedido"}finally{b.value=!1}}async function J(){const{loadMercadoPago:r}=await W(async()=>{const{loadMercadoPago:l}=await import("./index-CB107Tgk.js").then(o=>o.i);return{loadMercadoPago:l}},[]);await r(),await new window.MercadoPago(U,{locale:"es-CO"}).bricks().create("payment","mp-payment-brick",{initialization:{amount:C.value,payer:{email:V.user?.email||""}},customization:{paymentMethods:{creditCard:"all",debitCard:"all",bankTransfer:"all"},visual:{style:{theme:"default"}}},callbacks:{onReady:()=>{},onError:l=>{console.error("MP Brick error:",l),m.value="Error en el formulario de pago"},onSubmit:async l=>{m.value="";const o=l.formData||l;console.log("📤 MP Brick formData:",JSON.stringify(o,null,2));try{const u=V.user,T=(u?.name||"").trim().split(" "),c={orderId:v.value,transactionAmount:C.value,paymentMethodId:o.payment_method_id,payer:{email:u?.email||o.payer?.email||"",first_name:T[0]||"",last_name:T.slice(1).join(" ")||T[0]||"",identification:o.payer?.identification||{}}};o.token&&(c.token=o.token,c.issuerId=o.issuer_id,c.installments=o.installments),o.payment_method_id==="pse"&&(c.payer.entity_type="individual",c.payer.phone={area_code:"57",number:h.value.replace(/\D/g,"").slice(-10)},c.payer.address={zip_code:"110111",street_name:p.value||"Bogotá",street_number:"1",neighborhood:"Centro",city:"Bogotá",federal_unit:"Bogotá D.C."},o.transaction_details?.financial_institution&&(c.transactionDetail
1s={financial_institution:o.transaction_details.financial_institution}));const{data:x}=await z.post("/pagoj/procesi",c);x.status==="approved"?w.value="approved":x.externalResourceUrl?window.location.href=x.externalResourceUrl:x.status==="pending"?w.value="pending":m.value=q[x.statusDetail]||"No pudimos procesar tu pago. Intenta nuevamente."}catch(u){console.error("❌ Payment error:",u.response?.data),m.value=u.response?.data?.message||"Error procesando el pago"}}}})}return(r,e)=>{const l=X("router-link");return s(),a("main",Z,[t("div",ee,[P(l,{to:"/danki",class:"text-green-600 hover:underline text-sm mb-6 inline-block"},{default:S(()=>[...e[4]||(e[4]=[g(" ← Volver a la tienda ",-1)])]),_:1}),e[28]||(e[28]=t("h1",{class:"text-2xl font-bold text-gray-800 mb-6"},"Checkout",-1)),f.value.length===0?(s(),a("div",te,[...e[5]||(e[5]=[t("i",{class:"bi bi-cart-x text-4xl block mb-2"},null,-1),t("p",null,"Tu carrito está vacío",-1)])])):(s(),a("div",oe,[t("div",se,[e[7]||(e[7]=t("h2",{class:"font-semibold text-gray-800 mb-4"},"Productos",-1)),(s(!0),a(B,null,L(f.value,o=>(s(),a("div",{key:o.productId,class:"flex items-center gap-3 py-3 border-b last:border-0"},[o.image?(s(),a("img",{key:0,src:o.image,class:"w-12 h-12 object-cover rounded-lg"},null,8,ae)):(s(),a("div",ne,[...e[6]||(e[6]=[t("i",{class:"bi bi-book text-green-400"},null,-1)])])),t("div",le,[t("p",re,n(o.name),1),t("p",ie,"x"+n(o.quantity),1)]),t("span",de," $"+n((o.price*o.quantity).toLocaleString()),1)]))),128))]),t("div",ce,[e[8]||(e[8]=t("h2",{class:"font-semibold text-gray-800 mb-4"},"Método de entrega",-1)),t("div",ue,[(s(),a(B,null,L(I,o=>t("label",{key:o.key,class:N(["flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",d.value===o.key?"border-green-500 bg-green-50":"border-gray-200 hover:border-green-300"])},[E(t("input",{type:"radio",value:o.key,"onUpdate:modelValue":e[0]||(e[0]=u=>d.value=u),class:"accent-green-600"},null,8,pe),[[H,d.value]]),t("div",me,[t("p",ge,n(o.label),1),t("p",be,n(o.desc),1)]),t("span",ve,n(o.cost===0?"Gratis":`$${o.cost.toLocaleString()}`),1)],2)),64))])]),d.value!=="pickup"?(s(),a("div",xe,[e[9]||(e[9]=t("h2",{class:"font-semibold text-gray-800 mb-4"},"Datos de envío",-1)),t("div",ye,[E(t("input",{"onUpdate:modelValue":e[1]||(e[1]=o=>h.value=o),type:"tel",placeholder:"Teléfono de contacto",class:"w-full px-4 py-2.5 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-green-500"},null,512),[[D,h.value]]),E(t("textarea",{"onUpdate:modelValue":e[2]||(e[2]=o=>p.value=o),placeholder:"Dirección completa (ciudad, barrio, dirección, indicaciones)",rows:"3",class:"w-full px-4 py-2.5 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-green-500 resize-none"},null,512),[[D,p.value]])])])):y("",!0),t("div",_e,[e[10]||(e[10]=t("h2",{class:"font-semibold text-gray-800 mb-4"},"Nota (opcional)",-1)),E(t("textarea",{"onUpdate:modelValue":e[3]||(e[3]=o=>A.value=o),placeholder:"¿Alguna indicación especial?",rows:"2",class:"w-full px-4 py-2.5 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-green-500 resize-none"},null,512),[[D,A.value]])]),t("div",fe,[t("div",he,[e[11]||(e[11]=t("span",null,"Subtotal",-1)),t("span",null,"$"+n(M.value.toLocaleString()),1)]),t("div",ke,[e[12]||(e[12]=t("span",null,"Envío",-1)),t("span",null,n(j.value===0?"Gratis":`$${j.value.toLocaleString()}`),1)]),t("div",we,[e[13]||(e[13]=t("span",null,"IVA (19%)",-1)),t("span",null,"$"+n(R.value.toLocaleString()),1)]),t("div",je,[e[14]||(e[14]=t("span",null,"Total",-1)),t("span",Ce,"$"+n(C.value.toLocaleString())+" COP",1)])]),$.value?(s(),a("div",Ee,[v.value?y("",!0):(s(),a("button",{key:0,onClick:G,disabled:b.value||d.value!=="pickup"&&!p.value,class:N(["w-full py-3 rounded-lg font-semibold transition-colors",b.value||d.value!=="pickup"&&!p.value?"bg-gray-300 text-gray-500 cursor-not-allowed":"bg-green-600 text-white hover:bg-green-700"])},[b.value?(s(),a("span",Ae,"Creando pedido...")):(s(),a("span",Me,"Continuar al pago — $"+n(C.value.toLocaleString())+" COP",1))],10,Ve)),v.value?(s(),a("div",Te,[e[26]||(e[26]=t("h2",{class:"font-semibold text-gray-800 mb
1-4 flex items-center gap-2"},[t("i",{class:"bi bi-credit-card"}),g(" Datos de pago ")],-1)),w.value==="approved"?(s(),a("div",De,[e[20]||(e[20]=t("div",{class:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4"},[t("i",{class:"bi bi-check-lg text-green-600 text-3xl"})],-1)),e[21]||(e[21]=t("h3",{class:"text-xl font-bold text-green-800 mb-2"},"¡Pago exitoso!",-1)),e[22]||(e[22]=t("p",{class:"text-gray-600 mb-4"},"Tu pedido ha sido confirmado",-1)),P(l,{to:`/danki/mendo/${v.value}`,class:"inline-block px-6 py-2.5 rounded-lg bg-green-600 text-white font-semibold hover:bg-green-700"},{default:S(()=>[...e[19]||(e[19]=[g(" Ver mi pedido ",-1)])]),_:1},8,["to"])])):w.value==="pending"?(s(),a("div",Ie,[...e[23]||(e[23]=[t("div",{class:"w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mx-auto mb-4"},[t("i",{class:"bi bi-hourglass-split text-yellow-600 text-3xl"})],-1),t("h3",{class:"text-xl font-bold text-yellow-800 mb-2"},"Pago pendiente",-1),t("p",{class:"text-gray-600"},"Tu pago está siendo procesado. Te notificaremos cuando se confirme.",-1)])])):(s(),a("div",Re,[m.value?(s(),a("div",Be,[e[24]||(e[24]=t("i",{class:"bi bi-exclamation-circle text-red-600"},null,-1)),t("span",Le,n(m.value),1)])):y("",!0),e[25]||(e[25]=t("div",{id:"mp-payment-brick",class:"min-h-[300px]"},null,-1))])),e[27]||(e[27]=Q('<div class="mt-4 p-4 bg-blue-50 border border-blue-200 rounded-lg"><div class="flex items-center gap-2"><i class="bi bi-shield-check text-blue-600"></i><span class="text-sm font-medium text-blue-800">Pago 100% seguro con</span><img src="https://kelstorageco.blob.core.windows.net/blog/danki/mercadopago-logo.svg" alt="Mercado Pago" class="h-5"></div><p class="text-xs text-blue-600 mt-1"> Tus datos están protegidos y encriptados. Aceptamos tarjetas de crédito, débito y PSE. </p></div>',1))])):y("",!0)])):(s(),a("div",Pe,[e[18]||(e[18]=t("p",{class:"text-yellow-800 mb-3"},"Debes iniciar sesión para completar tu pedido",-1)),P(l,{to:{name:"login",query:{redirect:"/danki/checkout"}},class:"inline-block px-6 py-2.5 rounded-lg bg-green-600 text-white font-semibold hover:bg-green-700 transition-colors"},{default:S(()=>[...e[15]||(e[15]=[g(" Iniciar sesión ",-1)])]),_:1}),t("p",Se,[e[17]||(e[17]=g(" ¿No tienes cuenta? ",-1)),P(l,{to:{name:"register",query:{redirect:"/danki/checkout"}},class:"underline"},{default:S(()=>[...e[16]||(e[16]=[g("Regístrate aquí",-1)])]),_:1})])])),k.value?(s(),a("p",Ne,n(k.value),1)):y("",!0)]))])])}}});export{$e 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.