PayChanguLibrary 2.0.0
dotnet add package PayChanguLibrary --version 2.0.0
NuGet\Install-Package PayChanguLibrary -Version 2.0.0
<PackageReference Include="PayChanguLibrary" Version="2.0.0" />
<PackageVersion Include="PayChanguLibrary" Version="2.0.0" />
<PackageReference Include="PayChanguLibrary" />
paket add PayChanguLibrary --version 2.0.0
#r "nuget: PayChanguLibrary, 2.0.0"
#:package PayChanguLibrary@2.0.0
#addin nuget:?package=PayChanguLibrary&version=2.0.0
#tool nuget:?package=PayChanguLibrary&version=2.0.0
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 | Versions 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. |
-
net9.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.