khalti_maui 1.0.1
dotnet add package khalti_maui --version 1.0.1
NuGet\Install-Package khalti_maui -Version 1.0.1
<PackageReference Include="khalti_maui" Version="1.0.1" />
<PackageVersion Include="khalti_maui" Version="1.0.1" />
<PackageReference Include="khalti_maui" />
paket add khalti_maui --version 1.0.1
#r "nuget: khalti_maui, 1.0.1"
#:package khalti_maui@1.0.1
#addin nuget:?package=khalti_maui&version=1.0.1
#tool nuget:?package=khalti_maui&version=1.0.1
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
- Initiate — your server (recommended) or the library (
SecretKey, dev only) calls Khaltiepayment/initiate/to get apayment_url+pidx. - Checkout — the library opens
payment_urlin a browser tab (Chrome Custom Tabs /SFSafariViewController), where the user logs into Khalti and pays. - Result — the library polls
epayment/lookup/until the payment reaches a final status (Completed,Expired, …) and returns it. Khalti's redirect must be anhttpsURL, 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
SecretKeyon 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
PaymentUrlonly (no secret key),PayAsyncopens checkout and returnsPending— confirm the final status on your server viapidx.
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. |
-
net10.0-android36.0
- Microsoft.Maui.Essentials (>= 10.0.20)
-
net10.0-ios26.0
- Microsoft.Maui.Essentials (>= 10.0.20)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release: Khalti Payment Gateway (KPG-2 / ePayment) web-checkout for Android and iOS.