Expand description
Convenient 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.
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
Initializing an instance of the Paystack client and creating a transaction.
use std::env;
use dotenv::dotenv;
use paystack::{PaystackClient, InitializeTransactionBodyBuilder, Error, Currency, Channel};
#[tokio::main]
async fn main() -> Result<(), Error>{
dotenv().ok();
let api_key = env::var("PAYSTACK_API_KEY").unwrap();
let client = PaystackClient::new(api_key);
let body = InitializeTransactionBodyBuilder::default()
.amount("10000".to_string())
.email("email@example.com".to_string())
.currency(Some(Currency::NGN))
.channels(Some(vec![
Channel::ApplePay,
Channel::Bank,
Channel::BankTransfer
]))
.build()
.unwrap();
let transaction = client
.transaction
.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. The struct is constructed using the
ChargeBodyBuilder
- Builder for
ChargeBody
. - This struct is used to create the body for creating a subaccount on your integration.
- Builder for
CreateSubaccountBody
. - Represents the JSON response for subaccount creation.
- This struct is used to create a split payment on your integration. The struct is constructed using the
CreateTransactionSplitBodyBuilder
- Builder for
CreateTransactionSplitBody
. - This struct represents the Paystack customer data
- Export transaction response data.
- Represents the response of the export transaction.
- Represents the JSON response for fetch subaccount.
- This struct is used to create a transaction body for creating a transaction using the Paystack API. This struct should be created using the
InitializeTransactionBodyBuilder
The Builder derivation allows for the automatic implementation of the builder pattern. - Builder for
InitializeTransactionBody
. - Response from List Subaccount route
- MetaData of list response
- This struct is used to create a partial debit transaction body for creating a partial debit using the Paystack API. This struct should be created using the
PartialDebitTransactionBodyBuilder
The derive Builder allows for the automatic creation of the BuilderPattern - Builder for
PartialDebitTransactionBody
. - Represents the response 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.
- Represents the JSON response of the Paystack API when there is no data property
- Represents the percentage split data received in the JSON response.
- A struct to hold all functions in the subaccount API route
- This struct represents the subaccount. It can be used as the payload for the API end points that require a subaccount as a payload. It is also possible to extract a single field from this struct to use as well. The Struct is constructed using the
SubaccountBuilder
- Builder for
SubaccountBody
. - Represents the data of th Subaccounts
- Data of the list Subaccount response
- A Struct to hold all the functions of the transaction API route
- This struct represents the transaction history data
- This struct represents the response of the Paystack transaction initialization.
- This struct represents the data of the transaction response.
- A struct to hold all the functions of the transaction split API route
- Represents the JSON response containing percentage split information.
- Represents the JSON response containing percentage split information.
- 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.
- Represents the response of the total amount received on your account
- This struct is used to update a transaction split details on your integration. The struct is constructed using the
UpdateTransactionSplitBodyBuilder
- Builder for
UpdateTransactionSplitBody
. - Transaction volume by currency.
Enums
- Represents the type of bearer for a charge.
- Represents the payment channels supported by Paystack.
- Error type for ChargeBodyBuilder
- Error type for CreateSubaccountBodyBuilder
- Error type for CreateTransactionSplitBodyBuilder
- Represents different currencies supported by the Paystack API.
- Custom Error for the Paystack API
- Error type for InitializeTransactionBodyBuilder
- Error type for PartialDebitTransactionBodyBuilder
- Represents the type of transaction split.
- Represents the status of a transaction.
- Error type for SubaccountBodyBuilder
- Error type for UpdateTransactionSplitBodyBuilder
Functions
- A function for sending DELETE requests to a specified url using the reqwest client.
- A function for sending GET request to a specified url with optional query parameters using reqwest client.
- A function for sending POST requests to a specified url using the reqwest client.
- A function for sending PUT requests to a specified url using the reqwest client.
Type Aliases
- Custom result type for the Paystack API