Bonaventure OgetoBy Bonaventure Ogeto|

Paystack Integration Guides by Language and Framework

Paystack works with any language or framework that can make HTTP requests. The API is REST-based with JSON payloads, so the integration pattern is the same everywhere: initialize a transaction on your server, redirect the customer to pay, verify the result, and listen for webhooks. The only thing that changes between frameworks is the HTTP client you use and where you put your route handlers.

How Paystack Integration Works Across Languages

Paystack does not care what language you write. It is a REST API. You send HTTP requests to https://api.paystack.co, include your secret key in the Authorization header, and send or receive JSON. That is the entire protocol.

Here is what a transaction initialization looks like as a raw HTTP request:

POST https://api.paystack.co/transaction/initialize
Authorization: Bearer sk_test_xxxxxxxxxxxxx
Content-Type: application/json

{
  "email": "customer@example.com",
  "amount": 500000,
  "currency": "KES",
  "callback_url": "https://yourapp.com/payment/callback"
}

That request is the same whether you send it from Node.js, Python, PHP, Go, Ruby, Java, C#, or Dart. The language is just the HTTP client. fetch in JavaScript, requests in Python, Guzzle in PHP, net/http in Go. Different syntax, same bytes on the wire.

This is good news. It means three things:

  • No vendor lock-in to a specific SDK. Paystack provides official libraries for some languages, but you never need them. The API is simple enough to call directly.
  • You can port integrations between frameworks quickly. If you built Paystack into a Django app and now need it in FastAPI, the API calls are identical. Only the routing and request/response handling change.
  • Debugging is framework-independent. When something fails, you check the HTTP status code, the Paystack error message, and your request payload. The framework is rarely the problem. The error reference applies to every stack.

The guides in this cluster take this universal API and show you exactly where to put each piece in your specific framework. Where does the secret key go? How do you set up the route for webhooks? How do you verify a signature in your middleware? Those are framework questions, not Paystack questions, and that is what each guide answers.

For the full picture of how Paystack works before you pick a framework guide, read the complete engineering guide.

JavaScript and TypeScript

JavaScript is the most common language in the Paystack ecosystem. Most African startups run Node.js on the backend and React or Vue on the frontend, so this is where the largest chunk of our guides live.

Next.js App Router

Next.js with the App Router (Next.js 13+) uses React Server Components and Route Handlers. Your Paystack secret key lives in a Route Handler (app/api/paystack/route.ts), and the frontend uses Paystack Inline or redirects. Server Actions can also initialize transactions directly.

Next.js Pages Router

The Pages Router uses API Routes (pages/api/) instead of Route Handlers. If your project is on Next.js 12 or earlier, or you have not migrated to the App Router yet, these guides are for you.

React (Client-Side with Separate Backend)

Plain React apps (Create React App, Vite, etc.) have no server. You use Paystack Inline on the client to collect payment, then call your own backend API to verify. The backend can be Express, FastAPI, Laravel, or anything else. These guides cover the React side.

Vue

Vue integrations follow the same pattern as React: Paystack Inline on the client, backend API for verification and webhooks. Vue's composition API makes the Paystack popup easy to wrap in a composable.

Nuxt

Nuxt gives you server routes out of the box (server/api/), so you get the full-stack experience without a separate backend. Your Paystack secret key goes in a server route, and Nuxt handles the rest.

Angular

Angular uses services and dependency injection. The Paystack integration lives in a service that loads Paystack Inline, and your backend (often a separate Node or .NET API) handles verification and webhooks.

Svelte and SvelteKit

SvelteKit has server-side load functions and API endpoints (+server.ts files) that make Paystack integration clean. Plain Svelte without SvelteKit needs a separate backend, similar to plain React or Vue.

Node.js and Express

Express is still the most common Node.js backend framework in Africa. The integration is straightforward: Express routes handle initialization, verification, and webhook receipt. Use fetch (Node 18+) or axios to call the Paystack API.

NestJS

NestJS adds structure to Node.js with modules, controllers, services, and decorators. Your Paystack logic lives in a service, the controller handles routes, and guards can protect webhook endpoints. NestJS's dependency injection makes testing Paystack calls easy to mock.

Supabase Edge Functions

Supabase Edge Functions run on Deno. They are good for serverless Paystack integrations where you want to keep your backend light. The function receives the request, calls Paystack, writes to your Supabase database, and returns. No server to manage.

Firebase Cloud Functions

Firebase Cloud Functions (v2, based on Cloud Run) let you write Paystack handlers as serverless functions. You deploy them alongside your Firestore rules and Firebase Auth. Good for teams already deep in the Firebase ecosystem.

Python

Python is the second most popular backend language among African developers, especially for fintech teams and data-heavy products. Paystack integration in Python means using the requests library (or httpx for async) to call the API, then plugging the routes into your framework of choice.

Django

Django's view system handles Paystack routes. Your webhook endpoint is a Django view with @csrf_exempt (because Paystack cannot send CSRF tokens). Use Django's ORM to record transactions. The guides cover both function-based and class-based views.

Django REST Framework (DRF)

If your Django project exposes a REST API through DRF, these guides show you how to build Paystack endpoints as DRF views with serializers and proper response formatting. Useful for mobile apps and SPAs that talk to a Django API.

FastAPI

FastAPI is async-native, so you can use httpx.AsyncClient to call Paystack without blocking. Type hints and Pydantic models give you automatic request validation. FastAPI's dependency injection works well for sharing a Paystack client across routes.

Flask

Flask is minimal by design. You add routes, call Paystack with requests, and return JSON. No batteries included means no magic to fight. If you want the simplest possible Python integration, Flask is it.

PHP

PHP runs a large share of web applications in Africa, especially in Nigeria where Laravel is the dominant framework. Paystack itself was built in Lagos, so PHP support is first-class. The official paystack-php library exists, but you can also call the API directly with Guzzle or even curl.

Laravel

Laravel is the most popular PHP framework for Paystack integrations. You can use the paystack-php library or call the API through Laravel's HTTP client (which wraps Guzzle). Webhook routes go in routes/api.php to skip CSRF verification. Laravel's event system works well for dispatching jobs after payment confirmation.

Symfony

Symfony is less common than Laravel in the African dev scene but used in larger enterprise projects. The integration uses Symfony's HttpClient component and controller routes. Webhook handling works through a dedicated controller action.

Other Languages

These frameworks are less common in the African startup scene but popular in enterprise environments, fintech backends, and teams with specific language preferences.

Ruby on Rails

Rails handles Paystack with Net::HTTP or the httparty gem. Controllers receive webhooks, models store transaction records, and Active Job processes async work after payment. Rails conventions make the integration predictable.

Go

Go's net/http standard library is all you need. No external dependencies required. Go's strong typing and built-in JSON marshalling make Paystack response handling clean. Good for high-throughput payment services where you want low latency and small memory footprint.

Spring Boot (Java/Kotlin)

Spring Boot is common in African banks and large fintech companies. The integration uses RestTemplate or WebClient (reactive) to call Paystack. Spring's @RestController annotation handles webhook endpoints. Spring Security can validate webhook signatures in a filter.

ASP.NET Core (C#)

ASP.NET Core is used by some enterprise teams in South Africa, Kenya, and Nigeria. The integration uses HttpClient (injected via IHttpClientFactory) and controller actions. ASP.NET Core's middleware pipeline is a natural place for webhook signature verification.

Mobile

Mobile apps cannot safely store your Paystack secret key. The secret key must stay on your server. So every mobile Paystack integration has two parts: the mobile app (which shows the payment UI and collects the result) and a backend API (which initializes transactions, verifies payments, and receives webhooks).

The mobile guides in this cluster cover both parts. They show the mobile-side code and the backend calls your app needs to make.

Flutter

Flutter is the most popular cross-platform framework among African mobile developers. You can use the paystack_flutter package for a pre-built payment UI, or load Paystack Inline in a WebView. The backend is usually Node.js, Django, or Firebase Cloud Functions.

React Native

React Native integrations typically use react-native-paystack-webview to show the Paystack checkout inside your app. The JavaScript side calls your backend API, which does the actual Paystack API calls. If you already have a Node.js backend, the server code is identical to a web integration.

Android (Kotlin)

Native Android apps can use Paystack's Android SDK or load the checkout in a WebView using Android's WebViewClient. Kotlin coroutines handle async API calls to your backend. The webhook and verification logic lives on your server, not in the Android app.

iOS (Swift)

iOS apps can load the Paystack checkout in a WKWebView or use a native form with the Paystack iOS SDK. Swift's URLSession calls your backend to initialize and verify. As with all mobile platforms, the secret key must never appear in your app bundle.

The Four Tasks Every Integration Needs

No matter what framework you pick, your Paystack integration needs to handle four tasks. Every guide in this cluster is organized around these four tasks.

1. Accept a Payment

This is the starting point. You call POST /transaction/initialize with the customer's email, amount (in the smallest currency unit, e.g., kobo or cents), and a callback URL. Paystack returns an authorization_url where the customer pays. After payment, the customer is redirected back to your callback URL with a reference in the query string.

For frontend frameworks, you can skip the redirect and use Paystack Inline (a JavaScript popup) that handles payment in a modal without leaving your page.

See the accepting payments guide for the full breakdown of initialization, channels, and checkout options.

2. Verify a Payment

After the customer pays (or claims to have paid), you call GET /transaction/verify/:reference using your secret key. You check that the response shows status: "success" and that the amount and currency match what you expected. This is the single most important security step. Never grant access or deliver goods based on a client-side callback alone.

3. Handle Webhooks

Paystack sends POST requests to your webhook URL whenever something happens: a charge succeeds, a transfer completes, a subscription renews, a charge-back is filed. You must validate the x-paystack-signature header using HMAC SHA-512 with your secret key, return a 200 status immediately, then process the event asynchronously.

Webhooks are your safety net. If the customer closes the browser before the redirect, your webhook still fires. If the network drops during verification, the webhook still fires. Build your system so that webhooks are the source of truth, not redirects.

Read the webhooks engineering guide for retry logic, event types, and security patterns.

4. Build Subscriptions

Recurring billing means creating a Plan (with an interval and amount), then subscribing a customer to that plan. Paystack handles the charging schedule. You listen for subscription.create, invoice.payment_failed, and subscription.disable webhook events to keep your app in sync.

Each framework guide in this cluster covers all four tasks for your specific stack. Pick your framework from the lists above and work through the four guides in order.

What This Cluster Covers

This is the hub page for the framework integration cluster. It contains 100 spoke articles organized as a matrix of 25 frameworks and 4 tasks.

The 25 frameworks:

  • JavaScript/TypeScript (11): Next.js App Router, Next.js Pages Router, React, Vue, Nuxt, Angular, Svelte/SvelteKit, Node.js/Express, NestJS, Supabase Edge Functions, Firebase Cloud Functions
  • Python (4): Django, Django REST Framework, FastAPI, Flask
  • PHP (2): Laravel, Symfony
  • Other server-side (4): Ruby on Rails, Go, Spring Boot, ASP.NET Core
  • Mobile (4): Flutter, React Native, Android/Kotlin, iOS/Swift

The 4 tasks:

  • Accept payments (initialize a transaction, show checkout, handle callback)
  • Verify payments (confirm the transaction server-side before fulfilling)
  • Handle webhooks (receive events, validate signatures, process asynchronously)
  • Build subscriptions (create plans, subscribe customers, handle renewals and failures)

Every guide follows the same structure: what you need before you start, the complete code, an explanation of each step, and common mistakes to avoid. The code examples are designed to work as-is in a fresh project with your Paystack test keys.

How to Use This Cluster

  1. Read the pillar first. The complete engineering guide explains how Paystack works at a conceptual level. Read it before jumping into framework-specific code.
  2. Pick your framework. Find your stack in the lists above and open the "Accept payments" guide for that framework. That is your starting point.
  3. Work through all four tasks. Accept, verify, webhooks, subscriptions. Do them in order. Each guide builds on the previous one.
  4. Check the error reference. When you hit an error, check the error reference before searching Stack Overflow. The answer is probably there.

Which Framework Should You Choose?

If you are starting a new project and want a recommendation:

  • Solo developer building a web app: Next.js App Router. Full-stack in one project, great deployment story on Vercel, and the largest community of African developers using it with Paystack.
  • Team with Python experience: Django or FastAPI. Django if you want batteries included (admin panel, ORM, auth). FastAPI if you want async performance and modern Python conventions.
  • Team with PHP experience: Laravel. Dominant in Nigeria, strong Paystack community support, and plenty of local developers who know it.
  • Building a mobile app: Flutter with a Node.js or Supabase backend. Flutter gives you Android and iOS from one codebase. Supabase Edge Functions keep the backend minimal.
  • High-throughput payment service: Go. Minimal memory, fast startup, and the standard library is all you need.
  • Enterprise or banking environment: Spring Boot or ASP.NET Core. These are the frameworks your compliance team already trusts.

But honestly, it does not matter much. Paystack is a REST API. Pick the framework your team already knows and get building. You can always switch later because the API calls are identical.

Stay Updated on African Payment Integrations

Payment APIs in Africa change fast. New channels appear, country-specific rules shift, and frameworks release breaking updates that affect your integration code. We track all of it.

Join the McTaba Labs newsletter for practical updates on Paystack, M-Pesa, Flutterwave, and the full African payment stack. No hype, no filler. Just the technical changes that affect your code.

Subscribe to the newsletter

Key Takeaways

  • Paystack is a REST API with JSON payloads. Any language or framework that can send HTTP requests and parse JSON can integrate with it. There is no language-specific SDK you must use.
  • Every Paystack integration follows the same four tasks: accept a payment (initialize transaction), verify the payment (GET the transaction), handle webhooks (receive POST from Paystack), and manage subscriptions (create plans and subscribe customers).
  • Frontend frameworks like React, Vue, and Angular use Paystack Inline (a JavaScript popup) on the client side, but still need a backend to verify payments and receive webhooks. Never trust the client alone.
  • This cluster contains 100 framework-specific guides covering 25 frameworks across 4 integration tasks. Pick your stack from the list below and follow the guide that matches your task.
  • The core API calls are identical across all frameworks. Once you understand the Paystack flow in one language, porting it to another takes minutes, not days.

Frequently Asked Questions

Does Paystack have official SDKs for every language?
No. Paystack provides official libraries for a few languages (Node.js, PHP, and some mobile SDKs), but not for every framework. You do not need an official SDK. The Paystack API is a standard REST API with JSON payloads. Any language with an HTTP client can call it directly. Many production integrations skip the SDK entirely and use plain HTTP requests.
Can I use Paystack with a frontend-only app (no backend)?
Not safely. You can use Paystack Inline (the JavaScript popup) to collect payments on the frontend, but you must verify the payment on a server using your secret key. Your secret key must never appear in client-side code. Frontend-only apps need at least a lightweight backend or serverless function for verification and webhook handling.
Is the Paystack integration different for each African country?
The API endpoints and authentication are the same regardless of country. What changes is the currency code (NGN, GHS, ZAR, KES, USD), the available payment channels (some countries have mobile money, others do not), and the KYC requirements for your Paystack business account. Your code structure stays the same.
Should I use Paystack Inline or the redirect checkout?
Paystack Inline (the JavaScript popup) keeps the customer on your page, which usually means better conversion. The redirect checkout sends the customer to a Paystack-hosted page, which is simpler to implement and works when you cannot load JavaScript (e.g., server-rendered pages or email links). For most web apps, Inline is the better choice. For mobile apps and API-first architectures, you typically initialize on the server and open the authorization URL in a WebView or browser.
Can I use the same Paystack integration code across multiple frameworks?
The API calls are identical. A POST to /transaction/initialize with the same headers and body produces the same result from any language. What changes between frameworks is the routing (how you define URL endpoints), the request/response objects (how you read headers and body), and the environment configuration (where you store your secret key). If you understand the Paystack flow in one framework, moving to another is a matter of learning the new framework's HTTP conventions, not re-learning Paystack.

Ready to build real-world apps?

Join the McTaba Labs full-stack marathon (4 months full-time · 6 months part-time). Learn M-Pesa, USSD, and WhatsApp engineering while shipping 8 production apps.

Apply to the McTaba Marathon