import { useState } from 'react' import { CreditCard, Lock } from 'lucide-react' interface MockPaymentFormProps { amount: number onSubmit: (paymentMethod: any) => Promise disabled?: boolean } export default function MockPaymentForm({ amount, onSubmit, disabled }: MockPaymentFormProps) { const [cardNumber, setCardNumber] = useState('') const [expiry, setExpiry] = useState('') const [cvc, setCvc] = useState('') const [name, setName] = useState('') const [loading, setLoading] = useState(false) const [errors, setErrors] = useState>({}) const formatCardNumber = (value: string) => { const v = value.replace(/\s+/g, '').replace(/[^0-9]/gi, '') const matches = v.match(/\d{4,16}/g) const match = (matches && matches[0]) || '' const parts = [] for (let i = 0, len = match.length; i < len; i += 4) { parts.push(match.substring(i, i + 4)) } if (parts.length) { return parts.join(' ') } else { return v } } const formatExpiry = (value: string) => { const v = value.replace(/\s+/g, '').replace(/[^0-9]/gi, '') if (v.length >= 2) { return v.substring(0, 2) + '/' + v.substring(2, 4) } return v } const validate = () => { const newErrors: Record = {} if (cardNumber.length < 19) { newErrors.cardNumber = 'Número de tarjeta inválido' } if (expiry.length < 5) { newErrors.expiry = 'Fecha de expiración inválida' } if (cvc.length < 3) { newErrors.cvc = 'CVC inválido' } if (!name.trim()) { newErrors.name = 'Nombre requerido' } setErrors(newErrors) return Object.keys(newErrors).length === 0 } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (!validate()) return setLoading(true) try { await onSubmit({ cardNumber: cardNumber.replace(/\s/g, ''), expiry, cvc, name, type: 'card' }) } finally { setLoading(false) } } const handleCardNumberChange = (e: React.ChangeEvent) => { const formatted = formatCardNumber(e.target.value) if (formatted.length <= 19) { setCardNumber(formatted) } } const handleExpiryChange = (e: React.ChangeEvent) => { const formatted = formatExpiry(e.target.value) if (formatted.length <= 5) { setExpiry(formatted) } } return (
Pago Seguro (Demo Mode)
{errors.cardNumber &&

{errors.cardNumber}

}
{errors.expiry &&

{errors.expiry}

}
setCvc(e.target.value.replace(/[^0-9]/g, ''))} placeholder="123" disabled={disabled || loading} className="w-full px-4 py-3 border rounded-lg" style={{ borderColor: errors.cvc ? '#ef4444' : 'var(--mocha-taupe)' }} /> {errors.cvc &&

{errors.cvc}

}
setName(e.target.value)} placeholder="MARÍA GARCÍA" disabled={disabled || loading} className="w-full px-4 py-3 border rounded-lg uppercase" style={{ borderColor: errors.name ? '#ef4444' : 'var(--mocha-taupe)' }} /> {errors.name &&

{errors.name}

}
Total a pagar ${amount.toFixed(2)} USD

Modo de prueba: Este es un formulario de demostración. No se procesará ningún pago real.

Consulta STRIPE_SETUP.md para activar pagos reales

) }