Dot0.Zarinpal 10.0.1

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

Dot0.Zarinpal

A reusable Zarinpal IPG client for .NET 10. It supports payment requests, checkout URLs and server-side payment verification. It depends only on .NET HTTP/JSON APIs and Microsoft.Extensions.Http, with no application, database or other Dot0 module dependency.

Document public types, constructors, methods and properties with XML comments, including generated positional-record properties. The package includes those XML docs for IntelliSense.

Registration

Pass prepared settings once during application startup:

using Dot0.Zarinpal;

services.AddZarinpal(new ZarinpalSettings
{
    MerchantId = merchantId,
    Sandbox = true,
    Timeout = TimeSpan.FromSeconds(30),
    PooledConnectionLifetime = TimeSpan.FromMinutes(2),
});

Registration validates settings and returns an IHttpClientBuilder for additional HTTP configuration. Sandbox defaults to true; set it to false for production. MerchantId must be a non-empty UUID in either mode. The defaults above apply when timeout and connection lifetime are omitted.

Inject ZarinpalClient into scoped or transient consumers. AddHttpClient owns the shared SocketsHttpHandler pool. Connection lifetime controls renewal; cookies, automatic redirects and factory request logging are disabled. The client does not automatically retry requests or poll payment status.

Payment operations

using Dot0.Zarinpal.Models;

var request = new ZarinpalPaymentRequest(amountIrt, description, callbackUrl);
var checkout = await client.RequestAsync(request, cancellationToken);
var paymentUri = client.GetPaymentUri(checkout.Authority);

// Persist the amount and authority before redirecting the buyer to paymentUri.
// In the callback, load those saved values and match the returned authority.
var verification = await client.VerifyAsync(savedAuthority, savedAmountIrt, cancellationToken);
  • Public amounts and fees are long IRT (whole Toman). The client converts request and verification amounts to IRR with checked arithmetic and rounds returned fees up to whole Toman.
  • Verification accepts code 100 for a newly verified payment and 101 for a previously verified payment. RefId is the positive gateway transaction reference.
  • ZarinpalException preserves provider rejection codes. HTTP failures and invalid JSON propagate through standard .NET exceptions. Async methods accept cancellation.

The consuming application owns payment storage, authorization, callback handling, result pages and fulfillment idempotency. A callback status alone does not prove payment; verify the saved authority and amount server-side before fulfilling an order.

Build, checks and publishing

From the repository root:

dotnet run --project Zarinpal.Test/Zarinpal.Test.csproj --configuration Release
dotnet pack Zarinpal/Zarinpal.csproj --configuration Release --no-build --output ./nupkg -p:PackageVersion=10.0.0

The checks use HTTP test doubles and never contact a gateway or charge money. They cover sandbox/production endpoints, registration, shared handlers, currency conversion, verification, provider errors and overflow handling.

The publishing workflow is .github/workflows/deploy-zarinpal.yml. It runs on pushes to deploy-zarinpal or manual dispatch, builds and checks the client, then publishes version 10.0.<GitHub run number> as Dot0.Zarinpal. Before its first run, add the package's NuGet Trusted Publishing policy using the repository publishing instructions. The policy must allow creating this new package and use the existing NUGET_USER account, repository bootkitlib/dot0, workflow deploy-zarinpal.yml and no environment.

Creating the source and workflow does not establish that the package is published.

Provider references

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
10.0.1 81 11/18/2026