Paystack.Client.Sdk 1.1.0

dotnet add package Paystack.Client.Sdk --version 1.1.0
                    
NuGet\Install-Package Paystack.Client.Sdk -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Paystack.Client.Sdk" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Paystack.Client.Sdk" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Paystack.Client.Sdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Paystack.Client.Sdk --version 1.1.0
                    
#r "nuget: Paystack.Client.Sdk, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Paystack.Client.Sdk@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Paystack.Client.Sdk&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Paystack.Client.Sdk&version=1.1.0
                    
Install as a Cake Tool

Paystack.Client.Sdk

A .NET 8 SDK for integrating with the Paystack payment gateway. Provides a clean, strongly-typed client for initializing transactions and verifying payment status.

Installation

Install via NuGet Package Manager Console:

Install-Package Paystack.Client.Sdk

Or via the .NET CLI:

dotnet add package Paystack.Client.Sdk

Requirements

  • .NET 8.0 or later
  • A Paystack account and secret key — get yours at paystack.com

Configuration

Add a PaystackConfig section to your appsettings.json:

{
  "PaystackConfig": {
    "BaseUrl": "https://api.paystack.co",
    "SecretKey": "sk_live_your_secret_key_here"
  }
}

Use sk_test_... keys during development and sk_live_... in production.

Setup

Register the SDK in your Program.cs or Startup.cs:

using Paystack.Client.Sdk.Extensions;

builder.Services.AddPaystackClient(builder.Configuration);

This registers IPaystackClient as a scoped dependency, ready for constructor injection.

Usage

Inject IPaystackClient wherever you need it:

public class PaymentService
{
    private readonly IPaystackClient _paystack;

    public PaymentService(IPaystackClient paystack)
    {
        _paystack = paystack;
    }
}

Initialize a Transaction

Start a payment by creating a transaction. Paystack returns an authorization URL to redirect the user to.

Important: Paystack expects amounts in the smallest currency unit (kobo for NGN). Multiply naira amounts by 100.

var request = new PaystackInitializeTransactionRequest
{
    Email       = "customer@example.com",
    Amount      = 5000 * 100,  // ₦5,000 in kobo
    Reference   = Guid.NewGuid().ToString("N"),
    CallbackUrl = "https://yourapp.com/payment/callback",
    MetaData    = new { orderId = "ORD-001" }
};

var result = await _paystack.InitializeTransaction(request);

if (result.Data?.Status == true)
{
    var authorizationUrl = result.Data.Data?.AuthorizationUrl;
    // redirect the user to authorizationUrl
}

PaystackInitializeTransactionRequest fields:

Property Type Description
Email string Customer's email address
Amount decimal Amount in the smallest currency unit (e.g. kobo for NGN)
Reference string Unique transaction reference
CallbackUrl string URL Paystack redirects to after payment
MetaData object Any extra data to attach to the transaction

Verify a Transaction

After the user completes payment, verify the transaction using the reference:

var result = await _paystack.CheckTransactionStatus("your-transaction-reference");

if (result.Data?.Status == true)
{
    var transaction = result.Data.Data;

    Console.WriteLine($"Status:   {transaction?.Status}");
    Console.WriteLine($"Amount:   {transaction?.Amount}");
    Console.WriteLine($"Channel:  {transaction?.Channel}");
    Console.WriteLine($"Paid At:  {transaction?.PaidAt}");

    var customer = transaction?.Customer;
    Console.WriteLine($"Customer: {customer?.FirstName} {customer?.LastName} ({customer?.Email})");

    var auth = transaction?.Authorization;
    Console.WriteLine($"Card:     {auth?.CardType} ending {auth?.Last4}");
}

Using a Per-Request API Key

Both methods accept an optional apiKey parameter to override the configured secret key. Useful for multi-tenant scenarios:

var result = await _paystack.InitializeTransaction(request, apiKey: "sk_live_tenant_key");

var status = await _paystack.CheckTransactionStatus(reference, apiKey: "sk_live_tenant_key");

Response Models

ApiResults<T>

All methods return ApiResults<T>. Check Data for the typed payload.

PaystackResponseData (InitializeTransaction)

public class PaystackResponseData
{
    public bool    Status  { get; set; }
    public string? Message { get; set; }
    public PaystackAuthorizationData? Data { get; set; }
}

public class PaystackAuthorizationData
{
    public string? AuthorizationUrl { get; set; }  // redirect the user here
    public string? AccessCode       { get; set; }
    public string? Reference        { get; set; }
}

PaystackTransactionResponse (CheckTransactionStatus)

public class PaystackTransactionResponse
{
    public bool   Status  { get; set; }
    public string? Message { get; set; }
    public PaystackTransaction? Data { get; set; }
}

PaystackTransaction key fields:

Property Type Description
Id long Internal Paystack transaction ID
Status string "success", "failed", etc.
Reference string Your transaction reference
Amount decimal Amount charged (in kobo)
RequestedAmount decimal Original requested amount
Channel string Payment channel (card, bank, etc.)
Currency string Currency code (e.g. "NGN")
GatewayResponse string Human-readable gateway message
PaidAt DateTime When payment was completed
CreatedAt DateTime When the transaction was created
Fees int Paystack fees charged
Customer Customer Customer details
Authorization Authorization Card/payment method details
Metadata Metadata Custom metadata attached to the tx

License

MIT © Samuel Biliksuun

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 107 5/7/2026
1.0.51 449 11/20/2025
1.0.5 314 11/12/2025
1.0.4 455 4/30/2025
1.0.3 217 4/30/2025
1.0.2 212 4/30/2025
1.0.1 219 4/30/2025
1.0.0 223 4/30/2025

Version 1.1.0 - fixed JSON property mapping for snake_case fields, updated README