NinePay.SDK.DotNet 1.0.1

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

9PAY Payment Gateway .NET SDK

NuGet NuGet Downloads

Official .NET SDK for integrating 9PAY Payment Gateway.

This package allows you to:

  • Create payment requests with strongly typed parameters.
  • Query transaction status.
  • Verify webhook / callback data.

Requirements

  • .NET 8.0

Dependencies (automatically installed):

  • Newtonsoft.Json
  • DotNetEnv

Installation

Via .NET CLI

dotnet add package NinePay.SDK.DotNet

Via PackageReference

<PackageReference Include="NinePay.SDK.DotNet" Version="1.0.1" />

Environment Configuration

Set the following environment variables (or use a .env file — never commit it):

NINEPAY_MERCHANT_ID=YOUR_MERCHANT_ID
NINEPAY_SECRET_KEY=YOUR_SECRET_KEY
NINEPAY_CHECKSUM_KEY=YOUR_CHECKSUM_KEY
NINEPAY_ENDPOINT=https://your-gateway-endpoint.com

Configuration

using NinePay.SDK.DotNet.Config;

var merchantId = Environment.GetEnvironmentVariable("NINEPAY_MERCHANT_ID");
var secretKey = Environment.GetEnvironmentVariable("NINEPAY_SECRET_KEY");
var checksumKey = Environment.GetEnvironmentVariable("NINEPAY_CHECKSUM_KEY");
var endpoint = Environment.GetEnvironmentVariable("NINEPAY_ENDPOINT");

var config = new NinePayConfig(
    merchantId,
    secretKey,
    checksumKey,
    endpoint
);

Initialization

using NinePay.SDK.DotNet.Gateway;

var gateway = new NinePayGateway(config);

Create Payment

using NinePay.SDK.DotNet.Request;
using NinePay.SDK.DotNet.Response;
using NinePay.SDK.DotNet.Enums;

var request = new CreatePaymentRequest(
    "INV_" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), // Invoice No
    "50000",                                               // Amount
    "Payment for Order 1",                                 // Description
    "https://site.com/callback",                           // Back URL
    "https://site.com/return"                              // Return URL
);

request.WithMethod(PaymentMethod.ATM_CARD)
       .WithClientIp("127.0.0.1")
       .WithCurrency(Currency.VND)
       .WithLang(Language.VI);

ResponseInterface response = gateway.CreatePayment(request);

if (response.IsSuccess())
{
    var redirectUrl = response.GetData()["redirect_url"];
    Console.WriteLine("Redirect user to: " + redirectUrl);
}
else
{
    Console.WriteLine("Error: " + response.GetMessage());
}

Query Transaction

ResponseInterface response = gateway.Inquiry("INV_123456");

if (response.IsSuccess())
{
    Console.WriteLine(response.GetData());
}
else
{
    Console.WriteLine(response.GetMessage());
}

Verify Webhook / Callback

string result = Request.Query["result"];
string checksum = Request.Query["checksum"];

if (gateway.Verify(result, checksum))
{
    string decodedResult = gateway.DecodeResult(result);
    // Process JSON decodedResult...
}

License

MIT License © 9Pay

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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
1.0.1 190 4/8/2026
1.0.0 149 3/11/2026