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).
This section will briefly guide you through the steps to get started with the library.
- Install the NuGet package
dotnet add package GreatIdeas.Paystack.SDK
- 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();
- 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!;
}