Crate rust_paystack

Crate rust_paystack 

Source
Expand description

§Rust Paystack

A Rust library for interacting with the Paystack API.

§Getting Started

Run this command in your project directory:

cargo add rust_paystack
cargo add rust_decimal_macros // for parsing the amount

§Including the Library in Your Project

use rust_paystack::Paystack;

§Creating a New Instance

When creating a new instance, the API key should be passed as a string:

let rust_p = RustPaystack::new("sk_xxxxxxxxxx".to_string());

§Initializing a Transaction

use rust_paystack::Paystack;
use rust_decimal_macros::dec;

#[tokio::main]
async fn main() {
    let rust_p = RustPaystack::new("sk_xxxxxxxxxx".to_string());

    let amount = dec!(10.50); // Amount should be parsed using rust_decimal_macros
    let email = "test@testmail.com";

    let response = rust_p.initialize_transaction(email, amount).await;

    println!("{:?}", response);
}

§Verifying a Transaction

use rust_paystack::Paystack;

#[tokio::main]
async fn main() {
    let rust_p = RustPaystack::new("sk_xxxxxxxxxx".to_string());
    let response = rust_p.verify_payment("reference").await;

    println!("{:?}", response);
}

Structs§

RustPaystack