web-next: rename-character/customize-character por SumUp + renombrado de rutas
- /rename-character y /customize-character: renombrar/personalizar pagados por SumUp (getRenamePrice/getCustomizePrice). SumUp ahora es service-aware: columna home_stripelog.service; createSumUpCheckout guarda service+character; fulfillSumUpCheckout despacha a la acción del servicio (.char rename/customi) o, sin service, acredita PD. [service]/checkout acepta provider:'sumup'; PaidServiceForm acepta provider+confirmText; service-success maneja el return SumUp. Se eliminan las antiguas /rename y /customize (Stripe). - /revive-character (comparte ReviveServiceContent); se elimina /revive. - Renombres de ruta + todos sus enlaces: /account -> /my-account, /recruit -> /recruit-a-friend, /unstuck -> /unstuck-character. (/select-account y /api/account/* intactos.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { setRequestLocale } from 'next-intl/server'
|
||||
import { redirect } from '@/i18n/navigation'
|
||||
import { getSession } from '@/lib/session'
|
||||
import { getGameCharacters } from '@/lib/characters'
|
||||
import { getCustomizePrice } from '@/lib/prices'
|
||||
import { PageShell } from '@/components/PageShell'
|
||||
import { ServiceBox } from '@/components/ServiceBox'
|
||||
import { PaidServiceForm } from '@/components/PaidServiceForm'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export const metadata: Metadata = { title: 'Personalizar personaje' }
|
||||
|
||||
export default async function CustomizeCharacterPage({ params }: { params: Promise<{ locale: string }> }) {
|
||||
const { locale } = await params
|
||||
setRequestLocale(locale)
|
||||
|
||||
const session = await getSession()
|
||||
if (!session.bnetId) redirect({ href: '/login', locale })
|
||||
if (!session.username) redirect({ href: '/select-account', locale })
|
||||
|
||||
const [chars, price] = await Promise.all([getGameCharacters(session.accountId!), getCustomizePrice()])
|
||||
|
||||
return (
|
||||
<PageShell title="Personalizar personaje">
|
||||
<ServiceBox>
|
||||
<br />
|
||||
<p>
|
||||
La herramienta <span>Personalizar personaje</span> te permite cambiar los siguientes aspectos un personaje:
|
||||
</p>
|
||||
<p>- Color de la piel</p>
|
||||
<p>- Rostro</p>
|
||||
<p>- Pelo</p>
|
||||
<p>- Sexo</p>
|
||||
<p>- Características correspondientes a cada raza como cuernos, pendientes, marcas, vello facial</p>
|
||||
<p>Si también deseas cambiar el nombre del personaje, debes usar la herramienta Renombrar personaje.</p>
|
||||
<br />
|
||||
<p>
|
||||
Al usar el botón PERSONALIZAR del personaje que hayas escogido, se enviará una petición de personalización de
|
||||
dicho personaje.
|
||||
</p>
|
||||
<p>Cuando ingreses a la lista de personajes de tu cuenta, verás un ícono a la izquierda de tu personaje escogido.</p>
|
||||
<p>
|
||||
Al darle click a dicho ícono ingresarás al menú de edición de personaje que te permitirá escoger diferentes
|
||||
características.
|
||||
</p>
|
||||
<br />
|
||||
<fieldset>
|
||||
<legend>NOTA</legend>
|
||||
<div className="separate2">
|
||||
<p>
|
||||
Por favor, asegúrate de haber escogido al personaje correcto ya que esta acción no es reversible una vez
|
||||
realizada.
|
||||
</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div className="centered">
|
||||
<br />
|
||||
<br />
|
||||
<p>Requiere <span>{price}</span> <span className="yellow-info">€</span> (SumUp)</p>
|
||||
</div>
|
||||
|
||||
<PaidServiceForm
|
||||
characters={chars.map((c) => ({ name: c.name, classCss: c.classCss }))}
|
||||
checkoutEndpoint="/api/character/customize/checkout"
|
||||
payLabel="PERSONALIZAR"
|
||||
buttonClass="customize-button"
|
||||
provider="sumup"
|
||||
confirmText={`¿Estás seguro de personalizar al personaje seleccionado por ${price} € (SumUp)?`}
|
||||
/>
|
||||
</ServiceBox>
|
||||
</PageShell>
|
||||
)
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { ServicePageContent } from '@/components/ServicePageContent'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export default async function Page({ params }: { params: Promise<{ locale: string }> }) {
|
||||
const { locale } = await params
|
||||
return <ServicePageContent service="customize" locale={locale} />
|
||||
}
|
||||
@@ -45,7 +45,7 @@ export default async function DPointsSuccessPage({
|
||||
<br />
|
||||
<br />
|
||||
<p>
|
||||
<Link href="/account">← Regresar a mi cuenta</Link>
|
||||
<Link href="/my-account">← Regresar a mi cuenta</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -36,7 +36,7 @@ export function LoginForm() {
|
||||
const data: { success?: boolean; needsSelection?: boolean; error?: string } = await res.json()
|
||||
if (data.success) {
|
||||
setMessage({ ok: true, text: t('success') })
|
||||
router.push(data.needsSelection ? '/select-account' : '/account')
|
||||
router.push(data.needsSelection ? '/select-account' : '/my-account')
|
||||
} else {
|
||||
const key = (ERROR_KEYS as readonly string[]).includes(data.error ?? '') ? data.error! : 'genericError'
|
||||
setMessage({ ok: false, text: t(key) })
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { setRequestLocale } from 'next-intl/server'
|
||||
import { Link } from '@/i18n/navigation'
|
||||
import { ServerClock } from '@/components/ServerClock'
|
||||
import { getNoticias, getServerStatus, type Noticia, type ServerStatus } from '@/lib/home'
|
||||
import { getRealmName } from '@/lib/realm'
|
||||
@@ -92,11 +93,11 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
|
||||
</table>
|
||||
</div>
|
||||
<div className="raf-index-responsive">
|
||||
<a href="/recruit">¡RECLUTA A UN AMIGO!</a>
|
||||
<Link href="/recruit-a-friend">¡RECLUTA A UN AMIGO!</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div className="raf-index">
|
||||
<a href="/recruit">¡RECLUTA A UN AMIGO!</a>
|
||||
<Link href="/recruit-a-friend">¡RECLUTA A UN AMIGO!</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div className="body-box-content">
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@ export default async function RecruitPage({ params }: { params: Promise<{ locale
|
||||
<div className="box-content">
|
||||
<div className="title-box-content">
|
||||
<h2>Información</h2>
|
||||
<Link className="back-to-account" href="/account">Regresar a mi cuenta</Link>
|
||||
<Link className="back-to-account-responsive" href="/account">Regresar</Link>
|
||||
<Link className="back-to-account" href="/my-account">Regresar a mi cuenta</Link>
|
||||
<Link className="back-to-account-responsive" href="/my-account">Regresar</Link>
|
||||
</div>
|
||||
<div className="body-box-content justified">
|
||||
<br />
|
||||
@@ -0,0 +1,66 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { setRequestLocale } from 'next-intl/server'
|
||||
import { redirect } from '@/i18n/navigation'
|
||||
import { getSession } from '@/lib/session'
|
||||
import { getGameCharacters } from '@/lib/characters'
|
||||
import { getRenamePrice } from '@/lib/prices'
|
||||
import { PageShell } from '@/components/PageShell'
|
||||
import { ServiceBox } from '@/components/ServiceBox'
|
||||
import { PaidServiceForm } from '@/components/PaidServiceForm'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export const metadata: Metadata = { title: 'Renombrar personaje' }
|
||||
|
||||
export default async function RenameCharacterPage({ params }: { params: Promise<{ locale: string }> }) {
|
||||
const { locale } = await params
|
||||
setRequestLocale(locale)
|
||||
|
||||
const session = await getSession()
|
||||
if (!session.bnetId) redirect({ href: '/login', locale })
|
||||
if (!session.username) redirect({ href: '/select-account', locale })
|
||||
|
||||
const [chars, price] = await Promise.all([getGameCharacters(session.accountId!), getRenamePrice()])
|
||||
|
||||
return (
|
||||
<PageShell title="Renombrar personaje">
|
||||
<ServiceBox>
|
||||
<br />
|
||||
<p>
|
||||
La herramienta <span>Renombrar personaje</span> te permite cambiar de nombre a un personaje.
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
Al usar el botón RENOMBRAR del personaje que hayas escogido, se enviará una petición de cambio de nombre de
|
||||
dicho personaje.
|
||||
</p>
|
||||
<p>Cuando intentes entrar al reino con ese personaje, te pedirá que escojas un nuevo nombre.</p>
|
||||
<br />
|
||||
<fieldset>
|
||||
<legend>NOTA</legend>
|
||||
<div className="separate2">
|
||||
<p>
|
||||
Por favor, asegúrate de haber escogido al personaje correcto ya que esta acción no es reversible una vez
|
||||
realizada.
|
||||
</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div className="centered">
|
||||
<br />
|
||||
<br />
|
||||
<p>Requiere <span>{price}</span> <span className="yellow-info">€</span> (SumUp)</p>
|
||||
</div>
|
||||
|
||||
<PaidServiceForm
|
||||
characters={chars.map((c) => ({ name: c.name, classCss: c.classCss }))}
|
||||
checkoutEndpoint="/api/character/rename/checkout"
|
||||
payLabel="RENOMBRAR"
|
||||
buttonClass="rename-button"
|
||||
provider="sumup"
|
||||
confirmText={`¿Estás seguro de renombrar al personaje seleccionado por ${price} € (SumUp)?`}
|
||||
/>
|
||||
</ServiceBox>
|
||||
</PageShell>
|
||||
)
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { ServicePageContent } from '@/components/ServicePageContent'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export default async function Page({ params }: { params: Promise<{ locale: string }> }) {
|
||||
const { locale } = await params
|
||||
return <ServicePageContent service="rename" locale={locale} />
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { ReviveServiceContent } from '@/components/ReviveServiceContent'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export default async function ReviveCharacterPage({ params }: { params: Promise<{ locale: string }> }) {
|
||||
const { locale } = await params
|
||||
return <ReviveServiceContent locale={locale} />
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { redirect } from '@/i18n/navigation'
|
||||
import { getSession } from '@/lib/session'
|
||||
import { getGameCharacters } from '@/lib/characters'
|
||||
import { PageShell } from '@/components/PageShell'
|
||||
import { ServiceBox } from '@/components/ServiceBox'
|
||||
import { CharacterActionForm } from '@/components/CharacterActionForm'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export default async function RevivePage({ params }: { params: Promise<{ locale: string }> }) {
|
||||
const { locale } = await params
|
||||
setRequestLocale(locale)
|
||||
const t = await getTranslations('Services')
|
||||
const session = await getSession()
|
||||
if (!session.bnetId) redirect({ href: '/login', locale })
|
||||
if (!session.username) redirect({ href: '/select-account', locale })
|
||||
const chars = await getGameCharacters(session.accountId!)
|
||||
|
||||
return (
|
||||
<PageShell title={t('reviveTitle')}>
|
||||
<ServiceBox>
|
||||
<CharacterActionForm
|
||||
characters={chars.map((c) => ({ name: c.name, classCss: c.classCss }))}
|
||||
endpoint="/api/character/revive"
|
||||
actionLabel={t('reviveAction')}
|
||||
processingLabel={t('reviveProcessing')}
|
||||
doneLabel={t('reviveDone')}
|
||||
promptText={t('reviveChoose')}
|
||||
buttonClass="revive-button"
|
||||
/>
|
||||
</ServiceBox>
|
||||
</PageShell>
|
||||
)
|
||||
}
|
||||
@@ -27,8 +27,8 @@ export default async function Security2faLoginPage({ params }: { params: Promise
|
||||
<div className="box-content">
|
||||
<div className="title-box-content">
|
||||
<h2>Información</h2>
|
||||
<Link className="back-to-account" href="/account">Regresar a mi cuenta</Link>
|
||||
<Link className="back-to-account-responsive" href="/account">Regresar</Link>
|
||||
<Link className="back-to-account" href="/my-account">Regresar a mi cuenta</Link>
|
||||
<Link className="back-to-account-responsive" href="/my-account">Regresar</Link>
|
||||
</div>
|
||||
<div className="body-box-content justified">
|
||||
<br />
|
||||
|
||||
@@ -27,7 +27,7 @@ export function SelectAccountForm({ accounts }: { accounts: GameAccount[] }) {
|
||||
body: JSON.stringify({ accountId: id }),
|
||||
})
|
||||
const data: { success?: boolean } = await res.json()
|
||||
if (data.success) router.push('/account')
|
||||
if (data.success) router.push('/my-account')
|
||||
else {
|
||||
setError(t('error'))
|
||||
setBusy(null)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { fulfillCheckoutSession } from '@/lib/fulfill'
|
||||
import { isSessionPaid } from '@/lib/stripe'
|
||||
import { fulfillSumUpCheckout } from '@/lib/sumup'
|
||||
import { PageShell } from '@/components/PageShell'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
@@ -10,19 +11,24 @@ export default async function ServiceSuccessPage({
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ locale: string }>
|
||||
searchParams: Promise<{ service?: string; session_id?: string }>
|
||||
searchParams: Promise<{ service?: string; session_id?: string; provider?: string; ref?: string }>
|
||||
}) {
|
||||
const { locale } = await params
|
||||
setRequestLocale(locale)
|
||||
const { service: urlService, session_id } = await searchParams
|
||||
const { service: urlService, session_id, provider, ref } = await searchParams
|
||||
const t = await getTranslations('Paid')
|
||||
|
||||
// Entrega compartida con el webhook (idempotente). Si el webhook ya entregó,
|
||||
// el reclamo atómico devuelve ok=false pero el pago sigue confirmado.
|
||||
// Entrega compartida con el webhook/reconciliación (idempotente vía reclamo atómico).
|
||||
let status: 'delivered' | 'already' | 'error' = 'error'
|
||||
let okName: string | null = null
|
||||
let service = urlService ?? null
|
||||
if (session_id) {
|
||||
if (provider === 'sumup' && ref) {
|
||||
const r = await fulfillSumUpCheckout(ref)
|
||||
service = r.service ?? urlService ?? null
|
||||
okName = r.character ?? null
|
||||
if (r.ok) status = 'delivered'
|
||||
else if (r.paid) status = 'already'
|
||||
} else if (session_id) {
|
||||
const r = await fulfillCheckoutSession(session_id, urlService)
|
||||
service = r.service ?? urlService ?? null
|
||||
if (r.ok) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { randomUUID } from 'crypto'
|
||||
import { getSession } from '@/lib/session'
|
||||
import { getGameCharacters } from '@/lib/characters'
|
||||
import { createCheckoutSession } from '@/lib/stripe'
|
||||
import { createSumUpCheckout, sumupConfigured } from '@/lib/sumup'
|
||||
import { getPaidService } from '@/lib/paid-services'
|
||||
|
||||
export async function POST(request: Request, { params }: { params: Promise<{ service: string }> }) {
|
||||
@@ -39,6 +41,29 @@ export async function POST(request: Request, { params }: { params: Promise<{ ser
|
||||
|
||||
const site = process.env.SITE_URL || ''
|
||||
const ip = (request.headers.get('x-forwarded-for') || '').split(',')[0].trim() || '0.0.0.0'
|
||||
const productName = cfg.productName(character, metadata)
|
||||
|
||||
// Pago por SumUp (euros): al pagar, la reconciliación/return ejecuta la acción
|
||||
// del servicio sobre el personaje (no acredita PD).
|
||||
if (String(body.provider) === 'sumup') {
|
||||
if (!sumupConfigured()) return Response.json({ success: false, error: 'notConfigured' })
|
||||
const reference = randomUUID()
|
||||
const r = await createSumUpCheckout({
|
||||
accountId: session.accountId,
|
||||
username: session.username || '',
|
||||
email: session.bnetEmail || '',
|
||||
acoreIp: ip,
|
||||
amount: price,
|
||||
points: 0,
|
||||
reference,
|
||||
description: productName,
|
||||
returnUrl: `${site}/service-success?service=${service}&provider=sumup&ref=${reference}`,
|
||||
service,
|
||||
characterName: character,
|
||||
})
|
||||
if (!r.success || !r.url) return Response.json({ success: false, error: r.error || 'sumupError' })
|
||||
return Response.json({ success: true, url: r.url })
|
||||
}
|
||||
|
||||
const r = await createCheckoutSession({
|
||||
accountId: session.accountId,
|
||||
@@ -47,7 +72,7 @@ export async function POST(request: Request, { params }: { params: Promise<{ ser
|
||||
acoreIp: ip,
|
||||
amount: price,
|
||||
characterName: character,
|
||||
productName: cfg.productName(character, metadata),
|
||||
productName,
|
||||
successUrl: `${site}/service-success?service=${service}`,
|
||||
cancelUrl: `${site}/${service}`,
|
||||
metadata,
|
||||
|
||||
Reference in New Issue
Block a user