(null)
async function handleSubmit(e: React.FormEvent) {
e.preventDefault()
if (busy || !character || !destination.trim() || !password || !token.trim()) return
if (!window.confirm(`¿Estás seguro de transferir el personaje "${character}" a la cuenta ${destination.trim()} por ${price} € (SumUp)?`)) return
setBusy(true)
setError(null)
try {
const res = await fetch('/api/character/transfer/checkout', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'same-origin',
body: JSON.stringify({
character,
destination_account: destination.trim(),
password,
security_token: token.trim(),
provider: 'sumup',
}),
})
const data: { success?: boolean; url?: string; message?: string } = await res.json()
if (data.success && data.url) window.location.href = data.url
else {
setError(data.message || 'No se pudo iniciar la transferencia. Inténtalo de nuevo.')
setBusy(false)
}
} catch {
setError('Algo ha salido mal. Inténtalo más tarde.')
setBusy(false)
}
}
if (characters.length === 0) return No tienes personajes disponibles.
return (
)
}