(null)
async function handleSubmit(e: React.FormEvent) {
e.preventDefault()
if (busy || !character || !destination.trim() || !password || !token.trim()) return
if (!window.confirm(t('transfer.confirm', { character, destination: destination.trim(), price }))) 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: method,
locale,
}),
})
const data: { success?: boolean; url?: string; message?: string; error?: string } = await res.json()
if (data.success && data.url) window.location.href = data.url
else {
setError(data.message || (data.error && tpay.has(`errors.${data.error}`) ? tpay(`errors.${data.error}`) : t('transfer.errorGeneric')))
setBusy(false)
}
} catch {
setError(t('transfer.errorUnexpected'))
setBusy(false)
}
}
if (characters.length === 0) return {t('transfer.noCharacters')}
return (
)
}