Skip to content

Marfusios/btcpayserver-client

Repository files navigation

Logo

BTCPay Server client Build Status NuGet version Nuget downloads

This is a C# client for BTCPayServer. Taken from official repository and bundled into Nuget package.

[WIP] Not yet ready!

Releases and breaking changes

License:

MIT

Features

  • installation via NuGet (BTCPayServer.Client)
  • targeting .NET Standard 2.0 (.NET Core, Linux/MacOS compatible)

Usage (legacy API)

  • Server side:
// create an invoice

var client = new BTCPayServerClientLegacy(new Uri("https://btcpay.yourserver.com"), "legacy_api_key");

var invoice = await client.CreateInvoice(new InvoiceRequestLegacy()
{
    Currency = "USD",
    Price = 100m,
    ItemDesc = "Payment for my_store_order",
    OrderId = "my_store_order::xxxyyy",
    NotificationUrl = new Uri("https://webhook.site/03b96bf0-dbd3-4da0-b3d1-54aa5e7f794c"),
    RedirectUrl = new Uri("https://webhook.site/03b96bf0-dbd3-4da0-b3d1-54aa5e7f794c")
});


// getting an invoice by id
// you have to also specify a token (don't really know why :( )

var invoiceId = invoice.Id;
var invoiceToken = invoice.Token;
var existingInvoice = await client.GetInvoice(invoiceId, invoiceToken);
  • Client side:
// display a checkout modal with created invoice id from the previous step

<script src ="https://your.btcpay.url/modal/btcpay.js"></script>
window.btcpay.showInvoice(invoiceId);


// event listeners

window.btcpay.onModalWillEnter(yourCallbackFunction);
window.btcpay.onModalWillLeave(yourCallbackFunction);

Usage (new API)

  • Not implemented on BTCPay Server yet

More usage examples:

  • console sample (link)

Pull Requests are welcome!


Available for help

I do consulting, please don't hesitate to contact me if you have a custom solution you would like me to implement (web, [email protected])

Donations gratefully accepted.

  • Donate with Bitcoin
  • Donate with Litecoin
  • Donate with Ethereum