Skip to main content

Overview

Dunning is the process of automatically collecting overdue payments from subscribers. FyberPay’s dunning pipeline handles this end-to-end: sending payment reminders, retrying M-Pesa STK Push, restricting service via walled garden, and ultimately suspending accounts that remain unpaid. The entire pipeline is automated and configurable per organization. Once set up, it runs continuously without manual intervention.

Dunning State Machine

Every subscription has a dunningState that tracks where it is in the collection pipeline. The state machine enforces valid transitions, preventing invalid jumps.

States

StateDescriptionSubscriber Experience
noneNo dunning active. Subscription is current.Full internet access
retryingPayment is overdue. FyberPay is sending STK Push retries.Full internet access (grace period)
walled_gardenExtended non-payment. Service restricted to payment portal only.Can only access FyberPay portal and M-Pesa
suspendedFinal escalation. Service fully disconnected.No internet access

State Transition Diagram

                    payment received
          +--------------------------------+
          |                                |
          v          (no payment)          |
        none -----> retrying -----> walled_garden -----> suspended
          ^             |                |                    |
          |             |                |                    |
          +-------------+----------------+--------------------+
                        payment received at any stage
                        resets dunning back to "none"

Valid Transitions

FromToTrigger
noneretryingSubscription expires without payment
retryingwalled_gardenConfigurable days pass without payment
retryingnonePayment received
walled_gardensuspendedConfigurable days pass without payment
walled_gardennonePayment received
suspendednonePayment received or manual reactivation
Payment at any dunning stage resets the state to none, restores the subscriber’s RADIUS group, extends the subscription, and sends a confirmation notification. This happens automatically with zero manual intervention.

Configuration

Navigate to Settings > Dunning to configure the dunning pipeline for your organization.

Retry Intervals

The retryIntervals setting controls when FyberPay sends automatic STK Push payment retries after a subscription expires. Default: [1, 3, 7] (retry on day 1, day 3, and day 7 after expiry) Each retry sends an M-Pesa STK Push to the subscriber’s phone number, prompting them to pay the outstanding invoice.
For ISPs that want faster payment collection:
retryIntervals: [1, 2, 3, 5]
walledGardenAfterDays: 3
suspendAfterDays: 7
Retries on days 1, 2, 3, and 5. Walled garden after 3 days. Full suspension after 7 days.

Walled Garden Threshold

The walledGardenAfterDays setting controls when a subscriber’s service is restricted to the payment portal only. Default: 7 days after expiry When a subscriber enters the walled garden:
  1. Their RADIUS group is changed to walled-garden
  2. They can only access the FyberPay payment portal and M-Pesa endpoints
  3. All other internet traffic is blocked
  4. They receive an SMS and email notification explaining the restriction
  5. STK Push retries continue during the walled garden period

Suspension Threshold

The suspendAfterDays setting controls when a subscriber is fully disconnected. Default: 14 days after expiry When suspended:
  1. The subscription status changes to suspended
  2. RADIUS credentials remain in the walled-garden group (effectively no access)
  3. The subscriber receives a final SMS and email notification
  4. No further automatic retries are attempted
  5. Service is restored immediately if payment is received

Timeline Example

Here is a concrete example of the dunning pipeline with default settings for a subscriber whose subscription expired on March 1st.
DateDayEventSubscriber Impact
Mar 10Subscription expiresFull access (grace period)
Mar 21STK Push retry #1 sentFull access
Mar 43STK Push retry #2 sentFull access
Mar 87STK Push retry #3 + walled garden activatedRestricted to payment portal
Mar 87SMS + email: “Your internet has been restricted”Portal-only access
Mar 1514Subscription suspendedNo internet access
Mar 1514SMS + email: “Your service has been suspended”No access
The dunning pipeline only processes subscriptions with autoRenew set to true. If a subscriber has auto-renew disabled, their subscription simply expires without dunning retries.

Notification Templates

FyberPay sends automated notifications at each dunning stage via SMS and email.

Walled Garden Notification

Sent when the subscriber is moved to the walled garden:
  • SMS: “Hi , your subscription is overdue. Your internet has been restricted. Pay to restore full access.”
  • Email: Includes payment link and M-Pesa instructions

Suspension Notification

Sent when the subscriber is fully suspended:
  • SMS: “Hi , your subscription has been suspended due to non-payment. Pay to reactivate your service.”
  • Email: Includes payment link and support contact
You can enable or disable SMS and email notifications independently at Settings > Notifications. For example, you might disable email notifications if most of your subscribers do not have email addresses.

Auto-Reactivation on Payment

When FyberPay receives a payment for a subscriber in any dunning state, the following happens automatically:
1

Payment matched

The M-Pesa payment is matched to the subscriber’s outstanding invoice (via STK Push callback, C2B reference, or Bill Manager).
2

Invoice marked paid

The invoice status transitions to paid with the M-Pesa receipt number recorded.
3

Subscription extended

The subscription’s expiry date is extended by the plan’s billing cycle days from the current date.
4

Dunning state reset

The dunning state is reset from whatever it was (retrying, walled_garden, or suspended) back to none.
5

RADIUS restored

The subscriber’s RADIUS group is changed from walled-garden back to their plan’s group. Bandwidth limits are restored.
6

Confirmation sent

The subscriber receives a payment confirmation via SMS and email, confirming their service has been restored.
The entire reactivation process happens within seconds of the payment being confirmed. Subscribers who pay via STK Push typically see their internet restored before the M-Pesa confirmation SMS arrives.

How the Pipeline Runs

The dunning processor runs as a scheduled background job (BullMQ). It periodically scans for overdue subscriptions and processes each one based on its current dunning state and the number of days since expiry.

Processing Logic

For each overdue subscription, the processor:
  1. Reads the current dunningState and calculates daysSinceExpiry
  2. If in none or retrying state and daysSinceExpiry >= walledGardenAfterDays, escalates to walled garden
  3. If in none or retrying state and below the threshold, sends an STK Push retry
  4. If in walled_garden state and daysSinceExpiry >= suspendAfterDays, escalates to suspended
  5. If in walled_garden state and below the threshold, sends an STK Push retry
  6. If in suspended state, takes no further action

Idempotency

The dunning processor is idempotent. Running it multiple times for the same subscription at the same time produces the same result. State transitions are validated by the state machine, and duplicate STK Push requests are handled by FyberPay’s idempotency layer.

Monitoring Dunning

Track dunning activity from the admin dashboard:
  • Dashboard > Overview: Shows count of subscribers in each dunning state
  • Subscribers list: Filter by dunning state (retrying, walled_garden, suspended)
  • Billing > Invoices: Filter overdue invoices to see which subscriptions are in the pipeline

Manual Overrides

Admins can override the dunning pipeline at any time:
ActionHowEffect
Skip dunningManually extend a subscriptionSets new expiry date, resets dunning to none
Force suspendSuspend from the subscriber pageImmediately suspends regardless of dunning state
Force reactivateReactivate from the subscriber pageResets dunning, restores RADIUS, requires payment or admin override
Void invoiceVoid the overdue invoiceRemoves the payment obligation; subscriber stays in current state until manually adjusted

Next Steps

M-Pesa Integration

Configure the payment channels that power dunning retries.

Billing Setup

Set up invoicing, tax, and payment terms.