Skip to main content

Transaction Lifecycle

Payments should not be a black box. Know exactly where every transaction is at all times. Both STK Push and B2C payouts share the same state model. Understanding the lifecycle lets you handle every outcome correctly — including failures.

Transaction states

Terminal states — no further updates: SUCCESS, FAILED, REVERSED, CANCELLED

STK Push lifecycle

Typical completion: 30–90 seconds after the customer enters their PIN.

B2C payout lifecycle

Typical completion: 30 seconds to 5 minutes.

Receiving state updates

Supply a callbackUrl on every payment request. PalPluss delivers a POST to that URL when the transaction reaches a terminal state. See the Webhooks guide for payload structure and retry policy.

Polling

Poll GET /transactions/{id} if webhooks are unavailable.
Recommended polling intervals:
  1. Wait 15 seconds after initiation.
  2. Poll every 10 seconds while status is PENDING or PROCESSING.
  3. Stop at any terminal state.
  4. After 5 minutes without a terminal state, treat the transaction as likely failed.
Aggressive polling consumes your rate limit (60 requests/minute). Use webhooks as your primary mechanism.

Idempotency

  • Each POST /payments/stk creates a distinct transaction and a distinct M-Pesa checkout.
  • Retrying without customer action sends a new prompt — do not retry unless the customer requests it.
  • Service wallet top-ups support the Idempotency-Key header to prevent duplicate funding requests.