CryptoPay 1.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CryptoPay --version 1.4.0                
NuGet\Install-Package CryptoPay -Version 1.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CryptoPay" Version="1.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CryptoPay --version 1.4.0                
#r "nuget: CryptoPay, 1.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CryptoPay as a Cake Addin
#addin nuget:?package=CryptoPay&version=1.4.0

// Install CryptoPay as a Cake Tool
#tool nuget:?package=CryptoPay&version=1.4.0                

CryptoPay package NuGet downloads Bot API Version documentations

.NET Client for CryptoPay by @CryptoBot

Crypto Pay is a payment system based on @CryptoBot, which allows you to accept payments in cryptocurrency using the API.

This .NET library help you to work with Crypto Pay via Crypto Pay API.

Install

Use the nuget package.

Usage

API

First, you need to create your application and get an API token. Open @CryptoBot or @CryptoTestnetBot (for testnet), send a command /pay to create a new app and get API Token.

Don't forget to configure the ApiUrl and your CryptoPayApiToken:

builder.Services.AddHttpClient<ICryptoPayClient, CryptoPayClient>(client =>
{
  client.BaseAddress = new Uri("https://pay.crypt.bot/");
  client.DefaultRequestHeaders.Add("Crypto-Pay-API-Token", "token");
});

Next step: try to call a simple GetMeAsync(...) method to check that everything is working well:

var application = await cryptoPayClient.GetMeAsync(cancellationToken);
Net Bot Hostname
mainnet @CryptoBot https://pay.crypt.bot/
testnet @CryptoTestnetBot https://testnet-pay.crypt.bot/

All queries to the Crypto Pay API must be sent over HTTPS

You can find all available methods in the documentation.

Also, you can create invoice with supported assets and paid button names:

var invoice = await cryptoPayClient.CreateInvoiceAsync(
    Assets.BNB,
    1.505,
    description: "kitten",
    paid_btn_name: PaidButtonNames.viewItem,
    paid_btn_url: "https://placekitten.com/150",
    cancellationToken: cancellationToken);

Webhooks

Use Webhooks to get updates for the app.

If you'd like to make sure that the Webhook request comes from Crypto Pay, we recommend using a secret path in the URL, e.g. https://www.example.com/<secret>.

Webhooks will send may at least one time

Example endpoint. You should use CryptoPayHelper.CheckSignature(...) to check signature from crypto-pay-api-signature

[HttpPost("{token}")]
public async Task<IActionResult> PostAsync(
    [FromBody] Update update, 
    string token, 
    CancellationToken cancellationToken = default)
{
    if (update is not null &&
        this.HttpContext.Request.Headers.TryGetValue("crypto-pay-api-signature", out var signature) &&
        CryptoPayHelper.CheckSignature(signature, token, update) &&
        update.UpdateType == UpdateTypes.invoice_paid)
    {
        return this.Ok();
    }

    return this.BadRequest();
}

Explore all available methods from the documentation.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.0 357 9/30/2024
1.4.0 483 8/21/2024
1.2.0.3 910 2/23/2024
1.2.0.2 134 2/12/2024
1.2.0.1 128 2/2/2024
1.2.0 198 12/26/2023
1.1.3.6 309 9/20/2023
1.1.3.5 208 6/5/2023
1.1.3.4 178 6/5/2023
1.1.3.3 460 2/16/2023
1.1.3.2 424 11/21/2022
1.1.3.1 402 10/17/2022
1.1.3 434 8/10/2022
1.1.2 507 4/7/2022
1.1.1 433 4/6/2022
1.1.0 435 4/6/2022