Payment methods
Turn them on or off in Dashboard > Settings > Payments:
| Method | How it works | Marked paid |
|---|---|---|
| Cash | The customer pays on pickup, delivery or at the table | by staff: Cash received on the kitchen board |
| Card (Thawani) | The customer pays on Thawani's secure page before the kitchen starts | automatically, after Thawani confirms |
At least one method must stay on, or customers cannot order.
Setting up Thawani
Open a merchant account at Thawani Pay and get two key pairs from the merchant portal: UAT (test) and production.
In
.env:THAWANI_MODE="uat" THAWANI_SECRET_KEY="your UAT secret key" THAWANI_PUBLISHABLE_KEY="your UAT publishable key" SITE_URL="https://order.your-restaurant.com"Restart, then switch on Card (Thawani) in Dashboard > Settings. The settings page shows "Thawani keys are set (uat)".
Place a test order with Thawani's test cards. When it works, change to your production keys and
THAWANI_MODE="live".
Card payment needs the currency set to OMR (Thawani charges in rials) and an order total of at least 0.100 OMR.
What happens during a card payment
- Checkout sends the order to
POST /api/orderswithpaymentMethod: "CARD". The server prices the order from the database, saves it asUNPAID, and asks Thawani for a checkout session for the total. - The customer is sent to Thawani's payment page.
- Thawani sends the customer back to
/api/payments/thawani/return?order=<code>. - That route asks Thawani for the session's status. Only when Thawani answers paid does the order become
PAID. Nothing in the return address is trusted. - The customer lands on the tracking page.
If the customer cancels on Thawani's page, the order is cancelled and stays unpaid. If Thawani cannot be reached when the order is placed, the order is cancelled at once and the customer is asked to try again or pay cash.
If the customer closes the browser before coming back, the order stays UNPAID and the tracking page shows "Waiting for Thawani to confirm the payment". Check it in the Thawani merchant portal (the session id is stored on the order as paymentRef).
Adding another payment provider
The Thawani code is self-contained in src/lib/thawani.ts (create a session, ask for its status) and two places that call it: src/app/api/orders/route.ts and src/app/api/payments/thawani/return/route.ts. A new provider follows the same pattern: create a payment for order.total, store its id in paymentRef, and mark the order paid only after asking the provider on the server.