01 — Overview
Overview
Flayona is a Ghana-focused e-commerce marketplace for genuine imported (“abrokyire”) goods, sold at fair local prices, delivered by region and paid for via card or Mobile Money. It is a real, live platform — and because it handles money and extends credit, correctness and security sit at its core.
I built the whole system in deliberately lean technology: vanilla PHP and MySQL, server-rendered, installable as a PWA and fast on low-end Android devices. On top of that foundation sit a Buy-Now-Pay-Later engine, KYC onboarding, and four distinct authenticated portals — customer, admin, credit officer and distributor.
02 — Problem
The problem
Shoppers in Ghana want access to genuine imported goods at fair local prices, with payment options that match how people actually pay — Mobile Money as much as cards — and the flexibility to spread the cost.
Delivering that safely is hard. You need reliable payments across two very different rails, a way to extend credit without getting burned, identity verification before credit is granted, and separate, secure workspaces for the different people who run the business — all while staying fast on cheap Android phones on patchy connections.
03 — Requirements
Requirements
- Accept both card payments (Paystack) and Mobile Money.
- Offer a Buy-Now-Pay-Later option with credit scoring and instalments.
- Verify customer identity (KYC) before credit is extended.
- Provide separate secure portals for customers, admins, credit officers and distributors.
- Protect every portal with strong authentication and 2FA.
- Run fast and installable (PWA) on low-end Android, even offline for browsing.
04 — Research
Research & planning
- Studied Paystack's payment and webhook lifecycle to reconcile orders reliably.
- Mapped the Mobile Money flow used locally — where the order/PO number becomes the payment reference and is confirmed over WhatsApp.
- Reviewed the OWASP Top 10 and applied it to authentication, CSRF, input handling and access control across all four portals.
05 — Solution
The solution
The storefront is server-rendered PHP with a shared library of includes for auth, cart, payments, KYC and audit. It ships as a PWA with a service worker for installability and offline read-only browsing.
Pricing is distributor-driven: a master catalogue holds a reference price and the admin's private cost, but the price a customer actually pays is set by the distributor serving their region. Orders carry a kind (standard, pre-order or BNPL) and a fulfilment type (delivery, pickup or rider).
Standard orders take no card online — the customer places the order, receives an invoice with a payment reference (PO number), pays by Mobile Money and confirms on WhatsApp. Pre-order deposits are collected online via Paystack, whose webhook is signature-verified and reconciles the order.
The BNPL engine runs a credit score, generates a digital contract and an instalment schedule, and a scheduled cron job automatically charges instalments as they fall due — all gated behind KYC verification and available to Flayona Plus members.
Each of the four portals has its own authentication guard, TOTP two-factor authentication and password-reset flow, with CSRF protection and an append-only audit log across the platform.
06 — Architecture
System architecture
Flayona is a server-rendered PHP application over MySQL (mysqli). Cross-cutting concerns live in a shared `includes/` layer — authentication guards per role, CSRF, Paystack, BNPL, credit scoring, KYC upload, audit logging, mailer/SMS/WhatsApp and region logic — so each page composes the same vetted building blocks.
Four separate portals sit behind their own auth guards: the customer storefront, the admin back office, the credit-officer portal that reviews BNPL applications, and the distributor portal with its own POS, stock and orders.
Payment is asynchronous by design: standard orders resolve out-of-band via Mobile Money and WhatsApp confirmation, pre-order deposits go through a signature-verified Paystack webhook, and a cron job drives automated BNPL instalment charging independently of any user session.
07 — Data
Database design
The live schema (30+ tables) is organised around commerce and credit. Customers place orders of order items, settled through order payments; a master products table carries a reference price and admin cost, while distributor_products sets the region-specific price and distributor_variant_stock the stock. BNPL orders link to KYC applications, credit scores and instalments.
Roles are separated at the data layer — admins, credit officers and distributors are distinct account types with their own credentials and TOTP secrets — and cross-cutting tables cover regions, promotions, reviews, loyalty points, Flayona Plus subscriptions and an append-only audit log.
08 — Features
Key features
Four role portals
Separate authenticated workspaces for customers, admins, credit officers and distributors — each with its own login, 2FA and reset flow.
Region-based distributor pricing
A master catalogue with reference price and admin cost, where the price a customer pays is set by their region's serving distributor.
Mobile Money checkout
No card taken online for standard orders — an invoice with a PO reference, paid by Mobile Money and confirmed over WhatsApp.
Paystack pre-order deposits
Online deposits for pre-orders via Paystack, with a signature-verified webhook that reconciles the order.
Buy-Now-Pay-Later engine
Credit scoring, a digital BNPL contract and an instalment schedule, all gated behind KYC.
Flayona Plus membership
A paid subscription unlocking BNPL, priority pre-orders and member-only deals.
Automated instalment charging
A cron job charges BNPL instalments as they fall due, independent of any user session.
KYC onboarding
Document upload and verification that gates access to credit.
Distributor POS & stock
Distributors run point-of-sale, manage stock and fulfil orders from their own portal.
Regional delivery
Region-aware delivery pricing and messaging tailored to how goods move from the Accra hub.
Loyalty, reviews & promotions
Customer loyalty, product reviews, professional discounts, preorders and promotional campaigns.
Audit logging & 2FA
TOTP two-factor auth across portals, CSRF protection and an append-only audit trail.
09 — Engineering
Implementation decisions
Lean, deliberate stack
Vanilla PHP + MySQL with no framework or build step — chosen so the app stays fast and installable on low-end Android WebViews.
Shared includes layer
Auth, CSRF, payments, BNPL, KYC and audit all live in one vetted `includes/` layer that every page composes.
Per-role authentication
Each portal has its own auth guard and TOTP secret, so a customer session can never reach admin or distributor tooling.
Webhook reconciliation
The Paystack webhook is the single point that verifies signatures and reconciles order state against the provider.
Scheduled BNPL charging
Instalments are driven by a cron job, keeping repayment independent of whether the customer is online.
10 — Challenges
Challenges & how I solved them
Two very different payment rails
Cards and Mobile Money behave nothing alike. I modelled order state so both settle into the same consistent record — webhooks for Paystack, reference-matching plus WhatsApp confirmation for MoMo.
Extending credit safely
BNPL meant building credit scoring, digital contracts and automated charging, and strictly gating all of it behind KYC — encoded as explicit states so the rule can't be bypassed.
Four portals, one codebase
Keeping customer, admin, credit-officer and distributor auth cleanly separated took a disciplined shared-includes design and per-role guards.
Fast on cheap phones
Targeting low-end Android WebViews ruled out heavy frameworks and pushed me toward server rendering, a PWA shell and lightweight progressive enhancement.
11 — Security
Security & correctness
- TOTP two-factor authentication on every portal (customer, admin, credit officer, distributor).
- CSRF protection on state-changing requests across the platform.
- KYC verification gates access to credit; identity documents are uploaded and reviewed before approval.
- Paystack webhooks are signature-verified before any order state changes.
- Passwords are hashed; each portal has its own secure password-reset and login-alert flow.
- An append-only audit log records sensitive actions for accountability.
12 — Interface
Screenshots




13 — Outcome
Results
- A live e-commerce and FinTech platform (flayona.com) handling real orders, card and Mobile Money payments.
- A working BNPL engine with credit scoring, contracts and automated instalment charging.
- Four secure, role-separated portals running from a single, maintainable PHP codebase.
- The strongest evidence in my portfolio that I can build correctness- and security-critical software end to end.
14 — Reflection
Lessons learned
Payment correctness comes from modelling state well — both rails must settle into the same consistent record.
Constraints are clarifying: targeting low-end devices led to a leaner, faster architecture.
Separating roles at both the auth and data layers prevents whole categories of access bugs.
15 — What's next
Future improvements
- Automated dunning and retries for missed BNPL instalments.
- A richer analytics dashboard for revenue, credit performance and defaults.
- Expanded automated test coverage around the payment and BNPL flows.
16 — Toolchain