# Step-by-step: Connect Stripe and Swish for table ordering

**Version:** 2.3  
**Applies to:** maca Restu Pro **1.4.0+** with **online menu**, **table ordering**, **prices on dishes**, and **guest order status**

This guide helps you set up **guest payments**: guests choose **Pay online** (Stripe Checkout) or **Pay with server** (staff marks the order paid). You control **when** the choice appears and which methods are allowed under **maca Restu → Payments**.

> **Important:** maca Restu Pro is **not** a POS or certified payment terminal. You are responsible for VAT, receipts, refunds, and compliance with Stripe/Swish rules. Payment for your **Pro license** on maca.se uses a **separate** Stripe setup — do **not** reuse those keys here.

---

## Before you start

1. **Table ordering on** — *maca Restu → Settings* → enable **Guest order list**.
2. **HTTPS** — WordPress **Site Address** must use `https://`.
3. **Admin access** — you need access to Stripe (and your bank’s Swish portal if applicable).
4. Open **maca Restu → Payments** in WordPress — paste keys and copy webhook URLs there.
5. **Prices on the menu** — guest payments require table ordering to show prices (otherwise there is no amount to charge online).

---

## Guest flow in maca Restu (summary)

| Setting | Meaning |
|---------|---------|
| **Pay at table** | Guest chooses to pay the server; staff tap **Mark paid** on the waiter page |
| **When guests can pay (online)** | **At order** = right after submitting · **After meal** = when the order is **served** |
| **Enable Stripe checkout** | Required for **Pay online**; Stripe keys + webhook |
| **Show Pay online** | Can be disabled if you only accept payment at the table |

**Guest flow:** Submit order → open **My orders** / order status → choose how to pay → (online: Stripe) or (server: pay when staff visit the table). Optional **Split bill** — divide the total among several people and pay your share online.

**Guest QR / restore session:** If the guest lost order status (e.g. private browsing or cleared storage), staff can show **Guest QR** on waiter/kitchen order cards. The guest scans and order status reopens via `?maca_order=`.

**Staff flow:** The waiter page shows badges such as *Pay at table* or *Paid*, plus amount, time, and payment ID when enabled. **Mark paid** is hidden if the guest already paid online. The kitchen KDS can show the same payment info if configured.

**Tips:** Under Payments you can enable tips (preset percentages or fixed amounts, optional custom amount). Tips are included in the Stripe total and stored on the order.

**Email confirmation (optional):** For **Pay online**, guests can check *Email order confirmation* and enter an address. After successful payment, an **order and payment confirmation** is sent with line items and VAT breakdown. The address is **not stored** in WordPress — it is passed through Stripe Checkout for sending only. The email clearly states it is **not** an official tax receipt; your POS handles the legal receipt.

**VAT setup:** Under **Settings → Restaurant**, set service type (dine-in / takeaway) and VAT rates. Set **VAT code** per dish under **Dishes** (food / alcohol) so the email breakdown is correct.

**Payment history:** *maca Restu → Payment history* (under Payments) — filters, summary, and CSV export for reconciliation.

> You can enable **pay at table only** without Stripe — check **Pay at table** and leave **Stripe checkout** off.

---

## Overview: Stripe or Swish?

| Option | Best when | Difficulty |
|--------|-----------|------------|
| **Stripe (recommended first)** | You want cards, Apple/Google Pay, and often **Swish via Stripe** in one account | Medium |
| **Swish direct (Handel)** | You already have Swish Handel with your bank and a technical partner | Higher |

Many restaurants start with **Stripe** and enable Swish under **Payment methods** in Stripe (step 8). Use direct Swish (part B) only if you **do not** use Swish through Stripe.

### International guests (tourists, etc.)

| Method | Outside Sweden |
| --- | --- |
| **Stripe – cards** | Usually yes. Guests with foreign Visa/Mastercard can pay; amounts follow your Stripe account (often **SEK**). The guest's bank may charge FX fees. |
| **Apple Pay / Google Pay** | Depends on the guest's device and your Stripe settings. |
| **Swish (via Stripe or direct)** | Typically **Swedish Swish users** only. |

You do not need a separate “international” account for card payments — configure **Stripe** and mention online payments in your **privacy notice** (see **maca Restu → Terms & Privacy**).

---

## {#stripe} Part A — Stripe (steps 1–10)

### Step 1 — Create a Stripe account

1. Go to [https://dashboard.stripe.com/register](https://dashboard.stripe.com/register).
2. Register with your **business email**.
3. Choose **Sweden** and **SEK** when prompted.
4. Confirm your email from Stripe.

### Step 2 — Activate your business in Stripe

1. Log in to the [Stripe Dashboard](https://dashboard.stripe.com/).
2. If you see **Complete your account**, open it.
3. Enter business name, organization number, restaurant address, and **payout bank account** (IBAN).
4. Upload any documents Stripe requests.
5. Wait until Stripe allows live payments.

### Step 3 — Own account vs Connect

**Typical single restaurant (simplest):**

- Use **your own** Stripe account.
- Payouts go to your bank.
- Paste **your** API keys into maca Restu (step 5).

**Chains or platforms (later):**

- **Stripe Connect** — each site uses a connected account (`acct_…`).
- Contact your developer before using Connect.

This guide assumes **your own Stripe account**.

### Step 4 — Turn on test mode

1. In the Dashboard header, enable **Test mode**.
2. No real money is charged in test mode.

### Step 5 — Get API keys (test)

1. Open **Developers → API keys**: [dashboard.stripe.com/test/apikeys](https://dashboard.stripe.com/test/apikeys)
2. Copy:
   - **Publishable key** — `pk_test_…`
   - **Secret key** — click **Reveal** — `sk_test_…` (never share publicly)
3. In WordPress: **maca Restu → Payments → Settings**.
4. Under **Stripe**: enable **Test mode**, paste both keys, **Save payment settings**.

### Step 6 — Webhook URL

Stripe notifies your site via a **webhook** when payment succeeds.

Your site URL is shown in:

- **maca Restu → Payments** (sidebar), or under the Stripe box.

Example:

`https://your-restaurant.com/wp-json/maca-menulist/v1/payments/stripe/webhook`

Copy the full `https` URL.

### Step 7 — Create the webhook in Stripe

1. While in **test mode**: **Developers → Webhooks**.
2. **Add endpoint**.
3. **Endpoint URL:** paste the maca Restu webhook URL.
4. **Description:** e.g. `maca Restu table orders test`.
5. Select events at minimum:
   - `checkout.session.completed`
   - `payment_intent.succeeded`
   - `payment_intent.payment_failed`
6. **Add endpoint**.
7. Open the endpoint → **Signing secret** → **Reveal** → copy `whsec_…`.
8. In WordPress: paste into **Webhook signing secret** → **Save**.

### Step 8 — Enable payment methods

1. **Settings → Payment methods**: [dashboard.stripe.com/settings/payment_methods](https://dashboard.stripe.com/settings/payment_methods)
2. Enable **Cards**, **Apple Pay** / **Google Pay** if available.
3. Enable **Swish** if Stripe offers it for your Swedish account (then you usually skip part B).

### Step 9 — Test guest payments

1. In WordPress: **Payments** → enable **Pay at table** and/or **Enable Stripe checkout**; choose **At order** or **After meal**.
2. Place a **test order** from the QR menu (with priced dishes).
3. **Manual:** choose **Pay with server** → open the waiter page → **Mark paid**.
4. **Online:** choose **Pay online** → pay with test card `4242 4242 4242 4242`, any future expiry/CVC.
5. Verify:
   - Stripe → **Payments** (test charge)
   - Stripe → **Webhooks → Recent deliveries** (successful `checkout.session.completed`)
   - Guest order status: *Paid — thank you!*
   - **maca Restu → Table orders** — payment status *paid*

### Step 10 — Go live

1. Complete step 2 for live payments.
2. Turn **Test mode** **off** in Stripe.
3. **Developers → API keys** (live): [dashboard.stripe.com/apikeys](https://dashboard.stripe.com/apikeys)
4. Copy `pk_live_…` and `sk_live_…`.
5. Create a **new live webhook** with the same events and your live URL.
6. In WordPress: disable **Test mode**, paste live keys and live `whsec_…` → **Save**.
7. Make a small real purchase and verify **Balance → Payouts**.

---

## {#swish} Part B — Swish direct (Swish Handel)

Use only if you **do not** take Swish via Stripe (part A, step 8).

### Step B1 — Get Swish Handel

1. Contact your **bank** for **Swish for business / Swish Handel**.
2. You receive a **10-digit business Swish number** (not a private number).
3. Your bank or **technical partner** provides API access and certificates.

### Step B2 — Technical setup

Swish Handel usually requires:

- **Merchant Swish number** (10 digits)
- **TLS certificate** from bank/partner
- **Callback URL** registered with the partner

In maca Restu (preparation):

1. **maca Restu → Payments → Settings → Swish**
2. Enter **Swish number (Handel)**
3. Enable **Test / sandbox** while testing
4. Register the **Swish callback URL** from the Payments page with your partner, then check **Callback URL registered**

> Direct Swish (certificate/API) in the plugin is still limited — use **Swish via Stripe** (step 8) when possible. Keep bank documentation if you implement Handel later.

### Step B3 — Swish via Stripe (easier)

If Swish appears under Stripe **Payment methods**:

1. Skip part B.
2. Follow **part A** and enable Swish in **step 8**.
3. Set **Stripe** as primary provider in maca Restu.

---

## Part C — maca Restu settings

1. **maca Restu → Payments → Settings**
2. **Guest payment flow**
   - **Pay at table** — guest chooses server; staff confirm payment
   - **When guests can pay** — *At order* or *After meal*
   - **Tips** — presets and optional custom amount
   - **Staff payment info** — waiter, kitchen, or both
   - **Enable Stripe checkout** + **Show Pay online**
3. **Primary provider** — Stripe (recommended)
4. Enter Stripe keys and webhook (part A)
5. Use the **checklist** until guest payment options and Stripe checkout are ready
6. **Payment history** — link from Payments; export CSV when needed

---

## Troubleshooting

| Issue | Fix |
|-------|-----|
| Not fully configured | Stripe: publishable + secret keys; Swish: 10-digit merchant number |
| Webhook 400/401 | Wrong `whsec_` — copy secret from the matching endpoint |
| Payment OK but order not paid | Check webhook (`checkout.session.completed`), `whsec_`, and public URL |
| No pay button for guest | Prices on? Payments enabled? For *After meal*, order must be *served* |
| Manual only | Enable **Pay at table**, disable Stripe checkout |
| Test card fails | Test mode must be on in both Stripe and maca Restu |
| Confused with maca license | Pro license = maca.se; guest payments = **your** Stripe/Swish under Payments |

---

## Support

- **Stripe:** [support.stripe.com](https://support.stripe.com/)
- **Swish business:** via your bank
- **maca Restu:** [maca.se](https://maca.se) — mention **guest payments**, not Pro license

---

## Quick reference — where in Stripe?

| Task | Location |
|------|----------|
| Register | [dashboard.stripe.com/register](https://dashboard.stripe.com/register) |
| Complete business | Dashboard → **Complete account** |
| Test API keys | **Developers → API keys** (test mode on) |
| Live API keys | **Developers → API keys** (test mode off) |
| Webhook | **Developers → Webhooks → Add endpoint** |
| Payment methods | **Settings → Payment methods** |
| Payments list | **Payments** |
| Payouts | **Balance → Payouts** |
