1.4 KiB
1.4 KiB
Runbook: Payments Sanity Check (Local Mock)
Validate payment create + webhook reconciliation without hitting Moyasar.
Preconditions
- Venv + backend deps installed.
- DB migrated.
- Run from repo root unless noted.
Steps
- Start local mock server on
127.0.0.1:8001exposingPOST /v1/payments. - Seed data:
source venv/bin/activatecd backendpython3 manage.py migratepython3 manage.py seed_demo
- Run API with mock settings:
DJANGO_DEBUG=1 MOYASAR_SECRET_KEY=sk_test MOYASAR_PUBLISHABLE_KEY=pk_test MOYASAR_BASE_URL=http://127.0.0.1:8001 MOYASAR_WEBHOOK_SECRET=whsec python3 manage.py runserver 8000
- Generate JWT in shell (demo user) and store as
<ACCESS>. - Create payment:
POST /api/payments/withbooking_id,provider=moyasar,idempotency_key, valid source.
- Send paid webhook:
POST /api/payments/webhook/with{"type":"payment_paid","secret_token":"whsec","data":{"id":"<external_id>"}}
- Verify
GET /api/payments/shows statuspaidandpaid_atset.
Expected Results
- Create payment returns
status=initiated+ providerexternal_id+redirect_url. - Webhook returns
{"detail":"Webhook processed"}. - Payment transitions to
paididempotently.
Edge Checks
- Wrong/missing webhook secret ->
401. - Reused idempotency key -> same payment reused, no duplicate charge.
- Unsupported sources rejected by validation.
Cleanup
Stop Django + mock processes.