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. Splitting Payments Between a School and Its Departments
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 22, 2026

Splitting Payments Between a School and Its Departments

Create a Paystack subaccount for each department that has its own bank account. Create a Transaction Split group per fee schedule listing each department subaccount and their flat amount. When a student pays, pass the split_code for that term's fee structure. Paystack settles each department directly. Store subaccount_codes in a departments table keyed by fee_type.

Fee Structure and Split Group

// Fee structure: NGN 50,000 total
// Tuition: 40,000 (main account)
// Library: 2,000 (library subaccount)
// Sports: 3,000 (sports subaccount)
// Lab: 5,000 (science lab subaccount)

async function createTermSplitGroup(term) {
  var feeStructure = await db.feeStructures.findByTerm(term);
  var subaccounts = [];

  for (var dept of feeStructure.departments) {
    var department = await db.departments.findById(dept.department_id);
    subaccounts.push({
      subaccount: department.subaccount_code,
      share: dept.amount * 100, // kobo
    });
  }

  var response = await fetch('https://api.paystack.co/split', {
    method: 'POST',
    headers: { Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({
      name: term + ' fee split',
      type: 'flat',
      currency: 'NGN',
      subaccounts,
      bearer_type: 'account',
    }),
  });
  var data = await response.json();

  // Store split code for this term
  await db.feeStructures.update(
    { split_code: data.data.split_code },
    { where: { term } }
  );

  return data.data.split_code;
}

// Student payment checkout
app.post('/api/fees/pay', async (req, res) => {
  var { studentId, term, email } = req.body;
  var feeStructure = await db.feeStructures.findByTerm(term);

  var response = await fetch('https://api.paystack.co/transaction/initialize', {
    method: 'POST',
    headers: { Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({
      email,
      amount: feeStructure.total_amount * 100,
      split_code: feeStructure.split_code,
      metadata: { student_id: studentId, term },
    }),
  });
  var data = await response.json();
  res.json({ authorization_url: data.data.authorization_url });
});

Learn More

This guide is part of the Paystack split payments guide.

Sign up for the McTaba newsletter

Key Takeaways

  • ✓Create a department subaccount per department with its own bank account (library fund, sports levy, PTA, etc.).
  • ✓Build a fee_structures table: for each term/year, store the breakdown of fees per department.
  • ✓Create a Transaction Split group per fee structure. Reuse the same split_code for all students in that term.
  • ✓The school's main tuition amount goes to your main Paystack account (the residual after subaccount shares).
  • ✓On charge.success, mark the student's fee as paid and generate a receipt with the full fee breakdown.
  • ✓Offer parents/students a consolidated payment portal — one payment, all departments settled automatically.

Frequently Asked Questions

Can I reuse the same split group for all students in a term?
Yes. If the fee amounts are the same for all students in a class or level, create one split group per fee structure and reuse its split_code. Only create new split groups when the fee breakdown changes (different term, different class level, special levies).
What if a department does not have its own bank account?
Only include departments with separate bank accounts in the split. For departments without their own accounts, add their fee to the school's main account amount (the residual). The school bursar can then transfer internally to those departments through normal budget allocation.
How do I generate a fee receipt showing the full breakdown?
Store the fee_structure breakdown in your database. On charge.success, look up the fee structure for the transaction term and generate a receipt itemizing each component. The Paystack transaction receipt only shows the total — you must build the line-item receipt yourself from your fee structure table.
Can parents pay partial fees and complete later?
Paystack does not natively support partial payments on a single invoice. Implement partial payments by letting parents pay one fee category at a time (a separate transaction per fee type), or track a balance owed in your database and allow multiple payments against the same student account until fully settled.

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 Split Payments and Marketplaces: Complete Guide

Everything you need to split payments on Paystack: creating subaccounts, choosing between percentage and flat splits, multi-split transactions, fee configuration, delayed settlement, escrow-style patterns, and building real marketplace products with working Node.js code.

Read more

Percentage vs Flat Split Configuration on Paystack

A detailed comparison of percentage and flat split configurations on Paystack. Covers how each model works, worked margin calculations across different transaction sizes, when to use percentage vs flat, implementing per-transaction overrides, and building hybrid models that combine both approaches.

Read more

Escrow-Style Flows on Paystack and Their Limits

A thorough analysis of what escrow-style flows you can and cannot build on Paystack. Covers the difference between true escrow and delayed settlement, how to use manual settlement for hold-and-release patterns, the limits around hold duration and fund recovery, regulatory considerations in African markets, and when Paystack is not the right tool for escrow.

Read more

Building a Freelance Marketplace on Paystack

A freelance marketplace holds client funds until the work is approved, then releases to the freelancer. This guide covers implementing that hold-and-release pattern using Paystack delayed settlement, collecting platform commission via splits, and handling disputes and refunds.

Read more

Single Transfers with the Paystack API

A complete walkthrough of initiating a single Paystack transfer: formatting amounts, generating references, handling OTP, tracking statuses through webhooks, building retry logic for transient failures, and the common mistakes that cause money to land in the wrong place.

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.