Skip to content

UdotCASH/ucashpay-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

ucashpay-dotnet

A zero-dependency .NET (C#) client for U.CASH Pay: create crypto + card checkouts and verify settlement webhooks. Non-custodial. Targets .NET 6+.

Install

dotnet add package UdotCASH.UcashPay

Or reference the source directly. To publish to NuGet yourself: dotnet pack then dotnet nuget push.

Create a checkout

using UdotCASH.UcashPay;

var client = new UcashPayClient(Environment.GetEnvironmentVariable("UCASH_CLOUD_TOKEN")!);

var r = await client.CreateCheckoutAsync(
    amount: "10.00",
    currency: "USD",
    externalReference: order.Id,          // idempotent; returned in the webhook
    title: $"Order #{order.Id}",
    redirectUrl: "https://yoursite.com/thanks");

if (r.Ok) return Redirect(r.PaymentUrl);  // send buyer to hosted checkout

Verify a webhook (ASP.NET Core example)

app.MapPost("/ucashpay/webhook", async (HttpContext ctx) =>
{
    var raw = await new StreamReader(ctx.Request.Body).ReadToEndAsync();
    var sig = ctx.Request.Headers["X-Webhook-Signature"].ToString();
    var secret = Environment.GetEnvironmentVariable("UCASH_WEBHOOK_SECRET")!;

    var client = new UcashPayClient("");
    var v = client.VerifyWebhook(raw, sig, secret);
    if (!v.Verified) return Results.Unauthorized();

    // parse `raw`, mark the order paid
    return Results.Ok();
});

Set the webhook URL in pay.u.cash to your endpoint, save, then Test Webhook.

Set up your pay.u.cash account

  1. Sign up at pay.u.cash with email + password, then click the verification link in the email.
  2. Set your receive addresses under Settings → Addresses (a wallet per coin, or ENS/Unstoppable/FIO names). Crypto settles here.
  3. Create a store at Account → Stores → + Add Store.
  4. Copy the Store Cloud Token + Store Webhook Secret into your env. Use the store-level token, not the account-wide one.
  5. Set the webhook URL as above, then Test Webhook.

License

MIT.

About

U.CASH Pay client for .NET (C#): create crypto + card checkouts and verify settlement webhooks. Non-custodial, zero-dep.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages