import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{n as r,t as i}from"./openPay-4KSuxreV.js";var a=e(t(),1),o=n(),s=()=>{let[e,t]=(0,a.useState)({amount:1,card_number:``,card_holder_name:``,card_expiration_month:``,card_expiration_year:``,card_cvv:``,customer:{name:`JAIME QUINTANAR`,email:`jaimeagustinquintanarhelgueros@ideasysolucionestecnologicas.com`}}),n=()=>`${new Date().getTime()}-${Math.random().toString(36).substring(2,15)}`,s=e=>{let{name:n,value:r}=e.target;t(e=>({...e,[n]:r}))},c=async e=>{try{let t=await r(e);return console.log(`Tarjeta creada:`,t),t}catch(e){throw console.error(`Error al crear la tarjeta:`,e),e}};return(0,o.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();try{let t=await c({card_number:e.card_number,holder_name:e.card_holder_name,expiration_month:e.card_expiration_month,expiration_year:e.card_expiration_year,cvv2:e.card_cvv,device_session_id:`kR1MiQhz2otdIuUlQkbEyitIqVMiI16f`});if(!t||!t.id)throw Error(`No se recibió un ID de tarjeta válido.`);let r=await i({source_id:t.id,method:`card`,currency:`MXN`,description:`cargo inicial`,order_id:n(),device_session_id:`kR1MiQhz2otdIuUlQkbEyitIqVMiI16f`,amount:e.amount,customer:e.customer});console.log(`Cargo creado:`,r)}catch(e){console.error(`Error en el proceso de pago:`,e)}},children:[(0,o.jsx)(`input`,{type:`text`,name:`card_number`,placeholder:`Número de tarjeta`,value:e.card_number,onChange:s}),(0,o.jsx)(`input`,{type:`text`,name:`card_holder_name`,placeholder:`Nombre del titular`,value:e.card_holder_name,onChange:s}),(0,o.jsx)(`input`,{type:`text`,name:`card_expiration_month`,placeholder:`Mes de expiración`,value:e.card_expiration_month,onChange:s}),(0,o.jsx)(`input`,{type:`text`,name:`card_expiration_year`,placeholder:`Año de expiración`,value:e.card_expiration_year,onChange:s}),(0,o.jsx)(`input`,{type:`text`,name:`card_cvv`,placeholder:`CVV`,value:e.card_cvv,onChange:s}),(0,o.jsx)(`button`,{type:`submit`,children:`Realizar Pago`})]})};export{s as default};