Skip to content

Latest commit

 

History

History
103 lines (68 loc) · 3.58 KB

README.md

File metadata and controls

103 lines (68 loc) · 3.58 KB

GreatIdeas.Paystack.SDK

License

What is it?

This is a .Net wrapper for Paystack RESTful API. It is a simple library that allows you to easily integrate Paystack's payment gateway into your application for African countries (Nigeria, Ghana, South Africa) and accepting international currencies (USD).

API Endpoints

Getting Started

This section will briefly guide you through the steps to get started with the library.

  1. Install the NuGet package
dotnet add package GreatIdeas.Paystack.SDK
  1. Add the Paystack dependency to your project. It is recommended to use the appsettings or other secret management to store your secret key.
// Using a web application
using GreatIdeas.Paystack.SDK;

var builder = WebApplication.CreateBuilder(args);

const string secretKey = "sk_test_xxx";

builder.Services
    .AddPaystack(secretKey);
    
// Using a console application
using GreatIdeas.Paystack.SDK;
using Microsoft.Extensions.Hosting;

const string secretKey = "sk_test_xxx";

var host = new HostBuilder()
    .ConfigureServices(services =>
    {
        services.AddPaystack(secretKey);
    })
    .Build();
    
  1. Usage of the library Transaction
...

private readonly IPaystackTransaction _paystackTransaction;

public Transaction(IPaystackTransaction paystackTransaction)
{
    _paystackTransaction = paystackTransaction;
}

public async Task<TransactionInitializeResponse> AcceptPayment(TransactionInitializeModel model,
        CancellationToken cancellationToken)
{
    var response = await _paystackTransaction.InitializeAsync(model, cancellationToken);
    return response!;
}