Generaliza los servicios de personaje de pago (5) con infra común
- lib/paid-services.ts: config PAID_SERVICES (rename/customize/change-race/ change-faction/level-up) con comando SOAP, precio y productName por servicio. - app/api/character/[service]/checkout: ruta de checkout GENÉRICA (valida servicio + personaje, crea la sesión Stripe con successUrl /service-success?service=...). - app/[locale]/service-success: página de éxito ÚNICA que verifica el pago (claimPaidCheckout) y ejecuta el comando SOAP del servicio. - components/ServicePageContent: contenido común (guardas + PaidServiceForm). - 5 páginas mínimas /rename /customize /change-race /change-faction /level-up. - Catálogo Paid (por servicio: title/pay/success) sustituye a Rename. Verificado: 5 páginas redirigen a login, checkout 401 sin sesión, servicio inválido 404, service-success con pago inválido no entrega (muestra error). Pendiente: gold (cantidad) y transfer (destino+token), variantes del patrón. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
getRenamePrice,
|
||||
getCustomizePrice,
|
||||
getChangeRacePrice,
|
||||
getChangeFactionPrice,
|
||||
getLevelUpPrice,
|
||||
} from './prices'
|
||||
|
||||
export interface PaidServiceConfig {
|
||||
command: (character: string) => string
|
||||
getPrice: () => Promise<number>
|
||||
productName: (character: string) => string
|
||||
}
|
||||
|
||||
// Servicios de personaje de pago. slug = ruta (/rename, /customize, ...) y clave de
|
||||
// catálogo (Paid.<slug>). Comandos SOAP tal cual las success views de Django.
|
||||
export const PAID_SERVICES: Record<string, PaidServiceConfig> = {
|
||||
rename: {
|
||||
command: (c) => `.char rename ${c}`,
|
||||
getPrice: getRenamePrice,
|
||||
productName: (c) => `Renombrar personaje: ${c}`,
|
||||
},
|
||||
customize: {
|
||||
command: (c) => `.char customi ${c}`,
|
||||
getPrice: getCustomizePrice,
|
||||
productName: (c) => `Personalizar personaje: ${c}`,
|
||||
},
|
||||
'change-race': {
|
||||
command: (c) => `.char changerace ${c}`,
|
||||
getPrice: getChangeRacePrice,
|
||||
productName: (c) => `Cambiar raza: ${c}`,
|
||||
},
|
||||
'change-faction': {
|
||||
command: (c) => `.char changef ${c}`,
|
||||
getPrice: getChangeFactionPrice,
|
||||
productName: (c) => `Cambiar facción: ${c}`,
|
||||
},
|
||||
'level-up': {
|
||||
command: (c) => `.char level ${c} 80`,
|
||||
getPrice: getLevelUpPrice,
|
||||
productName: (c) => `Subir a nivel 80: ${c}`,
|
||||
},
|
||||
}
|
||||
|
||||
export function getPaidService(slug: string): PaidServiceConfig | null {
|
||||
return PAID_SERVICES[slug] ?? null
|
||||
}
|
||||
Reference in New Issue
Block a user