import Link from "next/link"; import type { Metadata } from "next"; import { formatMoney } from "@salixcommerce/core"; import { FakePaymentControls } from "@/components/fake-payment-controls"; import { EmptyState, Hero, PageContainer, StatusBadge } from "@/components/ui"; import { applicationConfiguration } from "@/config/public"; import { loadCurrentOrder } from "@/server/commerce/current-commerce"; import { loadCurrentPayment } from "@/server/payments/current-payment"; export const metadata: Metadata = { title: "Fake payment checkout" }; export const dynamic = "force-dynamic"; export default async function FakeCheckoutPage({ searchParams, }: Readonly<{ searchParams: Promise> }>) { const params = await searchParams; const orderReference = typeof params.order === "string" ? params.order : ""; const paymentReference = typeof params.payment === "string" ? params.payment : ""; const [order, payment] = await Promise.all([ loadCurrentOrder(orderReference), loadCurrentPayment(orderReference), ]); if ( order === null || payment === null || payment.provider !== "fake" || payment.providerPaymentReference !== paymentReference ) { return ( Return to shop} description="Fake payments are visible only to the browser that created the order." title="No authorized payment" /> ); } return (
{payment.status.replaceAll("_", " ")}

Order {order.reference}

Amount: {formatMoney(payment.amount, applicationConfiguration.business.locale)} {payment.status === "pending" ? ( ) : ( Return to order status )}
); }