.NET¶
Oura · source
Targets .NET 8. Uses the built-in System.Text.Json, no third-party dependencies. This SDK holds your secret key, so use it only on a server.
Install¶
Accept a payment¶
using Oura;
var oura = new OuraClient(Environment.GetEnvironmentVariable("OURA_SECRET_KEY")!);
var payment = await oura.Payments.CreateAsync(new Dictionary<string, object?>
{
["amount"] = 245000, // NPR 2,450.00 in paisa
["methods"] = new[] { "esewa", "khalti" },
["return_url"] = "https://himalstore.com.np/orders/1042",
});
var checkoutUrl = payment.GetProperty("checkout_url").GetString();
Other calls¶
await oura.Payments.RetrieveAsync("pay_123");
await oura.Payments.ListAsync(20);
await oura.Payments.CancelAsync("pay_123");
await oura.Payments.CreateAsync(parameters, idempotencyKey: $"order_{orderId}");
An idempotency key is generated for every create. Pass your own, tied to your order, to make retries safe across restarts. See Idempotency.
Configuration¶
Point the client at a local API while developing:
Webhooks¶
Verify with Webhooks.ConstructEvent(raw, sig, secret) and Webhooks.Verify(raw, sig, secret, 300). Both compare in constant time and reject stale timestamps. Always pass the raw request body. Full example: Webhooks.
Errors¶
Every non-2xx response raises OuraException with the error code, HTTP status and message. See Errors.