PayChanguLibrary 2.0.0

dotnet add package PayChanguLibrary --version 2.0.0
                    
NuGet\Install-Package PayChanguLibrary -Version 2.0.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="PayChanguLibrary" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PayChanguLibrary" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PayChanguLibrary" />
                    
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 PayChanguLibrary --version 2.0.0
                    
#r "nuget: PayChanguLibrary, 2.0.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 PayChanguLibrary@2.0.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=PayChanguLibrary&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PayChanguLibrary&version=2.0.0
                    
Install as a Cake Tool

PayChangu Payment Gateway Library

1. Introduction

This is a custom-developed Payment Gateway Library developed for a streamlined integration of PayChangu Payment Gateway in C# projects developed by Helix W. Chipofya.

This is a custom tool and independent project and the developer and product are not affiliated with PayChangu. This is just a tool that enhances the experience of integrating payment capabilities in your project.

2. Get Started

In order to start using this library, you will need to create an account on https://dashboard.paychangu.com. Upon creation you will be given access to a user dashboard to track incoming transactions, total payments and be able to generate project-specific API Keys to start creating user transactions on PayChangu's platform.

This library relies on those API Keys so be sure to generate them first and store them in save Environment Variables of your project.

3. Basic Usage

Initialize Service

To get started inject the service in your program.cs file and pass in your API Key as a parameter by writing builder.services.AddPayChanguLibrary(apiKey). In doing this you can easily access your API Key in GatewayService.APIKey when GatewayService is injected as a dependency in your class files. This key will be used when you create an object of the type TransactionRequest and is passed into a member function in TransactionRequest as a parameter to create a payment session.

TransactionRequest

Everything begins with a TransactionRequest. This is the transaction information that is created when the user begins to make a transaction. The TransactionRequest contains all the information about a purchase.

var transactionRequest = new TransactionRequest
{
    Amount = 5000,
    Currency = TransactionContext.Enums.Currency.MWK,
    ReturnURL = new Uri("https://your-return-url"),
    CallbackURL = new Uri("https://your-callback-url"),
    Email = "email@example.com",
    Firstname = "John",
    Lastname = "Doe",         
};

Create A Payment Session

A new payment session is created on PayChangu's payment platform by calling gatewayService.CreatePaymentSessionAsync while passing in a parameter of type TransactionRequest. This is an asynchronous method and returns a TransactionResponse object.

var transactionResponse =  await gatwayService.CreatePaymentSessionAsync(transactionRequest);

TransactionResponse (Checkout Url & Transaction Reference)

The TransactionResponse is returned which contains service properties of which among them is the Checkout Url. This is the url that is opened in a webview or web browser for the user to select payment methods and enter details to complete a purchase. TransactionResponse also contains a TransReference property which is the transaction reference that can be used to cross-check the state of a generated transaction. To check the state of a transaction you call gatewayService.CheckPaymentSessionAsync and pass in your transaction reference as the parameter. Checking the state of a transaction returns an object of type TransactionSession.

var session = await gatewayService.CheckPaymentSessionAsync(transactionResponse.TransReference);

TransactionSession

The TransactionSession object provides information about the state of a transaction that was referenced by using the transaction reference. The TransactionSession.Data property provides more detailed insight regarding the same.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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
2.0.0 223 12/4/2025
1.0.0 215 12/3/2025