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. Build a Parking Payment App
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 22, 2026

Build a Parking Payment App

Build a parking payment app by creating sessions on entry (with time-in recorded), calculating fees based on duration at exit, and collecting payment via Paystack before releasing the vehicle. Use a QR code or number plate lookup at entry to create the session. At exit, calculate the fee, initialize a Paystack transaction, and update the session to paid when the webhook fires.

In this article

  1. 1. Architecture and Session Flow
  2. 2. Fee Calculation and Paystack Integration
  3. 3. Learn More

Architecture and Session Flow

A parking payment app manages sessions between vehicle entry and exit. The core data is simple: when did the vehicle enter, when did it exit, how much does it owe, and has it paid?

The flow:

  1. Driver scans QR code (or attendant enters plate number) at entry
  2. System creates a parking session with entry timestamp and vehicle identifier
  3. At exit, driver requests payment — system calculates fee based on duration
  4. Driver pays via Paystack on their phone or a kiosk
  5. Webhook confirms payment — system updates session to paid and signals barrier open
  6. Vehicle exits within a grace period (say 5 minutes after payment)

Database tables: parking_lots (location, rate per hour, max daily rate), sessions (plate, lot_id, entry_at, exit_at, fee_amount, status, paystack_reference), rates (lot_id, period, rate — for peak/off-peak pricing).

Fee Calculation and Paystack Integration

function calculateParkingFee(entryAt, exitAt, ratePerHour, maxDailyRate) {
  var minutes = Math.ceil((exitAt - entryAt) / 60000); // ms to minutes
  var hours = Math.ceil(minutes / 60); // round up to nearest hour
  var fee = hours * ratePerHour;
  return Math.min(fee, maxDailyRate); // cap at daily max
}

async function initiateExitPayment(sessionId, driverEmail) {
  var session = await db.sessions.findById(sessionId);
  var lot = await db.parkingLots.findById(session.lot_id);
  var now = Date.now();
  var fee = calculateParkingFee(session.entry_at, now, lot.rate_per_hour, lot.max_daily_rate);

  var reference = 'PARK-' + sessionId + '-' + Date.now();
  await db.sessions.update(sessionId, { fee_amount: fee, paystack_reference: reference });

  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: driverEmail,
      amount: fee, // in kobo/cents
      currency: 'KES',
      reference: reference,
      metadata: { session_id: sessionId, plate: session.plate, lot_name: lot.name },
    }),
  });

  var data = await response.json();
  return data.data.authorization_url; // send to driver's phone
}

The webhook handler verifies the signature, finds the session by reference, marks it paid, and signals the barrier controller (via GPIO, serial port, or REST API depending on your hardware).

if (event.event === 'charge.success') {
  var sessionId = event.data.metadata.session_id;
  await db.sessions.update(sessionId, { status: 'paid', exit_at: new Date(), paystack_txn: event.data.id });
  await barrierController.open(sessionId); // trigger exit barrier
}

Get weekly developer tips

Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.

No spam. Unsubscribe anytime.

Learn More

See build a vehicle inspection booking and payment app for another government/transport sector Paystack integration.

Sign up for the McTaba newsletter

Key Takeaways

  • ✓Record entry time on arrival; calculate fee at exit based on elapsed time and your rate table.
  • ✓Collect payment before opening the exit barrier — do not release the vehicle on a pending payment.
  • ✓Use Paystack webhook to confirm payment, not the redirect, before triggering barrier release.
  • ✓Support M-Pesa in Kenya and card/bank transfer in Nigeria — the same Paystack initialization handles both.
  • ✓Overstay is a common edge case: define a grace period and an overstay rate per hour.

Frequently Asked Questions

What if a driver does not have a smartphone to pay at the exit?
Install a payment kiosk at the exit with a touchscreen that runs a simple web app connected to your backend. The driver enters their plate number; the kiosk shows the fee and a Paystack payment link they can scan with their phone, or they pay by card on a POS terminal connected to Paystack Terminal. For low-tech lots, an attendant with a tablet works too.
How do I handle the grace period between payment and exit?
When payment is confirmed, record the payment_confirmed_at timestamp. The barrier opens and stays openable for a grace period (5-10 minutes). If the vehicle does not exit in that window, the session resets to unpaid and the driver must pay again. This prevents someone paying for another person's car to get out free.
Can I offer monthly parking subscriptions?
Yes. Use Paystack Plans to create a monthly subscription. On entry, check if the plate number is linked to an active subscription — if so, create the session and mark it as subscription-covered without requiring payment at exit. A cron job checks for lapsed subscriptions daily and flags them inactive.

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

Things You Can Build with Paystack: Project Guides

A complete map of real-world projects you can build using the Paystack API. From online store checkouts and subscription platforms to savings apps and solar pay-as-you-go systems, each category links to step-by-step build guides with working code.

Read more

Build a Laundry Pickup and Payment App

A build guide for a laundry pickup and delivery app that uses Paystack to collect payments. Covers order pricing by weight or item count, pickup scheduling, status tracking through the wash cycle, payment collection at order creation or delivery, and customer notifications.

Read more

Build an Affiliate Commission Engine

A build guide for an affiliate commission engine where affiliates share tracking links, earn commissions when their referrals convert (pay via Paystack), and withdraw their balance via bank transfer. Covers click tracking, last-click attribution, commission ledger, and Paystack Transfers payout.

Read more

Build a Farmers Market Ordering Platform

A build guide for a farmers market ordering platform where customers order fresh produce from multiple farmers in one cart, the platform collects the combined payment via Paystack, and each farmer receives their share via Paystack Split Payments or Transfers. Covers inventory management, order routing to individual farmers, and delivery coordination.

Read more

Why Kenyan Checkout Conversion Depends on Mobile Money Placement

In Kenya, M-Pesa is how people pay. If your checkout page shows card fields first and buries M-Pesa below the fold, you are losing customers at the point of purchase. This article covers how to prioritize mobile money in your checkout, how the Paystack channels array controls payment method ordering, mobile-first design patterns for Kenyan users, and what to do when the M-Pesa STK push fails.

Read more

Onboarding Sellers to a Paystack Marketplace

A step-by-step guide to building a seller onboarding flow for a Paystack marketplace. Covers collecting bank details, validating with the Resolve Account endpoint, creating subaccounts, handling validation failures, designing the onboarding UI, and deciding when and how to add identity verification to the flow.

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.