GitHub Nuget Static Badge GitHub Actions Workflow Status NuGet version (CryptoPay.NET) CodeFactor GitHub repo size
.NET Standard cryptocurrency payment library for Telegram bot @cryptobot.
Note: This repository was cloned because the original author irresponsibly corrupted his code.
- Install the NuGet package:
dotnet add package CryptoPay.NET
- Create a new instance of the
CryptoPayClientclass:
const string apiKey = "your-api-key"; var client = new CryptoPayClient(apiKey); // or with custom base URL var client = new CryptoPayClient(apiKey, apiUrl: "https://testnet-pay.crypt.bot/");
- Create an invoice
var invoice = await client.CreateInvoiceAsync( Assets.BNB, 1.1, description: "test", paid_btn_name: PaidButtonNames.viewItem, paid_btn_url: "https://example.com/success", cancellationToken: cancellationToken);
- Get an invoice and handle the payment
while (true) { var invoices = await client.GetInvoicesAsync(invoiceIds: new[] { invoice.Id }); var invoice = invoices.Items.FirstOrDefault(); if (invoice == null) { continue; } if (invoice.Status == CryptoPay.Types.Statuses.paid) { // Invoice is paid HandlePaidInvoice(invoice); break; } await Task.Delay(1000); } void HandlePaidInvoice(Invoice invoice) { // Handle paid invoice }
This project is licensed under the MIT License - see the LICENSE.md file for details.