Slice · AI prompt
Indonesia payment providers behind one slug + ONE shared Convex backend (convex/features/payment discriminates on a provider column: paymentOrders + paymentWebhookEvents, unprefixed). Two frontend variants: doku — DOKU Hosted Checkout + Direct (VA / QRIS / e-Wallet / PayLater), HMAC-SHA256 signed REST, signature-verified webhook, idempotent retries, dependency-free, server-side env only. midtrans — Snap hosted-modal checkout + orders history (needs npm midtrans-client + a NEXT_PUBLIC_MIDTRANS_CLIENT_KEY). Install one with `npx rr add payment doku|midtrans`, or both. A future stripe variant is reserved in the schema's provider union.
# Install `payment` — Payment — Indonesia PSP (DOKU · Midtrans)
> Indonesia payment providers behind one slug + ONE shared Convex backend (convex/features/payment discriminates on a provider column: paymentOrders + paymentWebhookEvents, unprefixed).
📚 Knowledge base : https://resource.rahmanef.com/llms.txt
📦 Slice detail : https://resource.rahmanef.com/slices/payment
🧠 JSON catalog : https://resource.rahmanef.com/api/knowledge?slice=payment
🔗 Source : https://github.com/rahmanef63/resource-site/tree/main/frontend/slices/payment
## 1. Install
```bash
# alias: npx rr add payment
```
The CLI copies `frontend/slices/payment/` into your project + augments `.env.example` + installs npm deps automatically. Run it from your project root.
## 2. What it ships
- npm: `midtrans-client`
- shadcn primitives: `badge`, `button`, `card`, `dialog`, `input`, `label`, `select`, `skeleton`
- peer slices (cascade install):
- `convex-auth` — Order ownership requires authenticated user (guest checkout works without).
- env vars:
- `DOKU_CLIENT_ID` (convex)
- `DOKU_SECRET_KEY` (convex)
- `DOKU_IS_PRODUCTION` (convex)
- `MIDTRANS_SERVER_KEY` (convex)
- `MIDTRANS_CLIENT_KEY` (next-public)
- `MIDTRANS_IS_PRODUCTION` (convex)
- convex feature paths: `convex/features/payment`
## 3. Wire it up
Run `npx rr add payment` for both providers, or `npx rr add payment doku` / `midtrans`. Either variant copies the shared convex/features/payment backend. doku: Checkout (hosted) or Direct (single channel → VA/QRIS/deeplink); webhook /webhooks/doku verifies HMAC-SHA256; server-only, no NEXT_PUBLIC_*. midtrans: Snap.js + window.snap.pay(token); webhook verifies signature_key; needs NEXT_PUBLIC_MIDTRANS_CLIENT_KEY. Both patch paymentOrders by orderId; sandbox by default.
## Rules of engagement
- shadcn-only UI primitives. No raw `<button>` / `<dialog>` / native date or file inputs.
- 200-line hard cap per source file (extract neighbours when over).
- All Convex queries hit an index (`.withIndex(...)`); never bare `.collect()`.
- Public mutations/queries declare `args:` validators + authz.
- Full ruleset: https://resource.rahmanef.com/best-practice
The agent will fetch /llms.txt for the full ruleset and use /api/knowledge for the JSON catalog.