PayStackDotNetSDK API is a collection of all PayStack endpoints that C# developers can take advantage of to build financial solutions in Nigeria. Visit Paystack for Setup.
This Library require .Net framework 4.6 or higher
Install this library from Nuget
- Olorunfemi Davis - Booksrite
Some parts of this project were taken from Paystack.Net.SDK.
- Mark Adesina - Github
This project[alpha stage] showcases some uses of PayStackDotNetSDK methods. Github
This project is licensed under the MIT License
- More precise intellisense
- More Documentation in this README file
Add namespaces: using PayStackDotNetSDK; using PayStackDotNetSDK.Helpers;
- Read Documentation Here - PAYSTACK API Documentation
add namespaces: using PayStackDotNetSDK.Methods.Transactions; using PayStackDotNetSDK.Models.Transactions;
/// <summary>
/// Implements simple InitializeTransaction with basic parameters
/// </summary>
protected async void InitializeTransaction()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.InitializeTransaction("email@email.com", 1000000);
if (response.status)
{
Response.AddHeader("Access-Control-Allow-Origin", "*");
Response.AppendHeader("Access-Control-Allow-Origin", "*");
Response.Redirect(response.data.authorization_url); //Redirects your browser to the secure URL
}
else //not successful
{
//Do something else with the info.
}
}
/// <summary>
/// Implements simple InitializeTransaction with full parameters
/// If callback url is given, the url will be called upon completion. For example http://localhost:60441/Default.aspx?trxref=4dsnq70qtd&reference=4dsnq70qtd
/// </summary>
protected async void InitializeTransaction()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.InitializeTransaction(new TransactionRequestModel() { firstName="firstname", lastName="lastname", amount=1000000, currency = PayStackDotNetSDK.Helpers.Constants.Currency.Naira, email="email@email.com", metadata = new PaystackMetadata() { referrer="email@email.com" }, transaction_charge=4000 });
if (response.status)
{
Response.AddHeader("Access-Control-Allow-Origin", "*");
Response.AppendHeader("Access-Control-Allow-Origin", "*");
Response.Redirect(response.data.authorization_url); //Redirects your browser to the secure URL
}
else //not successful
{
//Do something else with the info.
}
}
protected async void VerifyTransaction()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.VerifyTransaction("reference_code");
}
/// <summary>
/// Implementation with basic parameters
/// </summary>
protected async void TransactionListing()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.ListTransactions();
}
/// <summary>
/// Implementation with full parameters
/// </summary>
protected async void TransactionListing()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.ListTransactions(new TransactionListRequestModel() {amount=40000, from= DateTime.UtcNow.AddDays(-10), to=DateTime.UtcNow, page=2, perPage=50, status= PayStackDotNetSDK.Helpers.Constants.Transaction.Status.Success, customer =4 });
}
/// <summary>
/// Fetch Transaction
/// </summary>
protected async void FetchTransaction()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.FetchTransaction(345);
}
/// <summary>
/// Implementation with basic parameters
/// </summary>
protected async void ChargeAuthorization()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.ChargeAuthorization("authorization_code", "email@email.com", 7000);
}
/// <summary>
/// Implementation with full parameters
/// </summary>
protected async void ChargeAuthorization()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.ChargeAuthorization(new TransactionRequestModel() { firstName="firstname" });
}
protected async void ViewTransactionTimelines()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.TransactionTimeline("referenceOrID");
}
/// <summary>
/// Implementation with basic parameters
/// </summary>
protected async void TransactionTotals()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.TransactionTotals();
}
/// <summary>
/// Implementation with full parameters
/// </summary>
protected async void TransactionTotals()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.TransactionTotals(new TransactionTotalsRequestModel() { });
}
/// <summary>
/// Implementation with basic parameters
/// </summary>
protected async void ExportTransactions()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.ExportTransactions();
}
/// <summary>
/// Implementation with full parameters
/// </summary>
protected async void ExportTransactions()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.ExportTransactions(new ExportRequestModel() { from= DateTime.UtcNow.AddDays(-15) });
}
/// <summary>
/// Implementation with basic parameters
/// </summary>
protected async void RequestReauthorization()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.RequestReAuthorization("authorization_code", "email@email.com", 4000);
}
/// <summary>
/// Implementation with full parameters
/// </summary>
protected async void RequestReauthorization()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.RequestReAuthorization(new RequestReAuthorizationRequestModel() { amount = 4000, authorization_code = "authorization_code", currency = PayStackDotNetSDK.Helpers.Constants.Currency.Naira, email = "email@email.com", reference = "reference", metadata = new PaystackRequestReAuthorizationMetadata() { custom_fields = new PaystackList<RequestReAuthorizationCustomField>() { new PaystackRequestReAuthorizationCustomField() { display_name = "display_name", value = "value", variable_name = "variable_name" } } } });
}
/// <summary>
/// Implementation with basic parameters
/// </summary>
protected async void CheckAuthorization()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.CheckAuthorization("authorization_code", "email@email.com", 4000);
}
/// <summary>
/// Implementation with optional parameters
/// </summary>
protected async void CheckAuthorization()
{
var connectionInstance = new PaystackTransaction(Credential.Key);
var response = await connectionInstance.CheckAuthorization("authorization_code", "email@email.com", 4000, PayStackDotNetSDK.Helpers.Constants.Currency.Naira);
}
add namespaces: using PayStackDotNetSDK.Methods.Customers; using PayStackDotNetSDK.Models.Customers;
add namespaces: using PayStackDotNetSDK.Methods.Subaccounts; using PayStackDotNetSDK.Models.SubAccounts;
add namespaces: using PayStackDotNetSDK.Methods.Plans; using PayStackDotNetSDK.Models.Plans;
add namespaces: using PayStackDotNetSDK.Methods.Subscriptions; using PayStackDotNetSDK.Models.Subscriptions;
add namespaces: using PayStackDotNetSDK.Methods.Pages; using PayStackDotNetSDK.Models.Pages;
add namespaces: using PayStackDotNetSDK.Methods.Invoices; using PayStackDotNetSDK.Models.Invoices;
add namespaces: using PayStackDotNetSDK.Methods.Settlements; using PayStackDotNetSDK.Models.Settlements;
add namespaces: using PayStackDotNetSDK.Methods.TransferRecipients; using PayStackDotNetSDK.Models.TransferRecipients;
add namespaces: using PayStackDotNetSDK.Methods.Transfers; using PayStackDotNetSDK.Models.Transfers;
add namespaces: using PayStackDotNetSDK.Methods.TransfersControls; using PayStackDotNetSDK.Models.TransfersControls;
add namespaces: using PayStackDotNetSDK.Methods.Charges; using PayStackDotNetSDK.Models.Charges;
add namespaces: using PayStackDotNetSDK.Methods.BulkCharges; using PayStackDotNetSDK.Models.BulkCharges;
add namespaces: using PayStackDotNetSDK.Methods.Refunds; using PayStackDotNetSDK.Models.Refunds;
add namespaces: using PayStackDotNetSDK.Methods.ControlPanels; using PayStackDotNetSDK.Models.ControlPanels;
add namespaces: using PayStackDotNetSDK.Methods.Verifications; using PayStackDotNetSDK.Models.Verifications;
add namespaces: using PayStackDotNetSDK.Methods.Banks; using PayStackDotNetSDK.Models.Banks;
/// <summary>
/// Get all Nigerian Banks on Paystack API
/// </summary>
protected async void GetAllBanks()
{
var connectionInstance = new PaystackListedBanks(Credential.Key);
var response = await connectionInstance.ListBanks();
}