Convenient Async rust bindings and types for the Paystack HTTP API aiming to support the entire API surface. Not the case? Please open an issue. I update the definitions on a weekly basis.
The client current covers the follow section of the API:
See the Rust API docs or the examples.
paystack-rs
uses the reqwest
http client under the hood and the tokio
runtime for async operations.
toml
[dependencies]
paystack-rs = "0.1"
You can also download the source code and use in your code base directly if you prefer.
Initalizing an instance of the Paystack client and creating a transaction.
```rust use std::env; use dotenv::dotenv; use paystack::{PaystackClient, TransactionBuilder, PaystackError};
#[tokio::main]
async fn main() -> Result<(), PaystackError>{
dotenv().ok()
let api_key = env::var("PAYSTACK_API_KEY").unwrap();
let client = PaystackClient::new(api_key);
let body = TransactionBuilder::new()
.email("email@example.com")
.amount("200000")
.currency(Currency::NGN)
.channels(vec![Channel::Qr, Channel::Ussd, Channel::BankTransfer])
.build()
.unwrap();
let transaction = client
.initialize_transaction(body)
.await
.expect("Unable to create transaction");
Ok(())
}
```
See CONTRIBUTING.md for information on contributing to paystack-rs.
Licensed under MIT license (LICENSE-MIT).