Official .NET server-side SDK for the Wire payment API. Targets .NET 8, with zero third-party dependencies (built on System.Net.Http and System.Text.Json).
dotnet add package Wirepaymentusing Wire;
using var wire = new WireClient("sk_live_...");
// Amounts are in minor units (integer).
var pi = await wire.PaymentIntents.CreateAsync(new PaymentIntentCreateParams
{
Amount = 50000,
Currency = "MNT",
AllowedOperators = new[] { "sandbox" }, // the operator ids enabled on your account
});
var confirmed = await wire.PaymentIntents.ConfirmAsync(pi.Id);
Console.WriteLine($"{confirmed.Id} {confirmed.Status}");await foreach (var charge in wire.Charges.ListAsync(new ListParams { Limit = 50 }))
{
Console.WriteLine(charge.Id);
}Always verify on the raw, unparsed request body.
using Wire;
// rawBody is the unparsed request body (string or byte[]).
// header is the value of the WirePayment-Signature request header.
var ev = Webhooks.Verify(rawBody, header, endpointSecret);
Console.WriteLine(ev.Type);Webhooks.Verify throws SignatureVerificationException on any mismatch, malformed header,
or timestamp outside tolerance (default 300s). It fails closed.
using Wire;
try
{
await wire.PaymentIntents.CreateAsync(new PaymentIntentCreateParams { Amount = -1 });
}
catch (WireException e)
{
Console.WriteLine($"{e.Code} {e.RequestId} {e.StatusCode}");
}Network and timeout failures surface as WireConnectionException (a subclass of WireException).
The API key is never logged nor included in any exception.
using var wire = new WireClient("sk_live_...", new WireClientOptions
{
BaseUrl = "https://api.wire.mn", // default
Timeout = TimeSpan.FromSeconds(30),
MaxRetries = 2,
// HttpClient = myHttpClient, // inject your own
// HttpMessageHandler = myHandler, // or a custom handler
});Requests are retried with exponential backoff and jitter on 429, 5xx, and network errors,
honoring Retry-After. POST requests carry an Idempotency-Key (generated if not supplied),
reused across retries.
Full API documentation: docs.wire.mn.
MIT