Xendit WireMock (Local)
This project includes a local WireMock service to mock Xendit API interactions.
Start/Stop
./scripts/wiremock.sh up
./scripts/wiremock.sh logs
./scripts/wiremock.sh down
WireMock runs at http://localhost:8080.
End-to-End Mock Flow
Run an automated backend flow test against WireMock:
npm run test:wiremock
This script will:
- Start WireMock
- Apply local D1 migrations
- Build and start Workers preview
- Execute payment create -> status -> webhook -> license verify checks
- Validate provider failure and timeout behavior (expects 502 mapping)
- Tear down WireMock
Configure Backend to Use WireMock
Set local env values for Workers preview:
export XENDIT_API_URL=http://localhost:8080
export XENDIT_SECRET_KEY=local-mock-key
export XENDIT_WEBHOOK_TOKEN=local-webhook-token
Then run preview:
npm run preview
Available Mock Endpoints
POST /qr_codessuccess (qr_mock_pending)POST /qr_codesfailure whenreference_idcontainsfailPOST /qr_codestimeout scenario id whenreference_idcontainstimeoutGET /qr_codes/qr_mock_pending=>PENDINGGET /qr_codes/qr_mock_completed=>COMPLETEDGET /qr_codes/qr_mock_failed=>FAILEDGET /qr_codes/qr_mock_timeout=> delayed response for timeout testing
Webhook Payload Samples
infra/wiremock/__files/webhook-completed.jsoninfra/wiremock/__files/webhook-failed.json
Use with backend webhook route:
curl -X POST http://localhost:8787/api/v1/payments/webhook \
-H 'content-type: application/json' \
-H 'x-callback-token: local-webhook-token' \
--data @infra/wiremock/__files/webhook-completed.json