Pull Transactions
Pull Transactions is a reconciliation tool. When your confirmation endpoint was down, this retrieves the C2B payments you missed.
Register once
Section titled “Register once”POST pulltransactions/v1/register
Daraja::pull()->register( nominatedNumber: '0722000000', callbackUrl: 'https://your-domain/daraja/pull',);Both default to configuration. The nominated number is the MSISDN on your short code’s KYC record in the M-Pesa portal — not an arbitrary number.
| Code | Meaning |
|---|---|
1000 |
Registered successfully |
1001 |
Already registered |
Registration is one-time per short code, and the short code must be live in production.
POST pulltransactions/v1/query
$transactions = Daraja::pull()->query( from: now()->subDay(), to: now(),);
foreach ($transactions as $transaction) { $transaction->transactionId; // yzlyrEsRG1 $transaction->date; // 2020-08-05T10:13:00Z $transaction->msisdn; $transaction->amount; // "168.00" $transaction->billReference; $transaction->transactionType; // c2b-pay-bill-debit $transaction->organisationName;}Dates accept a DateTimeInterface or a Y-m-d H:i:s string. The return value is
a Laravel collection of PulledTransaction objects.
Paging
Section titled “Paging”offset is a row offset, not a page number:
$page2 = Daraja::pull()->query(now()->subDay(), now(), offset: 100);Reconciling
Section titled “Reconciling”$missed = Daraja::pull()->query(now()->subHours(6), now()) ->reject(fn ($t) => Payment::where('receipt', $t->transactionId)->exists());
foreach ($missed as $transaction) { RecordMissedPayment::dispatch($transaction);}Limitations
Section titled “Limitations”- Only C2B transactions. B2C, B2B and reversals are not covered.
- Registration must happen before any query.
- Code
1001on a query means no transactions in the period, not an error.