paystackpay
A Python wrapper for the Paystack API. Supports both sync and async usage.
Installation
pip install paystackpay
Quickstart
from paystackpay import Paystack
client = Paystack(secret_key="sk_live_...")
# Initialize a transaction
response = client.transactions.initialize(
email="customer@example.com",
amount=100.0, # GHS 100 — pass amounts in major units
currency="GHS",
)
print(response["data"]["authorization_url"])
Async
import asyncio
from paystackpay import AsyncPaystack
async def main():
client = AsyncPaystack(secret_key="sk_live_...")
response = await client.transactions.initialize(
email="customer@example.com",
amount=100.0,
currency="GHS",
)
print(response["data"]["authorization_url"])
asyncio.run(main())
Context managers
# Sync
with Paystack(secret_key="sk_live_...") as client:
client.transactions.list()
# Async
async with AsyncPaystack(secret_key="sk_live_...") as client:
await client.transactions.list()
Amounts
Pass amounts in the major currency unit (e.g. 100.0 = GHS 100 / NGN 100). The library converts to the subunit (pesewas/kobo) before sending to Paystack.
Resources
All resources are available as attributes on the client. Every sync method has an identical async counterpart on AsyncPaystack.
Transactions
client.transactions.initialize(email, amount, currency)
client.transactions.verify(reference)
client.transactions.list()
client.transactions.fetch(transaction_id)
client.transactions.charge_authorization(email, amount, authorization_code, currency)
client.transactions.timeline(id_or_reference)
client.transactions.totals()
client.transactions.export()
client.transactions.partial_debit(authorization_code, email, amount, currency)
Customers
client.customers.create(email, first_name, last_name, phone)
client.customers.list()
client.customers.fetch(email_or_code)
client.customers.update(customer_code, first_name=None, last_name=None, email=None, phone=None)
client.customers.whitelist(customer_code)
client.customers.blacklist(customer_code)
client.customers.deactivate_authorization(authorization_code)
Plans
client.plans.create(name, interval, amount, currency)
client.plans.list()
client.plans.fetch(id_or_code)
client.plans.update(id_or_code, name=None, interval=None, amount=None)
Transfers
client.transfers.initiate(amount, recipient, reason, currency)
client.transfers.finalize(transfer_code, otp)
client.transfers.fetch(id_or_code)
client.transfers.list()
Transfer Recipients
client.transfer_recipients.create(type, name, account_number, bank_code, currency)
client.transfer_recipients.list()
client.transfer_recipients.fetch(id_or_code)
client.transfer_recipients.update(id_or_code, name=None, email=None)
client.transfer_recipients.delete(id_or_code)
Payment Requests
client.payment_requests.create(customer, description, amount, currency)
client.payment_requests.fetch(id_or_code)
client.payment_requests.list()
client.payment_requests.verify(id_or_code)
client.payment_requests.send_notification(id_or_code)
Refunds
client.refunds.create(transaction, amount=None, currency="NGN")
client.refunds.list()
client.refunds.fetch(refund_id)
Subaccounts
client.subaccounts.create(business_name, settlement_bank, account_number, percentage_charge)
client.subaccounts.list()
client.subaccounts.fetch(id_or_code)
client.subaccounts.update(id_or_code, **kwargs)
Webhooks
Verify the x-paystack-signature header on incoming webhook events — no HTTP call made.
payload = request.body # raw bytes
signature = request.headers["x-paystack-signature"]
is_valid = client.webhooks.verify_signature(payload, signature, secret="your_webhook_secret")
if not is_valid:
return HttpResponse(status=400)
Error Handling
All errors are subclasses of PaystackError and carry .message, .status_code, and .raw_response.
from paystackpay import Paystack, AuthenticationError, InvalidRequestError, PaystackError
client = Paystack(secret_key="sk_live_...")
try:
client.transactions.initialize(email="bad", amount=100.0, currency="NGN")
except AuthenticationError as e:
print(f"Bad key: {e.message}")
except InvalidRequestError as e:
print(f"Bad params: {e.message} — {e.raw_response}")
except PaystackError as e:
print(f"Paystack error {e.status_code}: {e.message}")
| Exception | Status code |
|---|---|
AuthenticationError |
401 |
InvalidRequestError |
400 |
NotFoundError |
404 |
RateLimitError |
429 |
APIError |
5xx |
Requirements
- Python 3.10+
httpxpydantic
License
MIT
Metadata
Release files for paystackpay 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| paystackpay-1.0.1.tar.gz | 10.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| paystackpay-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.2 kB
Release files / paystackpay-1.0.1.tar.gz
| Download URL | paystackpay-1.0.1.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6534e818119cbca512723b011767178b22f38cc8eb87caa4de23ebbc048dff3f
|
|
BLAKE2b-256 checksum How to use checksums |
614145bd416d62d217dd69912839be59068c45d44e2bfb20f684095fe3f71ee4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.
Transparency logRelease files / paystackpay-1.0.1-py3-none-any.whl
| Download URL | paystackpay-1.0.1-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7e25bd1426d3ae01b3fabba6f6b7df39922ec85512311680e8e8a0328f01ec9
|
|
BLAKE2b-256 checksum How to use checksums |
a3ac8c74e1dfcc7c3155f8264d1d0e4e0daece87b982dc22a200b977e5d3456e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.
Transparency log