Crate paystack

Source
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).

Modules§

bearer
Bearer Type
channel
Channel
charge
Charge
currency
Currency
customers
Customers
generic
Generic Model
split
Split Type
status
Status
subaccounts
Subaccounts
terminal
Terminal Models
transaction_split
Transaction Splits Models
transactions
Transactions Models

Structs§

Authorization
This struct represents the authorization data of the transaction status response
ChargeBody
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
ChargeBodyBuilder
Builder for ChargeBody.
CreateSubaccountBody
This struct is used to create the body for creating a subaccount on your integration.
CreateSubaccountBodyBuilder
Builder for CreateSubaccountBody.
CreateSubaccountResponse
Represents the JSON response for subaccount creation.
CreateTransactionSplitBody
This struct is used to create a split payment on your integration. The struct is constructed using the CreateTransactionSplitBodyBuilder
CreateTransactionSplitBodyBuilder
Builder for CreateTransactionSplitBody.
Customer
This struct represents the Paystack customer data
DeleteSubAccountBody
This struct is used to create the body for deleting a subaccount on your integration.
EventData
The data about the event to send to the API. For the invoice type, you need to pass the invoice id and offline reference: {id: invoice_id, reference: offline_reference}. For the transaction type, you can pass the transaction id: {id: transaction_id}`
ExportTransactionData
Export transaction response data.
ExportTransactionResponse
Represents the response of the export transaction.
FetchEventStatusResponse
This struct represents the response for checking the status of an event sent to the Terminal
FetchEventStatusResponseData
This struct represents the data of the event status
FetchSubaccountResponse
Represents the JSON response for fetch subaccount.
FetchTerminalResponse
This struct represents the response for fetch terminal.
FetchTerminalResponseData
Response Data for Fetch Terminal Route
FetchTerminalStatusResponse
This struct represents the response for checking the status of an event sent to the Terminal
FetchTerminalStatusResponseData
This struct represents the data of the event status
InitializeTransactionBody
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.
InitializeTransactionBodyBuilder
Builder for InitializeTransactionBody.
ListSubaccountsResponse
Response from List Subaccount route
MetaData
MetaData of list response
PartialDebitTransactionBody
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
PartialDebitTransactionBodyBuilder
Builder for PartialDebitTransactionBody.
PartialDebitTransactionResponse
Represents the response of the partial debit transaction.
PaystackClient
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.
ResponseWithoutData
Represents the JSON response of the Paystack API when there is no data property
SendEventBody
This struct is used to create an event body for sending an event to the paystack Terminal using the Paystack API. This struct should be created using the SendEventBodyBuilder The Builder derivation allows for the automatic implementation of the builder
SendEventBodyBuilder
Builder for SendEventBody.
SendEventResponse
This struct represents the response of sending an event to the terminal.
SendEventResponseData
This struct represents the data of the event response.
SplitData
Represents the percentage split data received in the JSON response.
SubaccountBody
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
SubaccountBodyBuilder
Builder for SubaccountBody.
SubaccountData
Represents the data of th Subaccounts
SubaccountEndpoints
A struct to hold all functions in the subaccount API route
SubaccountsResponseData
Data of the list Subaccount response
TerminalEndpoints
A Struct to hold all the functions of the terminal API route
TerminalResponseWithNoData
Response of updating the terminal data
TransactionEndpoints
A Struct to hold all the functions of the transaction API route
TransactionHistoryResponse
This struct represents the transaction history data
TransactionResponse
This struct represents the response of the Paystack transaction initialization.
TransactionResponseData
This struct represents the data of the transaction response.
TransactionSplitEndpoints
A struct to hold all the functions of the transaction split API route
TransactionSplitListResponse
Represents the JSON response containing percentage split information.
TransactionSplitResponse
Represents the JSON response containing percentage split information.
TransactionStatusData
This struct represents the data of the transaction status response.
TransactionStatusListResponse
This struct represents a list of transaction status.
TransactionStatusResponse
This struct represents the transaction status response.
TransactionTimelineData
This struct represents the transaction timeline data.
TransactionTimelineResponse
This struct represents the transaction timeline.
TransactionTotalData
Transaction total data.
TransactionTotalsResponse
Represents the response of the total amount received on your account
UpdateTerminalBody
The terminal update information to send to the API.
UpdateTerminalBodyBuilder
Builder for UpdateTerminalBody.
UpdateTransactionSplitBody
This struct is used to update a transaction split details on your integration. The struct is constructed using the UpdateTransactionSplitBodyBuilder
UpdateTransactionSplitBodyBuilder
Builder for UpdateTransactionSplitBody.
VolumeByCurrency
Transaction volume by currency.

Enums§

ActionType
Represents the different action the Terminal needs to perform.
BearerType
Represents the type of bearer for a charge.
Channel
Represents the payment channels supported by Paystack.
ChargeBodyBuilderError
Error type for ChargeBodyBuilder
CreateSubaccountBodyBuilderError
Error type for CreateSubaccountBodyBuilder
CreateTransactionSplitBodyBuilderError
Error type for CreateTransactionSplitBodyBuilder
Currency
Represents different currencies supported by the Paystack API.
Error
Custom Error for the Paystack API
EventType
Represents the different terminal event types supported by the Paystack API.
InitializeTransactionBodyBuilderError
Error type for InitializeTransactionBodyBuilder
PartialDebitTransactionBodyBuilderError
Error type for PartialDebitTransactionBodyBuilder
SendEventBodyBuilderError
Error type for SendEventBodyBuilder
SplitType
Represents the type of transaction split.
Status
Represents the status of a transaction.
SubaccountBodyBuilderError
Error type for SubaccountBodyBuilder
UpdateTerminalBodyBuilderError
Error type for UpdateTerminalBodyBuilder
UpdateTransactionSplitBodyBuilderError
Error type for UpdateTransactionSplitBodyBuilder

Functions§

delete_request
A function for sending DELETE requests to a specified url using the reqwest client.
get_request
A function for sending GET request to a specified url with optional query parameters using reqwest client.
post_request
A function for sending POST requests to a specified url using the reqwest client.
put_request
A function for sending PUT requests to a specified url using the reqwest client.

Type Aliases§

PaystackResult
Custom result type for the Paystack API