Skip to main content

Crate sagapay_sdk

Crate sagapay_sdk 

Source
Expand description

§SagaPay Rust SDK

This crate provides a Rust interface to the SagaPay blockchain payment gateway API. SagaPay is the world’s first free, non-custodial blockchain payment gateway service provider.

§Example

use sagapay::{Client, Config, CreateDepositParams, NetworkType};

#[tokio::main]
async fn main() -> Result<(), sagapay::Error> {
    // Initialize the SagaPay client
    let client = Client::new(Config {
        api_key: "your-api-key".to_string(),
        api_secret: "your-api-secret".to_string(),
        ..Config::default()
    });

    // Create a deposit address
    let deposit = client.create_deposit(CreateDepositParams {
        network_type: NetworkType::BEP20,
        contract_address: "0".to_string(), // '0' for native tokens (BNB)
        amount: "1.5".to_string(),
        ipn_url: "https://example.com/webhook".to_string(),
        udf: Some("order-123".to_string()),
        address_type: Some("TEMPORARY".to_string()),
    }).await?;

    println!("Deposit address: {}", deposit.address);
    println!("Expires at: {}", deposit.expires_at);

    Ok(())
}

Structs§

Balance
Balance information
Client
SagaPay API client
Config
Configuration for the SagaPay client
CreateDepositParams
Parameters for creating a deposit
CreateWithdrawalParams
Parameters for creating a withdrawal
DepositResponse
Response from the create deposit endpoint
Token
Token information
Transaction
Transaction details
TransactionStatusResponse
Response from the transaction status endpoint
WalletBalanceResponse
Response from the wallet balance endpoint
WebhookHandler
Handler for SagaPay webhook notifications
WebhookPayload
Webhook payload
WithdrawalResponse
Response from the create withdrawal endpoint

Enums§

AddressType
Address type enum
Error
SagaPay error types
NetworkType
Supported blockchain network types
TransactionStatus
Transaction status enum
TransactionType
Transaction type enum