paystack-client 0.1.0

A simple Rust client for Paystack payments (initialize & verify).
Documentation

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() {
    // Replace with your own test/secret key
    let api = PaystackClient::new("sk_test_xxx");

    let (reference, response) = api.initialize_payment(
        "test@example.com",
        5000.0, // amount in Naira (₦5000.0 -> 500000 kobo)
        "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);
}