💳💰 A .NET Library for payant
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vs/PayantDotNet/v14
PayantCSharp
packages
PayantDotNet.sln
Readme.md
license.md

Readme.md

GitHub issues GitHub forks GitHub stars GitHub license Twitter

Payant.NET

A .NET package for Payant

For more information, visit Payant Official Documentation.


Installation

To install PayantDotNet, run the following command in the Package Manager Console or nuget.

Installation image


Usage

  • Include the PayantDotNet namespace
using PayantDotNet;

NOTE : Each namespaces below are reponsible for each Payant activities you want to perfom.


  • Other namespaces include the following:
// For client related activities
using PayantDotNet.Client;

// For invoice related activities
using PayantDotNet.Invoice;

// For miscellaneous related activities
using PayantDotNet.Miscellaneous;

// For payment related activities
using PayantDotNet.Payment;

// For product related activities
using PayantDotNet.Product;

// For transfer related activities
using PayantDotNet.Transfer;
  • Instantiate the Payant object with your secret Key
Payant _payant = new Payant("xxxxxxxxxxxxxxxxxxxxxxxx");

Method Usage

NOTE: Every Add, Get, Delete, Send methods respectively follow similar usage style.


  • Add client: add new client to merchant account
var result = _payant.AddClientAsync();

Console.WriteLine(result.Status);
  • Get client: retrieve details of a specific client
var client = _payant.GetClientAsync("1709");

Console.WriteLine(client.Data.FirstName + " " + client.Data.LastName);
  • Add new Product: add a new Product to merchant account
// set product properties
Product newProduct = new Product
{
    Name = "Car",
    Description = "Toyota camry LE",
    UnitCost = 500,
    Type = Product.ProductTypes.Product,
    Status = "1"
};

//send request
var newProductResult = _payant.AddProductAsync(newProduct);

//output the result
Console.WriteLine(newProductResult.Status + ": " + newProductResult.Message);

//OUTPUT : Success: Product has been added successfully
  • Get Product: retrieve details of a specific product
var requestedProduct = _payant.GetProductAsync("78");

Console.WriteLine(requestedProduct.Status + " " + requestedProduct.Data.Name);

//OUTPUT : Success: Burger
  • Edit product: edit details of a specific product
//new values for product
Product editedProduct = new Product
{
    Name = "Cars",
    Description = "Toyota camry LE",
    UnitCost = 500,
    Type = Product.ProductTypes.Product,
    Status = "1"
};

var editedProductResult = _payant.EditProductAsync("96", editedProduct);

Console.WriteLine(editedProductResult.Status + " " + editedProductResult.Data.Name);
  • Get Products: get all products that exists in merchant account
var products = _payant.GetProductsAsync();

Console.WriteLine(products.Status + ": " + products.Data[0].CreatedAt);

Console.WriteLine(products.Status + ": " + products.Data[0].CreatedAt);

// OUTPUT: 
// Success: 2016-12-21 18:46:30
// Success: 2017-02-21 04:32:22
  • Add Payment: add new payment/perform a new payment
Payment newPayment = new Payment()
{
    InvoiceReferenceCode = "HFGcXb6IfUB4wurodtv1",
    Date = DateTime.Now.ToString("dd/mm/yyyy"),
    Amount = "5738.959",
    PaymentChannel = Payment.PaymentChannels.Cheque
};

var newPaymentResult = _payant.AddPaymentAsync(newPayment);
Console.WriteLine(newPaymentResult.Message);
  • Get Payment: retrieve a specific payment details
var payment = _payant.GetPaymentAsync("LGi1se7u6kfqT84dAbUS");

Console.WriteLine(payment.Status);
  • Get Payment History: retrieve payment histories within a range of time
PaymentHistory paymentHistories = new PaymentHistory()
{
    paymentPeriod = PaymentHistory.Periods.Ninety
};


var paymentHistoriesResult = _payant.GetPaymentHistoriesAsync(paymentHistories);

Console.WriteLine(paymentHistoriesResult.Status);
  • Get Banks: retrieve a list of banks and their access codes
var banks = _payant.GetBanksAsync();

foreach (var bank in banks.Data)
{
    Console.WriteLine($"Bank code: {bank.Key} , Bank name: {bank.Value.ToLower()}");
}


// OUTPUT: Bank code: 011 , Bank name: first bank nigeria}
  • Delete Client: delete a specific client from merchant account
var deletedClient = _payant.DeleteClientAsync("1787");

Console.WriteLine(deletedClient.Status);

// OUTPUT: Success

Available methods

  • Product
AddProductAsync(Product productData):ProductResponse
GetProductAsync(string productId):ProductResponse
EditProductAsync(string productId, Product productData):ProductResponse
GetProductsAsync():AllProductsResponse
  • Payments
AddPaymentAsync(Payment paymentData):PaymentResponse
GetPaymentAsync(string referenceCode):PaymentResponse
GetPaymentHistoriesAsync(PaymentHistory transferHistoryData):PaymentHistoryResponse
  • Transfers
AddTransferAsync(Transfer transferData):TransferResponse
GetTansferAsync(string referenceCode):TransferResponse
GetTransferHistoriesAsync(TransferHistory transferHistoryData):TransferHistoryResponse
DeleteTransferAsync(string referenceCode):Response
  • Invoices
AddInvoiceAsync(Invoice incoiceData):InvoiceResponse
GetInvoiceAsync(string referenceCode):InvoiceResponse
SendInvoiceAsync(string referenceCode):Response
GetInvoiceHistoryAsync(InvoiceHistory invoiceDetails):InvoiceResponse
DeleteInvoiceAsync(string referenceCode):Response
  • Clients
DeleteClientAsync(string clientId):Response
EditClientAsync(string clientId, Client clientData):ClientResponse
GetClientAsync(string clientId):ClientResponse
AddClientASync(Client clientData):ClientResponse
  • Miscellaneous
GetPaymentsAsync(string referenceCode):PaymentResponse
GetBanksAsync():Banks
ResolveAccountAsync(Account accountDetails):ResolvedAccountResponse



Contribution

For any changes or imporovement, simply fork this repo and contribute by submitting a pull request to enhance the functionalities, and I'll check it out By The Most High God's Grace.

For any inquiry, message me at @TNkemdilim

As a sign of appreciation, why not star the repo.

License

The MIT License (MIT). Please see License File for more information.