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.
- The
ChargeBuilderstruct provides a convenient way to construct a charge object with optional fields. Each field can be set individually using the builder’s methods. Once all the desired fields are set, thebuildmethod can be called to create an instance of theChargestruct. - This struct represents the Paystack customer data
- Export transaction response data.
- Represents the response of the export transaction.
- 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
- 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.
- A builder pattern implementation for constructing
PercentageSplitinstances. - Wrapper type which contains a failed request’s status code and body
- Represents the JSON response of the Paystack API when there is no data property
- Represents the percentage split data received in the JSON response.
- This struct represents the subacount that bears the transaction split
- Represents the data of th Subaccounts
- Represents a subaccount in the percentage split data.
- 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 is used to create a split payment on your integration.
- 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
- Transaction volume by currecny.
Enums
- Represents the type of bearer for a charge.
- Represents the payment channels supported by Paystack.
- Represents different currencies supported by the Paystack API.
- Custom Error for the Paystack API
- Represents the type of transaction split.
- Represents the status of a transaction.
Type Definitions
- Custom result type for the Paystack API