mpesapoller

package
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package mpesapoller holds the core-side M-Pesa tickers.

Both walk mpesa_transactions on a wall-clock cadence rather than off a next_poll_at column, because neither is driven by a per-row schedule: the Pull sweep reconciles a time window, and the balance poll asks about a shortcode. Cadence in a column serves a queue of rows; these have none.

Confirming an STK observation is deliberately not here. That row is confirmed by the loan poller in the credit module, which knows which loan the checkout belongs to and can therefore attribute the receipt; a core-side confirmer sees only the checkout ID and would settle the row with no loan at all.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalancePoller

type BalancePoller struct {
	// contains filtered or unexported fields
}

BalancePoller asks Daraja for the collection and disbursement shortcodes' balances on a cadence. The figures land later, on the async callback route (DarajaCallbackController.async), which resolves the shortcode through the correlation this poller writes at request time — Account Balance is async, so nothing here ever sees the figure it asked for.

func NewBalancePoller

func NewBalancePoller(deps BalancePollerDeps) *BalancePoller

NewBalancePoller builds the poller.

func (*BalancePoller) Start

func (p *BalancePoller) Start(ctx context.Context)

Start runs the poller until ctx is cancelled.

type BalancePollerDeps

type BalancePollerDeps struct {
	Client                balanceQuerier
	Queries               repository.MpesaBalanceRepository
	CollectionShortcode   uint
	DisbursementShortcode uint
	ResultURL             string
	QueueTimeOutURL       string
	Interval              time.Duration
	Logger                *slog.Logger
}

BalancePollerDeps are the collaborators BalancePoller needs; all required except Logger and DisbursementShortcode (zero skips that query).

ResultURL/QueueTimeOutURL are required — AccountBalanceRequest.URLs rejects an empty AsyncURLs (pkg/payment/mpesa/async.go's validate), so an unset pair here fails every tick, not just the first. Routes already exist server-side at DarajaCallbackController.Register's "/balance/result" and "/balance/timeout" — build these with cfg.Payments.Mpesa.DarajaCallbackURL("balance/result") / ("balance/timeout").

type PullSweeper

type PullSweeper struct {
	// contains filtered or unexported fields
}

PullSweeper reconciles Daraja's Pull API against mpesa_transactions on a wall-clock cadence. See doc.go for why this is a ticker rather than an mgpoller.Runner[T].

func NewPullSweeper

func NewPullSweeper(deps PullSweeperDeps) *PullSweeper

NewPullSweeper builds the sweeper.

func (*PullSweeper) Start

func (s *PullSweeper) Start(ctx context.Context)

Start runs the sweep until ctx is cancelled.

type PullSweeperDeps

type PullSweeperDeps struct {
	Client    pullQuerier
	Repo      repository.MpesaTransactionRepository
	Cursor    repository.MpesaPullCursorRepository
	Shortcode uint
	Interval  time.Duration
	Logger    *slog.Logger
}

PullSweeperDeps are the collaborators PullSweeper needs; all required except Logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL