Skip to main content

Paystack TypeScript SDK

A type-safe, platform-agnostic SDK for the Paystack API. Built with modern TypeScript and Zod for runtime validation.

Quick start

Get up and running with Paystack in minutes

1

Install the SDK

Install the package using your preferred package manager:
npm install @efobi/paystack
2

Initialize the client

Create a new Paystack instance with your secret key:
import { Paystack } from '@efobi/paystack';

const paystack = new Paystack(process.env.PAYSTACK_SECRET_KEY);
Get your secret key from the Paystack Dashboard. Use sk_test_* for testing and sk_live_* for production.
3

Initialize a transaction

Create your first payment transaction:
const result = await paystack.transaction.initialize({
  email: '[email protected]',
  amount: 50000, // Amount in kobo (₦500.00)
  currency: 'NGN'
});

if (result.data) {
  console.log('Payment URL:', result.data.data.authorization_url);
  // Redirect customer to result.data.data.authorization_url
}
The SDK returns a type-safe result object. Check for result.data for success or result.error for validation errors.

Key features

Everything you need for payment integration

Type-safe

Full TypeScript support with strict typing and IntelliSense

Platform-agnostic

Works in Node.js, Bun, browsers, and edge runtimes

Runtime validation

Input/output validation using Zod schemas for data integrity

Webhook handling

Built-in webhook verification and event listeners

Comprehensive APIs

Transactions, transfers, virtual accounts, and more

Modern interface

Clean, promise-based API with async/await support

Explore by topic

Deep dive into specific payment workflows

Transactions

Initialize, verify, and manage payment transactions

Transfers

Send money to bank accounts and manage recipients

Virtual accounts

Create dedicated virtual accounts for customers

Verification

Verify account numbers and resolve card BINs

Webhooks

Handle real-time payment events securely

Authentication

Secure your API keys and handle authorization

Ready to get started?

Follow our quickstart guide to integrate Paystack payments into your application in minutes.

Start building

Build docs developers (and LLMs) love