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. Building a Multi-Vendor Store with Paystack
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 22, 2026

Building a Multi-Vendor Store with Paystack

When a customer checks out with items from multiple vendors, create a Transaction Split group (POST /split) listing each vendor's subaccount and their flat share (item subtotal minus commission). Pass the resulting split_code when initializing the transaction. On charge.success, fulfill each vendor's order items. Paystack settles each vendor directly into their bank account.

Mixed-Cart Split Checkout

// Cart: items from multiple vendors
// [{ vendor_id, items, subtotal }]

app.post('/api/checkout', async (req, res) => {
  var { cart, email } = req.body;
  var commissionRate = 0.10;
  var total = cart.reduce((s, v) => s + v.subtotal, 0);

  // Build subaccounts list for the split
  var splitSubaccounts = await Promise.all(
    cart.map(async (vendorCart) => {
      var vendor = await db.vendors.findById(vendorCart.vendor_id);
      var vendorShare = Math.round(vendorCart.subtotal * (1 - commissionRate) * 100); // kobo
      return { subaccount: vendor.subaccount_code, share: vendorShare };
    })
  );

  // Create Transaction Split
  var splitRes = 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: 'Cart ' + Date.now(),
      type: 'flat',
      currency: 'NGN',
      subaccounts: splitSubaccounts,
      bearer_type: 'account',
    }),
  });
  var splitData = await splitRes.json();

  // Initialize transaction with split
  var txRes = 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: total * 100,
      split_code: splitData.data.split_code,
      metadata: { cart: cart.map(v => ({ vendor_id: v.vendor_id, subtotal: v.subtotal })) },
    }),
  });
  var txData = await txRes.json();
  res.json({ authorization_url: txData.data.authorization_url });
});

Learn More

This guide is part of the Paystack split payments guide.

Sign up for the McTaba newsletter

Key Takeaways

  • ✓For mixed-vendor carts, create a Transaction Split group per order listing each vendor's flat share.
  • ✓Your platform commission stays as the residual — the sum of all vendor shares must be less than the total charge.
  • ✓Create vendor subaccounts during seller onboarding. Store subaccount_code against each vendor record.
  • ✓On charge.success, split the order fulfillment tasks by vendor and notify each seller of their items.
  • ✓Delete or reuse split groups — creating a new split per order is fine for variable carts.
  • ✓Use GET /split to list and reuse existing split groups for fixed vendor combinations.

Frequently Asked Questions

Is there a limit on how many subaccounts can be in one Transaction Split?
Paystack supports up to 5 subaccounts in a single Transaction Split group. For carts with more than 5 vendors, split the checkout into separate transactions per vendor or batch vendor payments via transfers after a single platform collection.
Can the sum of subaccount shares exceed the total transaction amount?
No. The sum of all flat share amounts in the split must be less than or equal to the transaction total. Any amount not allocated to a subaccount goes to your main account as commission. If shares exceed the total, Paystack will reject the split.
How do I handle a refund on a multi-vendor cart when only one vendor's items are returned?
Issue a partial refund for the returned item value from your platform balance. Paystack partial refunds do not automatically claw back the vendor's subaccount share. You either absorb the refund or charge the vendor separately for the returned item.
Should I delete split groups after use?
You can, but it is not necessary. Unused split groups do not incur charges. For carts that are always different, create new splits per order. For fixed vendor combinations (e.g., a franchise with 3 fixed outlets), create one split group and reuse the split_code on every transaction.

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

Creating Transfer Recipients on Paystack

Every Paystack transfer starts with a recipient. This guide covers creating recipients for bank accounts and mobile money wallets across Nigeria, Ghana, Kenya, and South Africa. Includes account resolution, validation, storage patterns, and handling recipient updates.

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.