Pypaystack2 Package Reference
This is the package-level documentation for the pypaystack2
package.
The pypaystack2
package provides clients for interacting with Paystack's API in your python project
it provides PaystackClient
and AsyncPaystackClient
. The former for working in synchronous contexts
and the latter for working in asynchronous contexts. These two classes are considered the main clients
and provide bindings to other sub-clients as class attributes. E.g. PaystackClient.apple_pay
Subpackages
pypaystack2.sub_clients
: A package containing clients for interacting with specific Paystack's APIpypaystack2.models
: A package containing pydantic model representations of payload and response data the individual models may also be referred to as generic type calledPaystackDataModel
which serves as a placeholder for the models.
Module
pypaystack2.enum
: A module containing enums used package wide.
Example usage:
from pypaystack2 import PaystackClient
from pypaystack2.enums import Country
client = PaystackClient() # Assumes your secret key is set in your environmental variables
# as PAYSTACK_SECRET_KEY. you may also choose to pass the secret key explicitly on instantiation
# of the client. `client = PaystackClient(secret_key='<your-secret-key>')`
# Initializing a transaction
response = client.transactions.initialize(amount=10_000,email="johndoe@example.com")
print(repr(response))
# Get banks
response = client.miscellaneous.get_banks(country=Country.NIGERIA)
print(repr(response))
For more details, refer to the documentation.
AsyncPaystackClient
Bases: BaseAsyncAPIClient
An asynchronous Paystack API client class with all the sub clients supported by pypaystack2.
This class has all the individual sub clients classes like AsyncApplePayClient
, AsyncBulkChargeClient
as bindings to it.
Attributes:
Name | Type | Description |
---|---|---|
apple_pay |
A binding to |
|
bulk_charges |
A binding to |
|
charge |
A binding to |
|
integration |
A binding to |
|
customers |
A binding to |
|
dedicated_accounts |
A binding to |
|
disputes |
A binding to |
|
payment_requests |
A binding to |
|
miscellaneous |
A binding to |
|
payment_pages |
A binding to |
|
plans |
A binding to |
|
products |
A binding to |
|
refunds |
A binding to |
|
settlements |
A binding to |
|
splits |
A binding to |
|
subaccounts |
A binding to |
|
subscriptions |
A binding to |
|
terminals |
A binding to |
|
transactions |
A binding to |
|
transfer_recipients |
A binding to |
|
transfers |
A binding to |
|
transfer_control |
A binding to |
|
verification |
A binding to |
Source code in src/pypaystack2/main_clients.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
PaystackClient
Bases: BaseAPIClient
A Paystack API client class with all the sub clients supported by pypaystack2.
This class has all the individual sub clients classes like ApplePayClient
, BulkChargeClient
as bindings to it.
Attributes:
Name | Type | Description |
---|---|---|
apple_pay |
ApplePayClient
|
A binding to |
bulk_charges |
BulkChargeClient
|
A binding to |
charge |
ChargeClient
|
A binding to |
integration |
IntegrationClient
|
A binding to |
customers |
CustomerClient
|
A binding to |
dedicated_accounts |
DedicatedAccountClient
|
A binding to |
disputes |
DisputeClient
|
A binding to |
payment_requests |
PaymentRequestClient
|
A binding to |
miscellaneous |
MiscellaneousClient
|
A binding to |
payment_pages |
PaymentPageClient
|
A binding to |
plans |
PlanClient
|
A binding to |
products |
ProductClient
|
A binding to |
refunds |
RefundClient
|
A binding to |
settlements |
SettlementClient
|
A binding to |
splits |
TransactionSplitClient
|
A binding to |
subaccounts |
SubAccountClient
|
A binding to |
subscriptions |
SubscriptionClient
|
A binding to |
terminals |
TerminalClient
|
A binding to |
transactions |
TransactionClient
|
A binding to |
transfer_recipients |
TransferRecipientClient
|
A binding to |
transfers |
TransferClient
|
A binding to |
transfer_control |
TransferControlClient
|
A binding to |
verification |
VerificationClient
|
A binding to |
Source code in src/pypaystack2/main_clients.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
sub-clients pypaystack2.sub_clients
- ApplePay & AsyncApplePay
- BulkCharge & AsyncBulkCharge
- Charge & AsyncCharge
- Integration & AsyncIntegration
- Customer & AsyncCustomer
- DedicatedAccount & AsyncDedicatedAccount
- Dispute & AsyncDispute
- PaymentRequest & AsyncPaymentRequest
- Miscellaneous & AsyncMiscellaneous
- PaymentPage & AsyncPaymentPage
- Plan & AsyncPlan
- Product & AsyncProduct
- Refund & AsyncRefund
- Settlement & AsyncSettlement
- Split & AsyncSplit
- SubAccount & AsyncSubAccount
- Subscription & AsyncSubscription
- Terminal & AsyncTerminal
- Transaction & AsyncTransaction
- TransferRecipient & AsyncTransferRecipient
- Transfer & AsyncTransfer
- TransferControl & AsyncTransferControl
- Verification & AsyncVerification
pypaystack2.enums
AccountType
BankType
Bearer
Channel
Bases: StrEnum
Enum of payment channels supported by paystack
Source code in src/pypaystack2/enums.py
Country
Bases: StrEnum
Enum of countries supported by paystack
Source code in src/pypaystack2/enums.py
get_full(value)
staticmethod
Returns paystack supported country name in full lowercase
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The two-digit iso name of the country. |
required |
Returns:
Type | Description |
---|---|
str | None
|
The name of the country in lowercase if it is supported by |
str | None
|
paystack or none. |
Source code in src/pypaystack2/enums.py
Currency
DisputeStatus
Bases: StrEnum
Enum of dispute status supported by paystack
Source code in src/pypaystack2/enums.py
Document
Bases: StrEnum
Enum of Document types supported by paystack
Source code in src/pypaystack2/enums.py
Gateway
Identification
Interval
Bases: StrEnum
Enum of intervals supported by paystack.
Source code in src/pypaystack2/enums.py
Reason
RecipientType
Resolution
RiskAction
Schedule
Split
Status
Bases: StrEnum
Enum of statuses supported by paystack, used by Invoice, Charge & Plan
Source code in src/pypaystack2/enums.py
TerminalEvent
pypaystack2.models
BulkChargeInstruction
Bases: BaseModel
A dataclass for bulk charge instruction.
Attributes:
Name | Type | Description |
---|---|---|
authorization |
str
|
The authorization code of the customer you want to charge. |
amount |
int
|
The amount you want to charge. |
reference |
str
|
The transaction reference. |
Source code in src/pypaystack2/models/payload_models.py
LineItem
Bases: BaseModel
A dataclass for LineItem.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the product. |
amount |
int
|
The price of the product. |
quantity |
int
|
The quantity. |
Source code in src/pypaystack2/models/payload_models.py
Recipient
Bases: BaseModel
A model for representing Transfer Recipients.
Attributes:
Name | Type | Description |
---|---|---|
type |
RecipientType
|
Recipient Type. any value from the |
name |
str
|
A name for the recipient |
account_number |
str
|
Required if |
bank_code |
str | None
|
Required if |
description |
str | None
|
description |
currency |
Currency | None
|
currency |
auth_code |
str | None
|
auth code |
metadata |
dict[str, Any] | None
|
metadata |
Source code in src/pypaystack2/models/payload_models.py
Response
Bases: BaseModel
, Generic[PaystackResponseData]
A pydantic model containing the data gotten from making a request to paystack's API endpoints.
All client methods that make API calls to paystack returns an instance of Response
Attributes:
Name | Type | Description |
---|---|---|
status_code |
HTTPStatus
|
The response status code |
status |
bool
|
A flag for the response status |
message |
str
|
Paystack response message |
data |
PaystackResponseData
|
Data sent from paystack's server if any. This data is of a generic type called |
meta |
dict[str, Any] | None
|
Additional information about the response. |
type |
str | None
|
In cases where the response has a status of |
code |
str | None
|
In cases where the response has a status of |
raw |
dict[str, Any] | list[dict[str, Any]] | bytes | None
|
The original data returned by paystack in native python types i.e. the JSON data returned
from paystack REST APIs have only been converted to dicts or list. This is the same data
that is further extracted into individual fields such as |
Source code in src/pypaystack2/models/response_models.py
SplitAccount
Bases: BaseModel
A dataclass for SplitAccount.
Attributes:
Name | Type | Description |
---|---|---|
subaccount |
str
|
The id of the sub account. |
share |
int | float
|
The share of the split account the sub account should have. |
Source code in src/pypaystack2/models/payload_models.py
Tax
Bases: BaseModel
A dataclass for Tax.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the tax. |
amount |
int
|
The price of the tax. |
Source code in src/pypaystack2/models/payload_models.py
TransferInstruction
Bases: BaseModel
A dataclass for TransferInstruction.
Attributes:
Name | Type | Description |
---|---|---|
amount |
int
|
The amount to be transferred. |
recipient |
str
|
The beneficiary of the transaction. |
reference |
Optional[str]
|
The reference for the transaction. |
reason |
Optional[str]
|
The narration of the transaction. |