Build a tutoring marketplace with split payments by onboarding tutors with Paystack subaccounts (each tutor gets a subaccount tied to their bank account), then initializing each session payment with the tutor's subaccount code. Paystack routes 80% to the tutor at settlement and 20% stays in your platform account. The student pays one amount; Paystack handles the split.
Tables: tutors (name, email, subject, hourly_rate, paystack_subaccount_code, status), sessions (tutor_id, student_id, subject, duration_mins, total_amount, scheduled_at, status, paystack_ref), students (name, email).
async function onboardTutor(tutorData) {
// Create Paystack subaccount with tutor's bank details
var res = await fetch('https://api.paystack.co/subaccount', {
method: 'POST',
headers: { Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
business_name: tutorData.name + ' - Tutoring',
bank_code: tutorData.bank_code,
account_number: tutorData.account_number,
percentage_charge: 80, // Tutor gets 80%, platform keeps 20%
}),
});
var data = await res.json();
await db.tutors.update(tutorData.id, {
paystack_subaccount_code: data.data.subaccount_code,
status: 'active',
});
return data.data.subaccount_code;
}
The subaccount is created once per tutor. After that, every session payment automatically routes the tutor's share to their bank account at settlement — no manual payout work needed.
async function bookSession(studentId, studentEmail, tutorId, scheduledAt, durationMins) {
var tutor = await db.tutors.findById(tutorId);
var totalAmount = Math.ceil((tutor.hourly_rate / 60) * durationMins);
var reference = 'SES-' + Date.now();
var session = await db.sessions.create({
tutor_id: tutorId, student_id: studentId,
duration_mins: durationMins, total_amount: totalAmount,
scheduled_at: scheduledAt, status: 'pending',
paystack_ref: reference,
});
var res = 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: studentEmail,
amount: totalAmount,
currency: 'NGN',
reference,
subaccount: tutor.paystack_subaccount_code,
bearer: 'account', // platform bears Paystack fees
metadata: { session_id: session.id, tutor_id: tutorId, duration_mins: durationMins },
}),
});
return (await res.json()).data.authorization_url;
}
// Webhook: confirm booking
if (event.event === 'charge.success') {
var sessionId = event.data.metadata.session_id;
await db.sessions.update(sessionId, { status: 'confirmed' });
await notifyTutor(event.data.metadata.tutor_id, sessionId);
await notifyStudent(studentId, sessionId);
}
At settlement time, Paystack sends 80% to the tutor's bank account and 20% stays in your platform Paystack account. You do not need to manually calculate or transfer the split — it is automatic.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
See build a home services booking marketplace for the same subaccount split pattern applied to service providers.
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