Confirm a payment
A prompt was sent when STK returns ok. The payment is settled only when paid is true.
Confirm a payment
STK ok: true means Safaricom accepted the prompt. Mark the order paid only after BluePay reports it settled.
Two signals, one result
| Signal | When to use it |
|---|---|
| Webhook | BluePay POSTs the result to your callback URL. Verify X-BluePay-Signature (HMAC-SHA256 of the raw body, keyed with the API secret) and return 2xx quickly. |
| Payment status | Your server asks for the latest state. Use this when the webhook has not arrived. There are no automatic webhook retries. |
How to read status
| Field | Meaning |
|---|---|
paid: true | Settled. Fulfill the order. |
found: true and paid: false | BluePay has the STK. It is still pending or it failed. Read order.status: pending, completed, or failed. |
found: false | No row for that lookup key. Check the id you stored. |
payment.pending_confirmation | The receipt is still a temporary RCHK-… value. Wait for the M-Pesa receipt. |
Look up by checkout_request_id first. account_reference (or external_reference) returns the newest STK for that invoice id. stk_request_id is the integer from the STK response.
Webhook rules
- Account → Callback URL is the default. An STK
callback_urloverrides it for that payment only. - Safaricom notifies BluePay. Your URL receives BluePay’s JSON, not Safaricom’s callback.
- Header
X-BluePay-Eventismpesa.payment.receivedormpesa.payment.failedfor collections. - Header
Idempotency-Keyis the dedupe key for that delivery. Store it so a repeat delivery does not fulfill twice. - Compare the amount, phone, and
account_referenceindatawith the order you stored.
The payload and the PHP and Node checks are on Webhooks.