khalti_maui 1.0.1

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

khalti_maui

Accept Khalti payments in your .NET MAUI app through Khalti's current Payment Gateway (KPG-2 / ePayment). The library initiates a payment, opens the hosted Khalti checkout in a browser, and polls the gateway for the result — behind one cross-platform call. No deep-link / URL-scheme setup required.

var result = await KhaltiPayment.Current.PayAsync(new KhaltiPaymentRequest
{
    PublicKey   = "<your-public-key>",       // safe to ship
    Pidx        = pidxFromYourServer,         // from epayment/initiate/ on your server
    PaymentUrl  = paymentUrlFromYourServer,
    Environment = KhaltiEnvironment.Production,
});

if (result.IsSuccess)
    await DisplayAlert("Success", $"txn {result.TransactionId}", "OK");

Follows the same model as Khalti's official SDKs: a public key + a server-initiated pidx/payment_url, verified against epayment/lookup-sdk/ with the public key (no secret key on the client).

Requirements

Framework .NET MAUI (.NET 10+)
Android API 24+
iOS 13.0+

Installation

dotnet add package khalti_maui

That's it — no callback activity, no Info.plist URL scheme, no App Links.

How it works

  1. Initiate — your server (recommended) or the library (SecretKey, dev only) calls Khalti epayment/initiate/ to get a payment_url + pidx.
  2. Checkout — the library opens payment_url in a browser tab (Chrome Custom Tabs / SFSafariViewController), where the user logs into Khalti and pays.
  3. Result — the library polls epayment/lookup/ until the payment reaches a final status (Completed, Expired, …) and returns it. Khalti's redirect must be an https URL, so the outcome comes from the gateway (lookup), not a deep link — which is why no URL-scheme setup is needed.

Two ways to supply the payment

  • Server-initiated (recommended). Initiate on your backend with your secret key; pass the returned PaymentUrl (+ Pidx) into the request. The library opens checkout; verify the final status on your server (webhook / lookup).
  • Direct (development only). Set SecretKey on the request. The library initiates, opens checkout, and polls lookup to return a verified result. Never ship a live secret key in a mobile app.

API

Member Description
KhaltiPayment.Current.PayAsync(request) Runs the full checkout, returns a KhaltiPaymentResult.
KhaltiPaymentRequest PublicKey (required), Environment, and either Pidx+PaymentUrl (server-initiated) or SecretKey (+order fields) for dev-only direct initiation.
KhaltiPaymentResult Status, Pidx, TransactionId, Amount, Fee, Refunded, PurchaseOrderId/Name, Mobile, ErrorType, Code, Details.
KhaltiPaymentStatus Completed, Pending, Canceled, Expired, Refunded, Failed.
KhaltiErrorType None, Network, PaymentLookupFailure, Disposed, Unknown.

With PaymentUrl only (no secret key), PayAsync opens checkout and returns Pending — confirm the final status on your server via pidx.

Merchant credentials

Get your keys and configure the gateway on the Khalti merchant dashboard: https://khalti.com/ · docs: https://docs.khalti.com/

License

MIT. The library talks to Khalti's public ePayment API; Khalti and its gateway are operated by Khalti — see https://khalti.com/.

Product Compatible and additional computed target framework versions.
.NET net10.0-android36.0 is compatible.  net10.0-ios26.0 is compatible. 
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 135 7/13/2026
1.0.0 121 7/11/2026

Initial release: Khalti Payment Gateway (KPG-2 / ePayment) web-checkout for Android and iOS.