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
- Create
Deposit Params - Parameters for creating a deposit
- Create
Withdrawal Params - Parameters for creating a withdrawal
- Deposit
Response - Response from the create deposit endpoint
- Token
- Token information
- Transaction
- Transaction details
- Transaction
Status Response - Response from the transaction status endpoint
- Wallet
Balance Response - Response from the wallet balance endpoint
- Webhook
Handler - Handler for SagaPay webhook notifications
- Webhook
Payload - Webhook payload
- Withdrawal
Response - Response from the create withdrawal endpoint
Enums§
- Address
Type - Address type enum
- Error
- SagaPay error types
- Network
Type - Supported blockchain network types
- Transaction
Status - Transaction status enum
- Transaction
Type - Transaction type enum