Skip to content

abrishk26/chapa-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chapa_rust

An asynchronous, type-safe Rust SDK for the Chapa payment gateway.

With chapa_rust, you integrate payments without worrying about raw HTTP requests, JSON parsing, or error string matching. Instead, you get an ergonomic, strongly-typed API designed for async Rust.

Features

  • Async, non-blocking requests (powered by [tokio] and [reqwest])
  • Idiomatic Rust builders and result types
  • Typed error handling (no more guessing from error messages)
  • Supports transactions, verification, transfers, subaccounts, and bank lookup

Example

use chapa_rust::{Chapa, transaction::TransactionBuilder};
use chapa_rust::types::Currency;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let chapa = Chapa::new("your_api_key")?;

    let tx = TransactionBuilder::new(100)
        .currency(Currency::ETB)
        .first_name("Abreham")
        .last_name("Kassa")
        .email("test@example.com")
        .tx_ref("unique_ref")
        .build();

    let initialized = chapa.initialize(tx).await?;
    println!("Payment URL: {}", initialized.data.checkout_url);

    let verified = chapa.verify_transaction("unique_ref").await?;
    println!("Verified: {:?}", verified.status);

    Ok(())
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages