Expand description
Convenient rust bindings and types for the Paystakc HTTP API aiming to support the entire API surface. Not the case? Please open an issue. I update the definitions on a weekly basis.
Documentation
See the Rust API docs or the examples.
Installation
paystack-rs
uses the reqwest
http client under the hood and the tokio
runtime for async operations
[dependencies]
paystack-rs = "0.1"
Usage
Initalizing an instance of the Paystack client and creating a transaction.
use std::env;
use dotenv::dotenv;
use paystack::{PaystackClient, TransactionBuilder, PaystackError, Currency};
#[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)
.build()
.unwrap();
let transaction = client
.initialize_transaction(body)
.await
.expect("Unable to create transaction");
Ok(())
}
Contributing
See CONTRIBUTING.md for information on contributing to paystack-rs.
Licensed under MIT license (LICENSE-MIT).
Structs
- This struct represents the authorization data of the transaction status response
- This struct is used to create a charge body for creating a Charge Authorization using the Paystack API.
- Builder for the Charge object
- This struct represents the Paystack customer data
- Export transaction response data.
- Result of the export transaction information.
- This struct represents the mata data of the response.
- This struct is used to create a partial debit transaction body for creating a partial debit using the Paystack API.
- Builder for the Transaction object
- Result of the partial debit transaction.
- This is the struct that allows you to authenticate to the PayStack API. It contains the API key which allows you to interact with the API.
- Wrapper type which contains a failed request’s status code and body
- This struct represents the transaction history data
- This struct is used to create a transaction body for creating a transaction using the Paystack API.
- Builder for the Transaction object
- This struct represents the response of the Paystack transaction initalization.
- This struct represents the data of the transaction response.
- This struct represents the transaction status response.
- This struct represents the data of the transaction status response.
- This struct represents a list of transaction status.
- This struct represents the transaction timeline.
- This struct represents the transaction timeline data.
- Transaction total data.
- Total amount received on your account
- Transaction volume by currecny.
Enums
- Represents the payment channels supported by Paystack
- Respresents the currencies supported by Paystack
- Custom Error for the Paystack API
- Represents the status of the Transaction.
Type Definitions
- Custom result type for the Paystack API