d-points: dejar sólo Stripe y SumUp con compra de PD funcional
Elimina las pestañas de PayPal/dLocal/Crypto/Skrill y por país; deja Información + Stripe + SumUp (las dos únicas pasarelas que se usarán). - Stripe: totalmente funcional reutilizando createCheckoutSession + webhook + página de éxito. Nueva ruta /api/dpoints/checkout crea la sesión con importe elegido por el usuario (1 unidad = 100 PD). - SumUp: integración real (lib/sumup.ts) mediante checkout hospedado, habilitada al definir SUMUP_API_KEY/SUMUP_MERCHANT_CODE; si no, avisa. - Nuevo servicio de entrega `dpoints` (lib/paid-services.ts) que acredita PD en home_api_points; entrega idempotente vía reclamo atómico. - Página /d-points-success entrega ambos proveedores (session_id/ref). - Iconos SVG generados para cada pasarela (stripe/sumup, marca + wordmark). - Moneda configurable con DP_CURRENCY (por defecto EUR). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { setRequestLocale } from 'next-intl/server'
|
||||
import { Link } from '@/i18n/navigation'
|
||||
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'
|
||||
|
||||
export default async function DPointsSuccessPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ locale: string }>
|
||||
searchParams: Promise<{ provider?: string; session_id?: string; ref?: string }>
|
||||
}) {
|
||||
const { locale } = await params
|
||||
setRequestLocale(locale)
|
||||
const { provider, session_id, ref } = await searchParams
|
||||
|
||||
// Entrega compartida con el webhook/return (idempotente vía reclamo atómico).
|
||||
let status: 'ok' | 'already' | 'error' = 'error'
|
||||
|
||||
if (provider === 'sumup' && ref) {
|
||||
const r = await fulfillSumUpCheckout(ref)
|
||||
if (r.ok) status = 'ok'
|
||||
else if (r.paid) status = 'already'
|
||||
} else if (session_id) {
|
||||
const r = await fulfillCheckoutSession(session_id)
|
||||
if (r.ok) status = 'ok'
|
||||
else if (await isSessionPaid(session_id)) status = 'already'
|
||||
}
|
||||
|
||||
return (
|
||||
<PageShell title="Adquirir PD">
|
||||
<div className="box-content">
|
||||
<div className="body-box-content centered">
|
||||
{status === 'ok' ? (
|
||||
<span className="ok-form-response">¡Pago completado! Tus PD ya fueron acreditados a tu cuenta.</span>
|
||||
) : status === 'already' ? (
|
||||
<span className="ok-form-response">Este pago ya había sido procesado. Tus PD están acreditados.</span>
|
||||
) : (
|
||||
<span className="red-form-response">No pudimos confirmar tu pago. Si se realizó el cargo, contacta con soporte.</span>
|
||||
)}
|
||||
<br />
|
||||
<br />
|
||||
<p>
|
||||
<Link href="/account">← Regresar a mi cuenta</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</PageShell>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user