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. CI Pipelines for Payment Code
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 22, 2026

CI Pipelines for Payment Code

Configure your GitHub Actions CI pipeline with two jobs: (1) unit-tests — runs fast, no network, uses mocked Paystack; (2) integration-tests — uses PAYSTACK_TEST_KEY secret, calls real Paystack test API, runs only on PRs to main. Add a coverage step that fails the workflow if coverage drops below threshold. Never store live Paystack keys in CI — test keys only.

GitHub Actions Workflow for Payment Code

# .github/workflows/payment-tests.yml
name: Payment Tests

on:
  push:
    branches: ['*']
  pull_request:
    branches: [main]

jobs:
  unit-tests:
    name: Unit Tests (fast, no network)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci
      - run: npm test -- --testPathPattern="unit|webhook" --coverage
        env:
          PAYSTACK_SECRET_KEY: sk_test_fake_for_unit_tests
          NODE_ENV: test
      - name: Upload coverage report
        uses: actions/upload-artifact@v4
        with:
          name: coverage-report
          path: coverage/

  integration-tests:
    name: Integration Tests (real Paystack test API)
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request'
    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_PASSWORD: testpass
          POSTGRES_DB: testdb
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci
      - run: npm run db:migrate:test
        env:
          DATABASE_URL: postgres://postgres:testpass@localhost:5432/testdb
      - run: npm test -- --testPathPattern="integration"
        env:
          PAYSTACK_SECRET_KEY: ${{ secrets.PAYSTACK_TEST_KEY }}
          DATABASE_URL: postgres://postgres:testpass@localhost:5432/testdb
          NODE_ENV: test

Learn More

This guide is part of the Paystack testing guide.

Sign up for the McTaba newsletter

Key Takeaways

  • ✓Store your Paystack test key as a GitHub Actions secret (PAYSTACK_TEST_KEY) — never commit it to the repo.
  • ✓Separate unit tests (fast, no network) from integration tests (Paystack test API) into different CI jobs.
  • ✓Run unit tests on every push; run integration tests only on PRs targeting main to save CI time.
  • ✓Add a coverage check step — fail the workflow if payment-critical files drop below coverage threshold.
  • ✓Block deploys to production unless all test jobs pass — especially integration tests that verify the real Paystack API contract.
  • ✓Use a separate test database for integration tests in CI — inject DATABASE_URL as a CI secret or use an ephemeral in-memory DB.

Frequently Asked Questions

Is it safe to use a real Paystack test key in GitHub Actions?
Yes — test keys (sk_test_...) do not move real money. Store the test key as a GitHub Actions secret (never in the repo). Test mode API calls are harmless. What you must never put in CI is a live key (sk_live_...). Add a validation step: if PAYSTACK_SECRET_KEY starts with "sk_live_", fail the build immediately.
Should integration tests run on every push or only on PRs?
Integration tests against the real Paystack test API are slower (network dependent) and should run only on PRs to main — not on every push to feature branches. Unit tests should run on every push. This balance keeps CI fast for development while ensuring thorough testing before merging.
How do I prevent production deployment if payment tests fail?
In GitHub Actions, configure your deploy job with needs: [unit-tests, integration-tests]. The deploy job will not run unless both test jobs pass. For Vercel, configure the GitHub integration to require checks to pass before deploying preview or production environments.
Can I run integration tests without a real database in CI?
For pure API integration tests (testing your Paystack API call logic), you can use SQLite in-memory. For full integration tests that verify database state changes, use a real PostgreSQL service in your CI workflow (shown above using GitHub Actions services). SQLite has different SQL behavior from PostgreSQL — use real PostgreSQL for payment integration tests.

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

Testing Paystack Integrations: The Complete Guide

A complete guide to testing Paystack integrations at every level: test mode, test cards, unit tests with mocks, integration tests, end-to-end flows with Playwright, webhook simulation, contract testing, CI pipelines, staging environments, load testing, and coverage targets for payment code.

Read more

Simulating Declined Cards on Paystack

A card decline is one of the most common failure states in a payment flow, and your application must handle it gracefully. This guide shows how to simulate specific card declines in Paystack test mode and how to verify your decline handling code works correctly.

Read more

Mocking the Paystack API in PHPUnit

PHPUnit tests for Paystack integrations in Laravel or PHP can run without any network calls using Laravel's Http::fake() or Mockery. This guide shows how to mock Paystack responses, test webhook handlers, and verify your payment logic in isolation.

Read more

Contract Testing Your Paystack Webhook Handler

Contract testing verifies that your webhook handler correctly handles the exact payload structure Paystack sends. If Paystack adds or renames a field, contract tests catch the mismatch before it reaches production. This guide shows how to write contract tests for Paystack webhook events.

Read more

Paystack Popup Not Opening: Frontend Debug Guide

The Paystack Inline JS popup silently fails to open for several reasons: the script did not load, the browser blocked it as a popup, PaystackPop is undefined, the public key is wrong, or a Content Security Policy blocks the iframe. This guide walks through each cause with a verification step.

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.