import { getTranslations, 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 t = await getTranslations('Points') 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 (
{status === 'ok' ? ( {t('dpointsSuccess.paidOk')} ) : status === 'already' ? ( {t('dpointsSuccess.alreadyPaid')} ) : ( {t('dpointsSuccess.error')} )}

{t('dpointsSuccess.backToAccount')}

) }