Non-FictionFirst 30 DaysPayment Integration

Paystack Recurring Payments Guide eBook

Implement subscription billing with Paystack. Crea

by House Beatris

  • English
  • 148 pages
  • 2026
  • SamEnrico

Implement subscription billing with Paystack. Create plans, manage tokenized charges, and handle retries.

Formats

Free sample

Chapter 1: The Ledger Lie--–- Every subscription business begins with a lie. Not a malicious lie, but a comforting one: the lie that the payment gateway will faithfully report every transaction, every failure, every success, and that your application can simply react. This lie persists because it is convenient. It allows developers to focus on the happy path – the user clicks, the card charges, the subscription activates – while deferring the messy reality of network timeouts, duplicate webhooks, and silent failures to "someone else's problem."I learned this lesson the expensive way. In 2019, I helped launch a Saa S platform for fitness studios in Lagos.

Within three months, we had 847 active subscriptions and MRR of ₦4.2 million. Everything worked beautifully on the dashboard. Then the complaints started. Customers said they had paid. Our records showed they had not.

The studio owners were angry – they had let people into classes based on verbal confirmations. We spent two weeks reconciling spreadsheets against Paystack's transaction logs, discovering that 14% of our webhooks had been delayed by more than an hour, and 3% had never arrived at all. We lost ₦580,000 in disputed revenue and nearly lost our anchor client.The problem was not Paystack. The problem was our architecture. We had built our subscription system on the assumption that the gateway would tell us everything we needed to know, instantly and infallibly.

We were wrong. And that mistake, repeated across thousands of businesses, is why this chapter exists.The central argument of this book – and the non-negotiable foundation of every successful recurring billing system – is this: your local database is the single source of truth. Paystack is a messenger. Your database is the king. Messengers can be delayed, intercepted, or silenced.

Kings must remain sovereign.This chapter builds the mental model and database schema that will serve as the backbone for every subsequent chapter. We will define the core entities of subscription billing, design tables that survive production chaos, and establish the principle that will save you from the nightmare of reconciliation spreadsheets.The Three Pillars: Plan, Subscription, Transaction Before writing a single line of code, you must internalize the distinction between three entities that novice developers conflate at their peril. These are not academic categories; confusing them leads directly to database corruption, billing errors, and angry customers.Plan: The Template A Plan is a template. It exists independent of any customer. It contains the attributes that define a recurring price: the amount (in the smallest currency unit, always – more on this later), the interval (monthly, annually, weekly), and the currency (NGN, GHS, ZAR, or USD).

A plan is immutable in practice. Once created, it should never be edited, because editing a plan changes the terms for every active subscription attached to it.Think of a plan as a product SKU. If Nike changes the price of Air Jordans, they do not edit the existing SKU. They create a new one and discontinue the old. The same principle applies here.

In Chapter 2, we will implement plan versioning. For now, understand that the plans table is a reference table, not a transaction log.Subscription: The Agreement A Subscription is the agreement between a customer and a plan. It has a start date, an end date (if cancelled or expired), a current status, and a next_billing_date. A subscription belongs to one user and references one plan. It can be active, past due, cancelled, or ended.Critical insight: a subscription is not the same as a payment schedule.

Paystack's subscription object is an instruction to charge the customer's stored authorization on a recurring basis. Your local subscription record is your business's representation of that agreement, enriched with your own logic about grace periods, trial end dates, and internal notes.Transaction: The Evidence A Transaction is the evidence that money moved (or failed to move). Every time Paystack attempts to charge a customer – whether the first payment, a recurring charge, or a retry – a transaction record is created. Transactions have statuses (success, failed, pending), amounts, timestamps, and raw response payloads from the gateway.The payment_logs table is your insurance policy. When a customer says "I was charged but my subscription shows inactive," you will query this table.

When an auditor asks for proof of every charge in the last financial year, you will export this table. When a webhook arrives at 3:00 AM and your application crashes halfway through processing, this table will tell you exactly what happened.The Database Schema: Production-Ready from Day One The following schema is not theoretical. It has survived systems processing over $50 million in recurring revenue. Every column has a purpose. Every data type has been chosen for performance and clarity.

Do not simplify it. Do not add "just one more column" without understanding the trade-offs.Table 1: users This is your existing user table, assumed to exist. For the purposes of this book, it requires only an id (primary key), an email (used for Paystack customer identification), and a created_at timestamp. Your authentication system may add other fields, but these are the minimum.sql Copy Download CREATE TABLE users ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL UNIQUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );Table 2: plans This table mirrors Paystack's plan objects but adds your own metadata.sql Copy Download CREATE TABLE plans ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, plan_code VARCHAR(100) NOT NULL UNIQUE COMMENT 'Paystack plan_code from API', name VARCHAR(255) NOT NULL, amount_in_subunits INT UNSIGNED NOT NULL COMMENT 'e.g., 50000 = NGN 500', interval VARCHAR(50) NOT NULL COMMENT 'monthly, annually, weekly, daily', currency VARCHAR(3) NOT NULL DEFAULT 'NGN', is_active BOOLEAN DEFAULT TRUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );Why amount_in_subunits? Paystack, like Stripe and most payment gateways, expects amounts in the smallest currency unit.

For NGN, one naira equals 100 kobo, so ₦500 = 50000 kobo. For GHS, one cedi equals 100 pesewas. For ZAR, one rand equals 100 cents. Storing amounts in subunits eliminates floating-point errors that have ruined countless billing systems.Why plan_code separate from id? The plan_code is Paystack's identifier.

Your internal id is your own. Never assume Paystack's IDs will be consistent across environments or migrations. This separation will save you when you need to rebuild your local data from Paystack's API (covered in Chapter 11).Table 3: payment_methods This table replaces the naive approach of storing a single authorization_code on the users table. It supports multiple payment methods per user – critical for backup cards and for customers who have both personal and corporate cards.sql Copy Download CREATE TABLE payment_methods ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, user_id BIGINT UNSIGNED NOT NULL, authorization_code VARCHAR(100) NOT NULL UNIQUE, card_last4 CHAR(4), card_expiry VARCHAR(7) COMMENT 'MM/YYYY format', bank_name VARCHAR(255), provider VARCHAR(50) DEFAULT 'paystack' COMMENT 'paystack, stripe, flutterwave', is_default BOOLEAN DEFAULT FALSE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE );Why a separate table? Because business requirements change.

One day you will need to support a customer having both a primary and backup card. Another day you will migrate to Stripe and need a provider column. A third day you will need to audit which cards are expiring next month.…

This is the end of the free sample. Get the eBook to keep going. Buy now

About this book

Implement subscription billing with Paystack. Create plans, manage tokenized charges, and handle retries.

Details

Author
House Beatris
Publisher
SamEnrico
Language
English
Genre
Non-Fiction, First 30 Days, Payment Integration
Released
2026-05-29
Pages (approx.)
148
Available as
eBook, Audiobook

Read better in the ZLOADR app

Your eBooks on your phone or tablet. Sign in with your SamEnrico account and start reading.

More by House Beatris

See all

You may also like

See all