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: 'customer@example.com',
  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.

Ready to get started?

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

Start building