Crate crypto_pay_api

Source
Expand description

crypto-pay-api

A Rust client library for interacting with the CryptoPay API.

§Example with tokio

use crypto_pay_api::prelude::*;

#[tokio::main]
async fn main() -> Result<(), CryptoBotError> {
    let client = CryptoBot::builder().api_token("YOUR_API_TOKEN").build()?;
    let params = CreateInvoiceParamsBuilder::new().amount(dec!(10.0)).asset(CryptoCurrencyCode::Ton).build(&client).await?;
    let invoice = client.create_invoice(&params).await?;
    println!("Invoice created: {}", invoice.invoice_id);
    Ok(())
}

§Webhook Handling with axum

use crypto_pay_api::prelude::*;

#[tokio::main]
async fn main() -> Result<(), CryptoBotError> {
    let client = CryptoBot::builder().api_token("YOUR_API_TOKEN").build()?;
    let mut handler = client.webhook_handler(WebhookHandlerConfigBuilder::new().build());
    handler.on_update(|update| async move {
        println!("Invoice paid: {:?}", update.payload);
        Ok(())
    });
    Ok(())
}

For issues and contributions, please refer to the GitHub repository.

Modules§

prelude

Macros§

validate_dependency