> ## Documentation Index
> Fetch the complete documentation index at: https://strapi-suite.littlebox.pt/llms.txt
> Use this file to discover all available pages before exploring further.

# Payments

> Take Stripe payments and show the order status.

## Stripe Payment Link

`POST /orders/:publicId/payment`

Session: the guest session that placed the order, or the login session of the order's customer (any mode). Rate limit: `order.read`.

```json Response 200 theme={null}
{
  "url": "https://checkout.stripe.com/c/pay/cs_test_YOUR_SESSION",
  "expiresAt": "2026-11-28T09:55:00.000Z",
  "amount": 4990,
  "reused": false
}
```

* The amount always comes from the order: what is due right now.
* Strapi keeps one live link per order. Asking again returns the same link (`reused: true`) while it has more than an hour left.
* A link lives just under 24 hours.
* Stripe Checkout shows the payment methods enabled in the store's Stripe account (cards, Multibanco and others).

| Status | Code | When |
| - | - | - |
| 400 | `invalid` | `publicId` is not a UUID. |
| 404 | `ORDER_NOT_FOUND` | Unknown order, or an order of another session or customer. They are never told apart. |
| 409 | `NOTHING_DUE` | The order is fully paid. |
| 409 | `PAYMENT_PENDING` | A payment awaits confirmation (for example Multibanco). No new link meanwhile. |
| 409 | `ACTION_NOT_AVAILABLE` | The order is not open (cancelled or archived). |
| 502 | `STRIPE_UNREACHABLE`, `STRIPE_REQUEST_FAILED` | Stripe failed. Retry later. |
| 503 | `STRIPE_NOT_CONFIGURED`, `STOREFRONT_URL_MISSING` | The store is not set up for payments. |

## Return URLs

After the payment, Stripe sends the browser to `{storefrontUrl}{successPath}?order={publicId}`. When the customer gives up, it sends them to `{storefrontUrl}{cancelPath}?order={publicId}`. The store owner sets both paths in the Stripe settings of the module. The defaults are `/checkout/success` and `/checkout/cancel`, which match the structure above.

## The Webhook

Strapi handles the Stripe webhook by itself at `POST /api/littlebox-strapi-suite/ecommerce/stripe/webhook`. Stripe signs each call with the `Stripe-Signature` header. Your frontend has nothing to do for it, except that **Strapi must be reachable from Stripe** at that URL. The store owner subscribes these events in the Stripe dashboard: `checkout.session.completed`, `checkout.session.async_payment_succeeded`, `checkout.session.async_payment_failed`, `checkout.session.expired`, `charge.refunded`, `refund.updated` and `refund.failed`.

## Order Status

`GET /orders/:publicId/status`

Session: same as the payment link. Rate limit: `order.read`.

```json Response 200 theme={null}
{
  "publicId": "3f6c1d2e-8b7a-4c1f-9e2d-5a4b3c2d1e0f",
  "reference": "#1042",
  "createdAt": "2026-11-27T10:02:11.000Z",
  "locale": "en",
  "orderStatus": "OPEN",
  "paymentStatus": "PAID",
  "paymentResult": "PAID",
  "currency": "EUR",
  "totals": {
    "itemsOriginal": 5000,
    "productDiscount": 0,
    "subtotal": 5000,
    "orderDiscount": 500,
    "shippingTotal": 490,
    "total": 4990,
    "paid": 4990,
    "due": 0
  },
  "lines": [
    { "name": "Littlebox Strapi Suite T-Shirt", "option": "Black / M", "sku": "LSS-TEE-BLK-M", "quantity": 2, "unitPrice": 2500, "unitDiscount": 0, "total": 5000, "isGift": false }
  ],
  "promotions": [{ "name": "Welcome offer", "amount": 500 }],
  "shipping": { "name": "Standard delivery" }
}
```

`paymentResult` is the field to show on the confirmation page:

| `paymentResult` | Meaning |
| - | - |
| `PAID` | Nothing is due. |
| `PROCESSING` | Stripe accepted a payment that confirms later (for example Multibanco). |
| `UNPAID` | Something is still due. Right after Stripe's redirect, the webhook may not have arrived yet. |
| `CANCELLED` | The order was cancelled. |

`orderStatus` is `OPEN`, `ARCHIVED` or `CANCELLED`. `paymentStatus` is `PENDING`, `PARTIALLY_PAID`, `PAID`, `PARTIALLY_REFUNDED`, `REFUNDED` or `REFUND_DUE`. The answer never carries addresses, emails or internal ids.

> [!WARNING]
>
> Reaching the success page does not prove the payment. Always read the status. If it still says `UNPAID`, show
> "We are confirming your payment" and refresh the page every few seconds for a short while.

```tsx src/app/(store)/checkout/success/page.tsx theme={null}
import { getLocale } from "next-intl/server";
import { storeFetch, StoreApiError } from "@/lib/store/client";
import { readAuth } from "@/lib/store/session";
import { formatMoney } from "@/lib/store/money";
import type { OrderStatus } from "@/lib/store/types";
import AutoRefresh from "./auto-refresh";

const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;

export default async function SuccessPage({ searchParams }: { searchParams: Promise<{ order?: string }> }) {
  const { order } = await searchParams;
  if (!order || !UUID.test(order)) return <p>Order not found.</p>;
  const locale = await getLocale();
  let status: OrderStatus;
  try {
    status = await storeFetch<OrderStatus>(`/orders/${order}/status`, { auth: await readAuth() });
  } catch (error) {
    if (error instanceof StoreApiError && (error.status === 404 || error.status === 401)) {
      return <p>We could not find this order in your session. Check your confirmation email.</p>;
    }
    throw error;
  }
  return (
    <main>
      <h1>Order {status.reference}</h1>
      {status.paymentResult === "PAID" && <p>Thank you! Your payment is confirmed.</p>}
      {status.paymentResult === "PROCESSING" && <p>Your payment is being processed. We will email you.</p>}
      {status.paymentResult === "UNPAID" && (
        <>
          <p>We are confirming your payment…</p>
          <AutoRefresh seconds={3} times={10} />
        </>
      )}
      {status.paymentResult === "CANCELLED" && <p>This order was cancelled.</p>}
      <p>Total {formatMoney(status.totals.total, locale)}</p>
    </main>
  );
}
```

```tsx src/app/(store)/checkout/success/auto-refresh.tsx theme={null}
"use client";

import { useEffect, useRef } from "react";
import { useRouter } from "next/navigation";

export default function AutoRefresh({ seconds, times }: { seconds: number; times: number }) {
  const router = useRouter();
  const count = useRef(0);
  useEffect(() => {
    const id = setInterval(() => {
      if (++count.current > times) return clearInterval(id);
      router.refresh();
    }, seconds * 1000);
    return () => clearInterval(id);
  }, [router, seconds, times]);
  return null;
}
```

The cancel page reads the same status and offers a "Try again" button bound to the `payOrder` action, which returns the live link again.

## Manual Payments

The storefront API only creates Stripe links. There is no manual payment method to choose at checkout. The store owner records other payments (bank transfer, MB WAY, cash) in the admin, or sends the customer payment instructions by email from the order. Your pages only need to read `paymentResult`, `totals.paid` and `totals.due` from the order status.

## Order Access

* A guest reads only the orders placed with its own checkout session. Keep the guest cookie until the customer reaches the confirmation page.
* A logged in customer reads all their orders, including guest orders placed with the same email before they registered.
* Order emails contain no "view your order" link to the storefront. Guests follow their order by email.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.