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} />
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -19,7 +19,7 @@ export function AccountTools({ isAdmin }: { isAdmin: boolean }) {
|
||||
{ href: '/trade-points', icon: 'trade-pd-icon', label: t('svcTradePD'), desc: t('svcTradePDDesc') },
|
||||
{ href: '/promo-code', icon: 'promo-icon', label: t('svcPromo'), desc: t('svcPromoDesc') },
|
||||
{ href: '/security-token', icon: 'token-icon', label: t('svcToken'), desc: t('svcTokenDesc') },
|
||||
{ href: '/recruit', icon: 'recruit-a-friend-icon', label: t('svcRecruit'), desc: t('svcRecruitDesc') },
|
||||
{ href: '/recruit-a-friend', icon: 'recruit-a-friend-icon', label: t('svcRecruit'), desc: t('svcRecruitDesc') },
|
||||
{ href: '/rename-guild', icon: 'rename-guild-icon', label: t('svcRenameGuild'), desc: t('svcRenameGuildDesc') },
|
||||
{ href: '/vote-points', icon: 'vote-icon', label: t('svcVote'), desc: t('svcVoteDesc') },
|
||||
{ href: '/d-points', icon: 'dnt-icon', label: t('svcDPoints'), desc: t('svcDPointsDesc') },
|
||||
@@ -29,10 +29,10 @@ export function AccountTools({ isAdmin }: { isAdmin: boolean }) {
|
||||
...(isAdmin ? [{ href: '/admin', icon: 'store-icon', label: `🛡️ ${t('adminPanel')}`, desc: t('adminPanelDesc') }] : []),
|
||||
]
|
||||
const characterTools: Tool[] = [
|
||||
{ href: '/unstuck', icon: 'unstuck-icon', label: t('svcUnstuck'), desc: t('svcUnstuckDesc') },
|
||||
{ href: '/revive', icon: 'revive-icon', label: t('svcRevive'), desc: t('svcReviveDesc') },
|
||||
{ href: '/rename', icon: 'rename-icon', label: t('svcRename'), desc: t('svcRenameDesc') },
|
||||
{ href: '/customize', icon: 'customize-icon', label: t('svcCustomize'), desc: t('svcCustomizeDesc') },
|
||||
{ href: '/unstuck-character', icon: 'unstuck-icon', label: t('svcUnstuck'), desc: t('svcUnstuckDesc') },
|
||||
{ href: '/revive-character', icon: 'revive-icon', label: t('svcRevive'), desc: t('svcReviveDesc') },
|
||||
{ href: '/rename-character', icon: 'rename-icon', label: t('svcRename'), desc: t('svcRenameDesc') },
|
||||
{ href: '/customize-character', icon: 'customize-icon', label: t('svcCustomize'), desc: t('svcCustomizeDesc') },
|
||||
{ href: '/change-race', icon: 'change-race-icon', label: t('svcChangeRace'), desc: t('svcChangeRaceDesc') },
|
||||
{ href: '/change-faction', icon: 'change-faction-icon', label: t('svcChangeFaction'), desc: t('svcChangeFactionDesc') },
|
||||
{ href: '/level-up', icon: 'level-up-icon', label: t('svcLevelUp'), desc: t('svcLevelUpDesc') },
|
||||
|
||||
@@ -40,8 +40,8 @@ export function DPointsTabs({ realm, currency }: { realm: string; currency: stri
|
||||
>
|
||||
Información
|
||||
</button>
|
||||
<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="dnt-sidebar dnt-methods">
|
||||
<button className={`dnt-button-2 tablink${active === 'Stripe' ? ' dnt-selected' : ''}`} onClick={() => setActive('Stripe')}>
|
||||
|
||||
@@ -9,10 +9,12 @@ interface Props {
|
||||
checkoutEndpoint: string
|
||||
payLabel: string // ya formateado con el precio
|
||||
buttonClass?: string
|
||||
provider?: 'stripe' | 'sumup' // pasarela; por defecto Stripe
|
||||
confirmText?: string // si se pasa, pide confirmación antes de redirigir al pago
|
||||
}
|
||||
|
||||
/** Selector de personaje + botón de pago. Redirige al Checkout de Stripe. */
|
||||
export function PaidServiceForm({ characters, checkoutEndpoint, payLabel, buttonClass = '' }: Props) {
|
||||
/** Selector de personaje + botón de pago. Redirige al Checkout (Stripe o SumUp). */
|
||||
export function PaidServiceForm({ characters, checkoutEndpoint, payLabel, buttonClass = '', provider, confirmText }: Props) {
|
||||
const t = useTranslations('Services')
|
||||
const [character, setCharacter] = useState('')
|
||||
const [busy, setBusy] = useState(false)
|
||||
@@ -21,6 +23,7 @@ export function PaidServiceForm({ characters, checkoutEndpoint, payLabel, button
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault()
|
||||
if (busy || !character) return
|
||||
if (confirmText && !window.confirm(confirmText)) return
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
try {
|
||||
@@ -28,7 +31,7 @@ export function PaidServiceForm({ characters, checkoutEndpoint, payLabel, button
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({ character }),
|
||||
body: JSON.stringify({ character, ...(provider ? { provider } : {}) }),
|
||||
})
|
||||
const data: { success?: boolean; url?: string } = await res.json()
|
||||
if (data.success && data.url) {
|
||||
|
||||
+14
-4
@@ -6,10 +6,8 @@ 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
|
||||
/** Contenido de "Revivir personaje" (compartido por /revive y /revive-character). */
|
||||
export async function ReviveServiceContent({ locale }: { locale: string }) {
|
||||
setRequestLocale(locale)
|
||||
const t = await getTranslations('Services')
|
||||
const session = await getSession()
|
||||
@@ -20,6 +18,18 @@ export default async function RevivePage({ params }: { params: Promise<{ locale:
|
||||
return (
|
||||
<PageShell title={t('reviveTitle')}>
|
||||
<ServiceBox>
|
||||
<br />
|
||||
<p>{t.rich('reviveInfo1', { b: (c) => <span>{c}</span> })}</p>
|
||||
<p>{t('reviveInfo2')}</p>
|
||||
<br />
|
||||
<fieldset>
|
||||
<legend>NOTA</legend>
|
||||
<div className="separate2">
|
||||
<p>{t('reviveNote1')}</p>
|
||||
<p>{t('reviveNote2')}</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<CharacterActionForm
|
||||
characters={chars.map((c) => ({ name: c.name, classCss: c.classCss }))}
|
||||
endpoint="/api/character/revive"
|
||||
@@ -18,10 +18,10 @@ export async function ServiceBox({
|
||||
<div className="box-content">
|
||||
<div className="title-box-content">
|
||||
<h2>{heading ?? t('info')}</h2>
|
||||
<Link className="back-to-account" href="/account">
|
||||
<Link className="back-to-account" href="/my-account">
|
||||
{t('back')}
|
||||
</Link>
|
||||
<Link className="back-to-account-responsive" href="/account">
|
||||
<Link className="back-to-account-responsive" href="/my-account">
|
||||
{t('backShort')}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -126,7 +126,7 @@ export function SiteHeader({
|
||||
</div>
|
||||
<div className="nav-dropdown-content">
|
||||
<p>
|
||||
<Link href="/account">MI CUENTA</Link>
|
||||
<Link href="/my-account">MI CUENTA</Link>
|
||||
</p>
|
||||
<p>
|
||||
<a href="javascript:void(0);" onClick={logout}>
|
||||
|
||||
+21
-5
@@ -1,6 +1,7 @@
|
||||
import type { RowDataPacket, ResultSetHeader } from 'mysql2'
|
||||
import { db, DB } from './db'
|
||||
import { creditDPoints, PD_PER_UNIT } from './dpoints'
|
||||
import { getPaidService } from './paid-services'
|
||||
|
||||
const API = 'https://api.sumup.com/v0.1'
|
||||
|
||||
@@ -26,6 +27,10 @@ interface CreateParams {
|
||||
reference: string
|
||||
description: string
|
||||
returnUrl: string
|
||||
// Para pagos de servicio (renombrar, etc.): al pagar se ejecuta la acción del
|
||||
// servicio sobre `characterName` en vez de acreditar PD. Sin `service` = compra de PD.
|
||||
service?: string
|
||||
characterName?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,9 +60,9 @@ export async function createSumUpCheckout(p: CreateParams): Promise<{ success: b
|
||||
if (!url) return { success: false, error: 'noHostedUrl' }
|
||||
|
||||
await db(DB.default).query(
|
||||
'INSERT INTO home_stripelog (account_id, username, email, acore_ip, stripe_ip, product_name, amount, session_id, mode, character_name, timestamp, fulfilled) ' +
|
||||
'VALUES (?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, NOW(), 0)',
|
||||
[p.accountId, p.username, p.email, p.acoreIp, p.description, p.amount, p.reference, 'sumup', p.username],
|
||||
'INSERT INTO home_stripelog (account_id, username, email, acore_ip, stripe_ip, product_name, amount, session_id, mode, character_name, service, timestamp, fulfilled) ' +
|
||||
'VALUES (?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, NOW(), 0)',
|
||||
[p.accountId, p.username, p.email, p.acoreIp, p.description, p.amount, p.reference, 'sumup', p.characterName ?? p.username, p.service ?? null],
|
||||
)
|
||||
return { success: true, url }
|
||||
} catch (e) {
|
||||
@@ -83,13 +88,15 @@ async function isReferencePaid(reference: string): Promise<boolean> {
|
||||
* Entrega un checkout SumUp pagado: verifica el estado, reclama de forma atómica
|
||||
* (fulfilled 0->1) y acredita los PD. Idempotente. Devuelve true si acreditó ahora.
|
||||
*/
|
||||
export async function fulfillSumUpCheckout(reference: string): Promise<{ ok: boolean; paid: boolean }> {
|
||||
export async function fulfillSumUpCheckout(
|
||||
reference: string,
|
||||
): Promise<{ ok: boolean; paid: boolean; service?: string; character?: string }> {
|
||||
if (!reference) return { ok: false, paid: false }
|
||||
const paid = await isReferencePaid(reference)
|
||||
if (!paid) return { ok: false, paid: false }
|
||||
|
||||
const [rows] = await db(DB.default).query<RowDataPacket[]>(
|
||||
'SELECT id, account_id, amount FROM home_stripelog WHERE session_id = ? AND mode = ?',
|
||||
'SELECT id, account_id, amount, service, character_name FROM home_stripelog WHERE session_id = ? AND mode = ?',
|
||||
[reference, 'sumup'],
|
||||
)
|
||||
const log = rows[0]
|
||||
@@ -102,6 +109,15 @@ export async function fulfillSumUpCheckout(reference: string): Promise<{ ok: boo
|
||||
)
|
||||
if (res.affectedRows === 0) return { ok: false, paid: true }
|
||||
|
||||
// Pago de servicio (renombrar…): ejecuta la acción sobre el personaje.
|
||||
const service = log.service ? String(log.service) : ''
|
||||
const cfg = service ? getPaidService(service) : null
|
||||
if (cfg) {
|
||||
const ok = await cfg.fulfill(String(log.character_name), { service })
|
||||
return { ok, paid: true, service, character: String(log.character_name) }
|
||||
}
|
||||
|
||||
// Sin servicio: compra de PD (comportamiento por defecto).
|
||||
const points = Math.round(Number(log.amount) * PD_PER_UNIT)
|
||||
const ok = await creditDPoints(Number(log.account_id), points)
|
||||
return { ok, paid: true }
|
||||
|
||||
@@ -266,7 +266,11 @@
|
||||
"unstuckDone": "Unstucked",
|
||||
"reviveChoose": "Choose the character you want to revive",
|
||||
"reviveProcessing": "Reviving",
|
||||
"reviveDone": "Revived"
|
||||
"reviveDone": "Revived",
|
||||
"reviveInfo1": "The <b>Revive character</b> tool lets you revive a dead character.",
|
||||
"reviveInfo2": "Use this option when your character is dead and no other option works.",
|
||||
"reviveNote1": "The character must be offline.",
|
||||
"reviveNote2": "You can repeat the action on the same character every 12 hours."
|
||||
},
|
||||
"Paid": {
|
||||
"rename": {
|
||||
|
||||
@@ -266,7 +266,11 @@
|
||||
"unstuckDone": "Desbloqueado",
|
||||
"reviveChoose": "Escoge el personaje que quieres revivir",
|
||||
"reviveProcessing": "Reviviendo",
|
||||
"reviveDone": "Revivido"
|
||||
"reviveDone": "Revivido",
|
||||
"reviveInfo1": "La herramienta <b>Revivir personaje</b> te permite revivir un personaje muerto.",
|
||||
"reviveInfo2": "Usa esta opción cuando tu personaje esté muerto y ninguna otra opción te sirva.",
|
||||
"reviveNote1": "Se requiere que el personaje esté desconectado.",
|
||||
"reviveNote2": "Se puede repetir la acción en un mismo personaje cada 12 horas."
|
||||
},
|
||||
"Paid": {
|
||||
"rename": {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-- Pagos de servicio por SumUp (p.ej. /rename-character): guarda a qué servicio
|
||||
-- corresponde el checkout para que la reconciliación ejecute la acción (renombrar)
|
||||
-- en vez de acreditar PD. NULL = compra de PD (comportamiento por defecto).
|
||||
-- Ver lib/sumup.ts (createSumUpCheckout / fulfillSumUpCheckout).
|
||||
ALTER TABLE home_stripelog ADD COLUMN IF NOT EXISTS service VARCHAR(32) NULL DEFAULT NULL;
|
||||
Reference in New Issue
Block a user