Paystack Client (Rust)
A lightweight, async Rust client for interacting with the Paystack API.
This crate provides helpers for initializing and verifying payments using reqwest and tokio.
✨ Features
- Initialize a Paystack payment
- Generate unique payment references
- Verify payment status
- Async-first (
tokio + reqwest)
Instalation
cargo add paystack-client
Usage
initialize payment
use paystack_client::PaystackClient;
#[tokio::main]
async fn main() {
let api = PaystackClient::new("sk_test_xxx");
let (reference, response) = api.initialize_payment(
"test@example.com",
5000.0, "http://localhost/callback",
)
.await
.expect("Failed to initialize payment");
println!("Generated reference: {}", reference);
println!("Paystack response: {:#?}", response);
}
verify payment
use paystack_client::PaystackClient;
#[tokio::main]
async fn main() {
let api = PaystackClient::new("sk_test_xxx");
let reference = "SOME-UNIQUE-REFERENCE";
let verification = api.verify_payment(reference)
.await
.expect("Failed to verify payment");
println!("Verification result: {:#?}", verification);
}