Overview Integration Summary
Medicare SIMRS implements a sequential payment gate for outpatient (rajal) self-pay (UMUM) patients at Alia hospital. Patients must pay at each checkpoint — Poli, Lab/Radiology, and Pharmacy — before the next station can proceed. Payment is handled entirely by Alia's payment gateway; Medicare only initiates the request and receives the result via webhook.
- Bundle transaction items per checkpoint station
- Call Alia API to create a payment request
- Block next-station actions until checkpoint is RELEASED
- Expose webhook endpoint for Alia callbacks
- Create internal deposit record upon RELEASED
- Expose
POST /payment-requestsendpoint - Expose
GET /payment-requests/{id}endpoint - Generate checkout URL and deliver to patient (WhatsApp/SMS)
- Process payment via QRIS, VA, etc.
- POST webhook to Medicare upon status change (RELEASED / EXPIRED / CANCELLED)
Checkpoint Station Flow
Integration Points Summary
| Direction | Endpoint | Triggered by | Purpose |
|---|---|---|---|
| Medicare → Alia | POST /payment-requests |
Staff clicks "Validate & Send" | Create payment request for a checkpoint bundle |
| Medicare → Alia | GET /payment-requests/{id} |
Polling job (every 2 minutes, fallback) | Re-sync payment status if webhook was missed |
| Alia → Medicare | POST /webhook/alia/payment-callback |
Patient completes payment on Alia platform | Notify Medicare of result (RELEASED / EXPIRED / CANCELLED) |
Full Payment Flow End to End
Complete sequence from patient registration to invoice closure, showing all interactions between Medicare, Alia, and the patient across all three checkpoints.
End-to-End Sequence — All Three Checkpoints
Outbound API: Medicare → Alia Alia must implement
Medicare will call these two endpoints on Alia's server.
The base URL is configured via PG_ALIA_BASE_URL on Medicare's side.
All requests include the header X-Api-Key: {PG_ALIA_API_KEY}.
POST /payment-requests — Create Payment Request
alia_order_id and awaits the webhook.
POST {ALIA_BASE_URL}/payment-requests
Content-Type: application/json
X-Api-Key: {PG_ALIA_API_KEY}
{
"reference_id": "MED-{noreg}-{station}-{epoch}",
"patient": {
"nopasien": "12345",
"nama": "BUDI SANTOSO",
"phone": "08123456789"
},
"station": "POLI",
"items": [
{
"kode": "TND001",
"deskripsi": "Konsultasi Dokter Umum",
"qty": 1,
"harga": 50000,
"subtotal": 50000
}
],
"total_amount": 50000,
"callback_url": "https://{MEDICARE_HOST}/webhook/alia/payment-callback"
}
{
"alia_order_id": "ALIA-20260511-001",
"checkout_url": "https://pay.alia.example/checkout/...",
"expires_at": "2026-05-11T12:00:00+07:00"
}
| Field | Type | Required | Description |
|---|---|---|---|
reference_id | string | REQ | Medicare's idempotency key. Format: MED-{noreg}-{station}-{epoch} |
patient.nopasien | string | REQ | Medicare internal patient ID |
patient.nama | string | REQ | Patient full name |
patient.phone | string | REQ | Patient phone for payment link delivery |
station | enum | REQ | One of: POLI, LAB_RAD, FARMASI |
items | array | REQ | Line items for the checkpoint |
total_amount | number | REQ | Total in IDR (integer) |
callback_url | string | REQ | Medicare webhook URL. Alia must POST the result here after payment. |
GET /payment-requests/{alia_order_id} — Check Status (Polling Fallback)
AWAITING_PAYMENT. Used to re-sync status if a webhook was delayed or missed.
This does not replace the webhook — webhook remains the primary path.
GET {ALIA_BASE_URL}/payment-requests/{alia_order_id}
X-Api-Key: {PG_ALIA_API_KEY}
{
"alia_order_id": "ALIA-20260511-001",
"reference_id": "MED-2605110001-POLI-1715414400",
"status": "RELEASED | AWAITING_PAYMENT | EXPIRED | CANCELLED",
"paid_at": "2026-05-11T10:30:00+07:00",
"amount": 50000
}
Webhook: Alia → Medicare Medicare implements
Alia must call this endpoint when a payment request changes status. Medicare's webhook handler is already live and ready to receive.
POST /webhook/alia/payment-callback
POST https://{MEDICARE_HOST}/webhook/alia/payment-callbackThis endpoint is public (no auth middleware). Security is enforced via HMAC-SHA256 signature verification and optional IP whitelist. No CSRF token required.
POST https://{MEDICARE_HOST}/webhook/alia/payment-callback
Content-Type: application/json
X-Alia-Signature: {hmac-sha256-hex}
{
"alia_order_id": "ALIA-20260511-001",
"reference_id": "MED-2605110001-POLI-1715414400",
"status": "RELEASED",
"paid_at": "2026-05-11T10:30:00+07:00",
"amount": 50000,
"payment_method": "QRIS",
"external_reference": "QRIS-REF-001"
}
X-Alia-Signature = HMAC-SHA256( key = PG_ALIA_WEBHOOK_SECRET, data = raw request body (UTF-8) ) // hex-encoded, lowercase
// Payment processed
HTTP 200 { "received": true }
// Bad signature
HTTP 401
// Server error — Alia should retry
HTTP 500
| Field | Type | Required | Description |
|---|---|---|---|
alia_order_id | string | REQ | Alia's order ID — from POST /payment-requests response |
reference_id | string | REQ | Medicare's reference ID — echo from original request |
status | enum | REQ | RELEASED (paid) · EXPIRED (timeout) · CANCELLED (voided) |
paid_at | datetime | REQ | ISO 8601 with timezone. Required for RELEASED; null for others. |
amount | number | REQ | Actual amount paid in IDR |
payment_method | string | OPT | e.g. QRIS, VA, CREDIT_CARD |
external_reference | string | OPT | Alia upstream transaction ID |
alia_order_id + status more than once,
Medicare returns HTTP 200 without re-processing. Safe to retry on network failure — no duplicate deposits.
Webhook Processing Sequence
Payment States State Machine
Each checkpoint progresses through these states. Alia is the source of truth for all terminal states — Medicare never auto-transitions to RELEASED, EXPIRED, or CANCELLED without a signal from Alia.
Checkpoint State Diagram
State Reference
| State | Set by | Meaning | Next States |
|---|---|---|---|
PENDING |
Medicare (internal) | Checkpoint row created, not yet submitted to Alia | AWAITING_PAYMENT, CANCELLED |
AWAITING_PAYMENT |
Medicare (internal) | Submitted to Alia successfully. Patient should pay via checkout URL. | RELEASED, EXPIRED, CANCELLED |
RELEASED |
Alia (webhook) | Patient paid. Next station unblocked. Deposit created in Medicare. | None — terminal |
EXPIRED |
Alia (webhook) | Payment link expired. Staff must re-submit the checkpoint. | None — terminal |
CANCELLED |
Alia (webhook) or admin | Payment request voided. Staff must re-submit. | None — terminal |
GET /payment-requests/{alia_order_id} every 2 minutes for
checkpoints in AWAITING_PAYMENT. If Alia returns a changed status,
Medicare applies the same transition logic as the webhook. This is a safety net only —
the webhook is the primary and preferred path.