Skip to content

feat(payment): Mayar jadi satu-satunya payment gateway (API key, Web Token, webhook) - #3

Merged
ronalandroid merged 1 commit into
mainfrom
feat/mayar-payment-gateway
Nov 15, 2026
Merged

ronalandroid merged 1 commit into
mainfrom
feat/mayar-payment-gateway

Conversation

@ronalandroid

Copy link
Copy Markdown
Owner

Ringkasan

Mayar (Headless API v2) sekarang jadi satu-satunya payment gateway untuk checkout POS online dan langganan. DOKU dihapus.

Perubahan

  • DOKU dihapus: provider, endpoint /api/webhooks/doku, env DOKU_*, dan script smoke DOKU. Deployment yang masih berisi PAYMENT_GATEWAY_PROVIDER=doku / SUBSCRIPTION_PAYMENT_MODE=doku_* tetap bisa boot. Nilainya dibaca sebagai Mayar dan muncul peringatan di /api/admin/system-status.
  • API key (MAYAR_API_KEY) dipakai untuk POST /hl/v2/payments/create dan GET /hl/v2/payments/{id}.
  • Web Token (MAYAR_WEBHOOK_TOKEN): webhook wajib membawa token dari dashboard Mayar di header X-Callback-Token. ?token= di URL atau HMAC body juga diterima. API key tidak pernah diterima sebagai token webhook.
  • Webhook "paid" dicek ulang ke API Mayar memakai referensi yang disimpan saat pembayaran dibuat, dan nominalnya harus sama. Webhook palsu tidak bisa menandai order lunas. Event non-pembayaran, tes dashboard, dan order yang tidak dikenal dijawab 200. Webhook ganda diabaikan.
  • Pembayaran online baru aktif kalau API key dan Web Token sama-sama terisi.
  • Sandbox default ke https://api.mayar.io (sesuai docs Mayar terbaru). Akun lama web.mayar.club bisa set MAYAR_SANDBOX_BASE_URL=https://api.mayar.club.
  • ?token= disamarkan di log request/alert.
  • Baru: backend/scripts/mayar-connect.mjs (cek key, daftarkan + tes URL webhook), scripts/smoke-local-mayar.mjs (uji end-to-end lokal dengan Mayar tiruan), docs/engineering/MAYAR_INTEGRATION_GUIDE.md.
  • Template env, Coolify, release:verify-config, dan script staging diperbarui ke Mayar.

Setelah merge

  1. Env backend di Coolify: PAYMENT_GATEWAY_PROVIDER=mayar, MAYAR_ENVIRONMENT, MAYAR_API_KEY, MAYAR_WEBHOOK_TOKEN (Web Token). Hapus DOKU_*, lalu redeploy.
  2. Mayar → Integrasi → Webhook: https://api.kaffepos.my.id/api/webhooks/mayar, atau jalankan node scripts/mayar-connect.mjs --register di container backend.
  3. node scripts/mayar-connect.mjs. Kalau semua ✓, Mayar sudah terhubung.

Pengujian

  • Backend: 47 file / 240 tes lulus. Frontend: 57 file / 209 tes lulus. Typecheck, lint, dan vite build OK.
  • npm run smoke:local:mayar dengan Postgres lokal + Mayar tiruan: semua lulus. Yang diuji: order QRIS POS, webhook tanpa/salah token (401), webhook "paid" palsu saat Mayar belum lunas (409), pelunasan sekali + duplikat diabaikan, aktivasi langganan, cek status manual idempoten, mayar-connect --register, dan token tidak muncul di log.
  • Belum diuji ke API Mayar asli karena butuh API key di server.

Generated by Claude Code

…d webhook

- Remove DOKU (provider, /api/webhooks/doku, env, scripts). Legacy
  PAYMENT_GATEWAY_PROVIDER=doku / SUBSCRIPTION_PAYMENT_MODE=doku_* still boot,
  read as Mayar with a system-status warning.
- Webhook auth: MAYAR_WEBHOOK_TOKEN (Mayar dashboard "Web Token") via the
  X-Callback-Token header, ?token= on the URL, or an HMAC of the raw body.
  The API key is never accepted as a webhook token.
- Never trust a "paid" webhook on its own: re-read GET /hl/v2/payments/{id}
  with the reference stored at creation and require a matching amount before
  settling POS orders or activating subscriptions. Non-payment events and
  orders KaffePOS does not know are acknowledged with 200.
- Online payment only opens when both MAYAR_API_KEY and MAYAR_WEBHOOK_TOKEN
  are set. Sandbox host defaults to api.mayar.io (current Mayar docs).
- Redact ?token= from request logs and alerts.
- Add backend/scripts/mayar-connect.mjs (check key, register + test webhook),
  scripts/smoke-local-mayar.mjs (local end-to-end run with a fake Mayar API)
  and docs/engineering/MAYAR_INTEGRATION_GUIDE.md. Update env templates,
  release checks and staging scripts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011vndxq8hQ8FPSGhexsE9Tz
@ronalandroid
ronalandroid merged commit e791487 into main Nov 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants