McTaba Labs logo
Software EngineeringThe WhiteboardProjectsEventsMasterclassesWebinarsLearn
Book Call

500+ developers already in the community

Get answers, find accountability partners, and stay ahead

Join Discord →
McTaba Labs logo

Educating 1 million students in tech by 2030.

Programs

  • HighSchool Graduates Launchpad
  • AI & Business Automation
  • Corporate Training
  • McTaba Story & Mission
  • Full-Stack Curriculum
  • Course Pricing & Plans
  • Frequently Asked Questions

Resources

  • Join Discord Community
  • Tech Events in Nairobi
  • Masterclasses
  • Free Resources
  • Learn
  • Campus
  • Africa Tech Talent Report
  • Partner With Us
  • Start a Project
  • Our Work

Contact Us

  • 124 Manyani East Road, Lavington, Nairobi
  • +254727795603
  • Book a Discovery Call

Office Hours:

Mon-Fri: 9am - 2pm EAT

Sat: 10am - 12pm EAT

© 2027 McTaba Labs - A product of Edtech Industries. All rights reserved.

Privacy PolicyTerms of ServiceRefund Policy
  1. Learn
  2. Paystack for African Developers
  3. Forecasting Cash Flow from Paystack Data
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 22, 2026

Forecasting Cash Flow from Paystack Data

Cash flow forecasting from Paystack: 1) Export monthly revenue totals from GET /transaction (group by month, sum amounts). 2) Get MRR from active subscriptions: GET /subscription?status=active, sum amounts. 3) Get settlement schedule: GET /settlement for historical payout timing (T+1 or T+2). 4) Feed aggregated data to LLM — not raw transactions. 5) Prompt for projection with stated assumptions. Key: the LLM should return a range (low/mid/high), not a single number, and must state what assumptions drive the projection. Never use an AI cash flow projection for financial commitments without human review.

Preparing Paystack Data for Forecasting

// Prepare aggregated data for LLM — never raw transactions
async function buildForecastInput() {
  var headers = { Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY };

  // 1. Monthly revenue for past 6 months
  var monthlyRevenue = [];
  for (var i = 5; i >= 0; i--) {
    var d = new Date();
    d.setMonth(d.getMonth() - i);
    var from = new Date(d.getFullYear(), d.getMonth(), 1).toISOString().slice(0, 10);
    var to = new Date(d.getFullYear(), d.getMonth() + 1, 0).toISOString().slice(0, 10);
    var res = await fetch('https://api.paystack.co/transaction?status=success&from=' + from + '&to=' + to + '&perPage=100', { headers });
    var txns = (await res.json()).data || [];
    monthlyRevenue.push({
      month: from.slice(0, 7),
      total_ngn: txns.reduce((s, t) => s + t.amount, 0) / 100,
      count: txns.length,
    });
  }

  // 2. Current MRR from active subscriptions
  var subsRes = await fetch('https://api.paystack.co/subscription?status=active&perPage=100', { headers });
  var subs = (await subsRes.json()).data || [];
  var mrr = subs.reduce((s, sub) => s + sub.amount, 0) / 100;

  // 3. Settlement lag (from recent settlements)
  var settleRes = await fetch('https://api.paystack.co/settlement?perPage=10', { headers });
  var settlements = (await settleRes.json()).data || [];
  var avgLagDays = settlements.length
    ? settlements.reduce((s, st) => {
        var txDate = new Date(st.effective_date);
        var settleDate = new Date(st.settlement_date);
        return s + (settleDate - txDate) / 86400000;
      }, 0) / settlements.length
    : 1; // default T+1

  return { monthlyRevenue, mrr_ngn: mrr, active_subscriptions: subs.length, avg_settlement_lag_days: avgLagDays };
}

// Feed to LLM for forecast
async function generateCashFlowForecast() {
  var data = await buildForecastInput();

  var prompt = `Here is our Paystack revenue data for the past 6 months:
Monthly revenue: ${JSON.stringify(data.monthlyRevenue)}
Current MRR from active subscriptions: NGN ${data.mrr_ngn}
Active subscriptions: ${data.active_subscriptions}
Average settlement lag: ${data.avg_settlement_lag_days.toFixed(1)} days

Based on this data, forecast next month's revenue (low/mid/high range).
State the assumptions driving each scenario.
Highlight any trends you see in the monthly data.
Note: Paystack settles net of fees (~1.5% + NGN 100 per transaction).`;

  var response = await anthropic.messages.create({
    model: 'claude-opus-4-6',
    max_tokens: 1024,
    messages: [{ role: 'user', content: prompt }],
  });

  return response.content[0].text;
}

Learn More

See building a natural language revenue dashboard for the interactive query pattern over the same data.

Sign up for the McTaba newsletter

Key Takeaways

  • ✓Feed the LLM aggregated monthly totals, not raw transaction arrays — lower token cost, better analysis.
  • ✓MRR from active subscriptions is the most reliable forward-looking signal in Paystack data.
  • ✓Settlement timing (T+1/T+2) matters for cash flow — Paystack settles net of fees, not gross revenue.
  • ✓Ask for a range (low/mid/high) with stated assumptions — a single number is false precision.
  • ✓AI projections are starting points for planning, not commitments — all forecasts need human review.

Frequently Asked Questions

How accurate is AI cash flow forecasting from payment data?
It depends heavily on your business pattern. Subscription businesses with stable MRR get useful projections — the LLM can spot renewal timing and churn patterns. One-time payment businesses with volatile revenue get less reliable forecasts. Think of AI forecasting as surfacing trends and making the data easier to interpret, not as replacing a finance professional's judgment. Use it for planning conversations, not financial commitments.
Does Paystack's settlement data include all revenue or only settled amounts?
Settlement data shows what Paystack paid out to your bank — net of fees and after settlement lag. Transaction data shows gross revenue as it is charged. For cash flow forecasting, use transaction data for revenue projection and settlement data for bank account cash timing. These two numbers will differ by fees (roughly 1.5% + NGN 100 per transaction) and timing (T+1 or T+2 settlement).
How do I factor in currency for multi-currency businesses?
Forecast by currency separately. NGN, KES, and GHS have different settlement dynamics and exchange rate exposure. Give the LLM each currency's monthly data independently and ask for per-currency projections. If you need a combined projection in one currency, apply exchange rates yourself and note the assumption — do not let the LLM choose exchange rates.

Learn Paystack Integration

KES 2,999

The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.

Start Paystack Course

Not ready? Create Free Account

Keep reading

Paystack AI Agents and the MCP Server: The Complete Guide

A comprehensive guide to building AI agents that interact with Paystack through the Model Context Protocol (MCP) server. Covers connecting the MCP server to Claude Code, querying transactions with natural language, building payment support chatbots, AI-assisted reconciliation, agentic payouts with safety rails, secret key security, human-in-the-loop design, prompt injection risks, and audit trails for AI-initiated financial actions.

Read more

RAG Over Your Payment Documentation and Transaction History

RAG lets an LLM answer questions grounded in your actual Paystack docs and transaction history instead of its training data. "What does this error code mean?" retrieves from your embedded docs. "What happened to transaction X?" retrieves from your transaction store.

Read more

Agentic Payouts: Safety Rails You Must Build First

An AI agent that can trigger Paystack transfers needs guardrails that a human operator does not. Build these safety rails before you give any agent access to POST /transfer — or you will build them after the first incident.

Read more

Building a WhatsApp AI Sales Agent That Takes Payment

A customer messages your WhatsApp number: "I want the premium plan." The AI agent replies with the price, confirms, and sends a Paystack payment link — all without a human operator. Here is how to build it.

Read more

Accept Payments with Paystack in Next.js Pages Router

Wire Paystack payments into a Next.js Pages Router project. This guide covers API routes for initializing transactions, getServerSideProps for server-side verification, redirect callbacks, and inline popup checkout with full working code.

Read more

Explore related topics

M-Pesa & African Stack

M-Pesa Daraja API tutorials, USSD development, and WhatsApp Business API guides. The African Stack that global bootcamps do not teach.

Learn to Code in Kenya

Everything a Kenyan needs to know before writing their first line of code. Career paths, real costs, hardware requirements, and honest answers about what it takes.

Learning to Code

Roadmaps, language guides, and practical advice for learning to code and launching a programming career.

Breaking Into Tech

Practical, no-nonsense guides for anyone looking to start or change their career in tech. From choosing your first language to acing interviews.

The African Stack: Skills for This Market

The skills that make Kenyan developers hard to replace: M-Pesa, USSD, WhatsApp, fintech, and building for the African market.

Bonaventure Ogeto

Bonaventure Ogeto

Founder, McTaba Labs

Bonaventure is the founder of McTaba Labs, a coding bootcamp in Nairobi, Kenya. He has spent years building products for the African market and mentoring the next generation of developers across the continent.