pypaystack2 3.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pypaystack2-3.1.0/PKG-INFO +149 -0
- pypaystack2-3.1.0/README.md +128 -0
- pypaystack2-3.1.0/pyproject.toml +62 -0
- pypaystack2-3.1.0/src/pypaystack2/__init__.py +58 -0
- pypaystack2-3.1.0/src/pypaystack2/_metadata.py +5 -0
- pypaystack2-3.1.0/src/pypaystack2/base_clients.py +396 -0
- pypaystack2-3.1.0/src/pypaystack2/cli.py +21 -0
- pypaystack2-3.1.0/src/pypaystack2/enums.py +220 -0
- pypaystack2-3.1.0/src/pypaystack2/exceptions.py +14 -0
- pypaystack2-3.1.0/src/pypaystack2/fees_calculation_mixin.py +350 -0
- pypaystack2-3.1.0/src/pypaystack2/main_clients.py +245 -0
- pypaystack2-3.1.0/src/pypaystack2/models/__init__.py +171 -0
- pypaystack2-3.1.0/src/pypaystack2/models/payload_models.py +181 -0
- pypaystack2-3.1.0/src/pypaystack2/models/response_models.py +859 -0
- pypaystack2-3.1.0/src/pypaystack2/py.typed +0 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/__init__.py +102 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/__init__.py +59 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/apple_pay.py +143 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/bulk_charges.py +257 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/charge.py +320 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/customers.py +367 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/dedicated_accounts.py +467 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/disputes.py +382 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/integration.py +80 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/miscellaneous.py +150 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/payment_pages.py +288 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/payment_requests.py +438 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/plans.py +240 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/products.py +231 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/refunds.py +159 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/settlements.py +116 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/splits.py +300 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/subaccounts.py +251 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/subscriptions.py +301 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/terminals.py +343 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/transactions.py +556 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/transfer_recipients.py +295 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/transfers.py +274 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/transfers_control.py +228 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/async_clients/verification.py +155 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/__init__.py +55 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/apple_pay.py +148 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/bulk_charges.py +257 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/charge.py +320 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/customers.py +366 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/dedicated_accounts.py +467 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/disputes.py +385 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/integration.py +80 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/miscellaneous.py +150 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/payment_pages.py +288 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/payment_requests.py +439 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/plans.py +240 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/products.py +231 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/refunds.py +159 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/settlements.py +115 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/splits.py +301 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/subaccounts.py +251 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/subscriptions.py +301 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/terminals.py +342 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/transactions.py +558 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/transfer_recipients.py +298 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/transfers.py +275 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/transfers_control.py +228 -0
- pypaystack2-3.1.0/src/pypaystack2/sub_clients/sync_clients/verification.py +155 -0
- pypaystack2-3.1.0/src/pypaystack2/types.py +13 -0
- pypaystack2-3.1.0/src/pypaystack2/utils.py +32 -0
- pypaystack2-3.1.0/src/pypaystack2/webhook/__init__.py +0 -0
- pypaystack2-3.1.0/src/pypaystack2/webhook/cli.py +267 -0
- pypaystack2-3.1.0/src/pypaystack2/webhook/enums.py +28 -0
- pypaystack2-3.1.0/src/pypaystack2/webhook/logging_config.py +51 -0
- pypaystack2-3.1.0/src/pypaystack2/webhook/models.py +45 -0
- pypaystack2-3.1.0/src/pypaystack2/webhook/webhook_proxy_server.py +129 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pypaystack2
|
|
3
|
+
Version: 3.1.0
|
|
4
|
+
Summary: A developer-friendly client library for Paystack
|
|
5
|
+
Keywords: paystack-python,pypaystack,paystack,paystackapi
|
|
6
|
+
Author: Gbenga Adeyi
|
|
7
|
+
Author-email: Gbenga Adeyi <adeyigbenga005@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Dist: httpx>=0.28.1
|
|
13
|
+
Requires-Dist: pydantic>=2.12.5
|
|
14
|
+
Requires-Dist: fastapi[standard]>=0.123.10 ; extra == 'webhook'
|
|
15
|
+
Requires-Dist: ngrok>=1.4.0 ; extra == 'webhook'
|
|
16
|
+
Requires-Dist: python-dotenv>=1.2.1 ; extra == 'webhook'
|
|
17
|
+
Requires-Dist: typer-slim[standard]>=0.20.0 ; extra == 'webhook'
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Provides-Extra: webhook
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# PyPaystack2
|
|
23
|
+
|
|
24
|
+
[](https://pepy.tech/project/pypaystack2)
|
|
25
|
+
[](https://pepy.tech/project/pypaystack2)
|
|
26
|
+
[](https://pepy.tech/project/pypaystack2)
|
|
27
|
+
|
|
28
|
+
PyPaystack2 is an Open Source Python client library for integrating [Paystack](https://paystack.com/) into your python
|
|
29
|
+
projects. It aims at being developer friendly and easy to use.
|
|
30
|
+
|
|
31
|
+
**Version 3 is here now**
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- 1st class support for type annotations.
|
|
36
|
+
- Synchronous and Asynchronous clients.
|
|
37
|
+
- Pydantic for data modelling.
|
|
38
|
+
- Fees Calculation utilities.
|
|
39
|
+
- Webhook support & utilities (>= v3.1.0).
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
$ pip install -U pypaystack2
|
|
45
|
+
# or install with uv
|
|
46
|
+
$ uv add pypaystack2
|
|
47
|
+
# For webhook cli
|
|
48
|
+
$ pip install -U "pypaystack2[webhook]"
|
|
49
|
+
or install with uv
|
|
50
|
+
$ uv add "pypaystack2[webhook"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage Preview
|
|
54
|
+
|
|
55
|
+
In the REPL session below, we're using PyPaystack2 to create a `Customer` (user) and a `Plan` on
|
|
56
|
+
[Paystack](https://paystack.com/) and then add the newly created customer as a subscriber to the plan.
|
|
57
|
+
|
|
58
|
+
### Note
|
|
59
|
+
|
|
60
|
+
The REPL session below assumes the environmental variable `PAYSTACK_SECRET_KEY="YOUR_SECRET_KEY"` is set. if not,
|
|
61
|
+
you can alternatively pass it into the `PaystackClient` on instantiation like so
|
|
62
|
+
`PaystackClient(secret_key='YOUR_SECRET_KEY')` otherwise, you will get a `MissingSecretKeyException` raised prompting
|
|
63
|
+
you to provide a secret key. It also does not handle likely exceptions that calling client methods like
|
|
64
|
+
`client.customers.create`, `client.plans.create` & `client.subscriptions.create` may raise like `ClientNetworkError`
|
|
65
|
+
for network related issues and `ValueError` for validation related issues.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
Python 3.11.13 (main, Sep 2 2025, 14:20:25) [Clang 20.1.4 ] on linux
|
|
69
|
+
Type "help", "copyright", "credits" or "license" for more information.
|
|
70
|
+
>>> from pypaystack2 import __version__
|
|
71
|
+
>>> print(__version__)
|
|
72
|
+
3.0.0 # Ensure you're running PyPaystack2 version >= 3.0.0 for the following entries to work
|
|
73
|
+
>>> from pypaystack2 import PaystackClient
|
|
74
|
+
>>> from pypaystack2.enums import Interval
|
|
75
|
+
>>> from pypaystack2.models import Customer, Plan
|
|
76
|
+
>>> client = PaystackClient()
|
|
77
|
+
>>> new_customer_response = client.customers.create(email="johndoe@example.com",first_name="John",last_name="Doe")
|
|
78
|
+
>>> assert new_customer_response.status # Validating the request is successful
|
|
79
|
+
>>> new_customer = new_customer_response.data
|
|
80
|
+
>>> assert isinstance(new_customer,Customer) # Showing that we indeed get an instance of a pydantic model name `Customer` a modelled representation of the data returned by paystack as a result of the request to create a new user
|
|
81
|
+
>>> new_plan_response = client.plans.create(name="Test 1k Daily Contributions", amount=client.to_subunit(1000), interval=Interval.DAILY)
|
|
82
|
+
>>> assert new_plan_response.status # Validating the request is successful
|
|
83
|
+
>>> new_plan = new_plan_response.data # Validating the request is successful
|
|
84
|
+
>>> assert isinstance(new_plan,Plan)
|
|
85
|
+
>>> new_subscription_response = client.subscriptions.create(customer=new_customer.customer_code,plan=new_plan.plan_code)
|
|
86
|
+
>>> assert new_subscription_response.status == True # Validating the request is successful
|
|
87
|
+
>>> print(repr(new_subscription_response))
|
|
88
|
+
Response(
|
|
89
|
+
status_code=<HTTPStatus.OK: 200>,
|
|
90
|
+
status=True,
|
|
91
|
+
message='Subscription successfully created',
|
|
92
|
+
data=Subscription(
|
|
93
|
+
customer=87934333,
|
|
94
|
+
plan=2237384,...
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Webhook
|
|
98
|
+
|
|
99
|
+
PyPaystack2 now supports verifying the authenticity of a webhook payload and a CLI to make working with webhooks locally
|
|
100
|
+
seamless
|
|
101
|
+
|
|
102
|
+
#### Verifying a webhook payload
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
Python 3.11.13 (main, Sep 2 2025, 14:20:25) [Clang 20.1.4 ] on linux
|
|
106
|
+
Type "help", "copyright", "credits" or "license" for more information.
|
|
107
|
+
>>> from pypaystack2 import PaystackClient
|
|
108
|
+
>>> client = PaystackClient()
|
|
109
|
+
>>> payload = ... # webhook payload e.g., b'{"event": "customeridentification.success", "data": {"customer_id": 324345768, "customer_code": "CUS_e7urjebaoyk1ze2", "email": "jddae8446e-e54c-42ab-bf37-e5abff14527e@example.com", "identification": {"country": "NG", "type": "bank_account", "bvn": "123*****543", "account_number": "342****22", "bank_code": "121"}}}'
|
|
110
|
+
>>> signature = ... # x-paystack-signature e.g., "5d049eb93c7c71fa098f5215d7297bda401710b62df8b392b9052adf8d1a02ff308f6ca57a1db14ffeabd5b66264e9c42de029b7067b9c71eb9c231fb2a8e383"
|
|
111
|
+
>>> is_verified_webhook_payload = client.is_verified_webhook_payload(payload,signature)
|
|
112
|
+
>>> print(is_verified_webhook_payload)
|
|
113
|
+
True
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Forward webhook events from paystack to your app running locally
|
|
117
|
+
|
|
118
|
+
**Note:** This requires that you install `pypaystack2[webhook]`
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pypaystack2 webhook start-tunnel-server --addr localhost:8000 --ngrok-auth-token
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Documentation
|
|
125
|
+
|
|
126
|
+
See [Documentation](https://gray-adeyi.github.io/pypaystack2/) for more on this package.
|
|
127
|
+
|
|
128
|
+
## Disclaimer
|
|
129
|
+
|
|
130
|
+
This project is an Open Source client library for [Paystack](https://paystack.com/). It is not officially endorsed or
|
|
131
|
+
affiliated with [Paystack](https://paystack.com/). All trademarks and company names belong to their respective owners.
|
|
132
|
+
|
|
133
|
+
## Contributions
|
|
134
|
+
|
|
135
|
+
Thank you for being interested in contributing to PyPaystack2.
|
|
136
|
+
There are many ways you can contribute to the project:
|
|
137
|
+
|
|
138
|
+
- [Star on GitHub](https://github.com/gray-adeyi/pypaystack2/)
|
|
139
|
+
- Try PyPaystack2 and [report bugs/issues you find](https://github.com/gray-adeyi/pypaystack2/issues/new)
|
|
140
|
+
- [Buy me a coffee](https://www.buymeacoffee.com/jigani)
|
|
141
|
+
|
|
142
|
+
## Other Related Projects
|
|
143
|
+
|
|
144
|
+
| Name | Language | Functionality |
|
|
145
|
+
|------------------------------------------------------------------------------------|-----------------------|----------------------------------------------------------------------------------|
|
|
146
|
+
| [Paystack CLI](https://pypi.org/project/paystack-cli/) | Python | A command line app for interacting with paystack APIs |
|
|
147
|
+
| [paystack](https://github.com/gray-adeyi/paystack) | Go | A client library for integration paystack in go |
|
|
148
|
+
| [@gray-adeyi/paystack-sdk](https://www.npmjs.com/package/@gray-adeyi/paystack-sdk) | Typescript/Javascript | A client library for integrating paystack in Javascript runtimes (Node,Deno,Bun) |
|
|
149
|
+
| [paystack](https://pub.dev/packages/paystack) | Dart | A client library for integration paystack in Dart |
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# PyPaystack2
|
|
2
|
+
|
|
3
|
+
[](https://pepy.tech/project/pypaystack2)
|
|
4
|
+
[](https://pepy.tech/project/pypaystack2)
|
|
5
|
+
[](https://pepy.tech/project/pypaystack2)
|
|
6
|
+
|
|
7
|
+
PyPaystack2 is an Open Source Python client library for integrating [Paystack](https://paystack.com/) into your python
|
|
8
|
+
projects. It aims at being developer friendly and easy to use.
|
|
9
|
+
|
|
10
|
+
**Version 3 is here now**
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- 1st class support for type annotations.
|
|
15
|
+
- Synchronous and Asynchronous clients.
|
|
16
|
+
- Pydantic for data modelling.
|
|
17
|
+
- Fees Calculation utilities.
|
|
18
|
+
- Webhook support & utilities (>= v3.1.0).
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
$ pip install -U pypaystack2
|
|
24
|
+
# or install with uv
|
|
25
|
+
$ uv add pypaystack2
|
|
26
|
+
# For webhook cli
|
|
27
|
+
$ pip install -U "pypaystack2[webhook]"
|
|
28
|
+
or install with uv
|
|
29
|
+
$ uv add "pypaystack2[webhook"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage Preview
|
|
33
|
+
|
|
34
|
+
In the REPL session below, we're using PyPaystack2 to create a `Customer` (user) and a `Plan` on
|
|
35
|
+
[Paystack](https://paystack.com/) and then add the newly created customer as a subscriber to the plan.
|
|
36
|
+
|
|
37
|
+
### Note
|
|
38
|
+
|
|
39
|
+
The REPL session below assumes the environmental variable `PAYSTACK_SECRET_KEY="YOUR_SECRET_KEY"` is set. if not,
|
|
40
|
+
you can alternatively pass it into the `PaystackClient` on instantiation like so
|
|
41
|
+
`PaystackClient(secret_key='YOUR_SECRET_KEY')` otherwise, you will get a `MissingSecretKeyException` raised prompting
|
|
42
|
+
you to provide a secret key. It also does not handle likely exceptions that calling client methods like
|
|
43
|
+
`client.customers.create`, `client.plans.create` & `client.subscriptions.create` may raise like `ClientNetworkError`
|
|
44
|
+
for network related issues and `ValueError` for validation related issues.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
Python 3.11.13 (main, Sep 2 2025, 14:20:25) [Clang 20.1.4 ] on linux
|
|
48
|
+
Type "help", "copyright", "credits" or "license" for more information.
|
|
49
|
+
>>> from pypaystack2 import __version__
|
|
50
|
+
>>> print(__version__)
|
|
51
|
+
3.0.0 # Ensure you're running PyPaystack2 version >= 3.0.0 for the following entries to work
|
|
52
|
+
>>> from pypaystack2 import PaystackClient
|
|
53
|
+
>>> from pypaystack2.enums import Interval
|
|
54
|
+
>>> from pypaystack2.models import Customer, Plan
|
|
55
|
+
>>> client = PaystackClient()
|
|
56
|
+
>>> new_customer_response = client.customers.create(email="johndoe@example.com",first_name="John",last_name="Doe")
|
|
57
|
+
>>> assert new_customer_response.status # Validating the request is successful
|
|
58
|
+
>>> new_customer = new_customer_response.data
|
|
59
|
+
>>> assert isinstance(new_customer,Customer) # Showing that we indeed get an instance of a pydantic model name `Customer` a modelled representation of the data returned by paystack as a result of the request to create a new user
|
|
60
|
+
>>> new_plan_response = client.plans.create(name="Test 1k Daily Contributions", amount=client.to_subunit(1000), interval=Interval.DAILY)
|
|
61
|
+
>>> assert new_plan_response.status # Validating the request is successful
|
|
62
|
+
>>> new_plan = new_plan_response.data # Validating the request is successful
|
|
63
|
+
>>> assert isinstance(new_plan,Plan)
|
|
64
|
+
>>> new_subscription_response = client.subscriptions.create(customer=new_customer.customer_code,plan=new_plan.plan_code)
|
|
65
|
+
>>> assert new_subscription_response.status == True # Validating the request is successful
|
|
66
|
+
>>> print(repr(new_subscription_response))
|
|
67
|
+
Response(
|
|
68
|
+
status_code=<HTTPStatus.OK: 200>,
|
|
69
|
+
status=True,
|
|
70
|
+
message='Subscription successfully created',
|
|
71
|
+
data=Subscription(
|
|
72
|
+
customer=87934333,
|
|
73
|
+
plan=2237384,...
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Webhook
|
|
77
|
+
|
|
78
|
+
PyPaystack2 now supports verifying the authenticity of a webhook payload and a CLI to make working with webhooks locally
|
|
79
|
+
seamless
|
|
80
|
+
|
|
81
|
+
#### Verifying a webhook payload
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
Python 3.11.13 (main, Sep 2 2025, 14:20:25) [Clang 20.1.4 ] on linux
|
|
85
|
+
Type "help", "copyright", "credits" or "license" for more information.
|
|
86
|
+
>>> from pypaystack2 import PaystackClient
|
|
87
|
+
>>> client = PaystackClient()
|
|
88
|
+
>>> payload = ... # webhook payload e.g., b'{"event": "customeridentification.success", "data": {"customer_id": 324345768, "customer_code": "CUS_e7urjebaoyk1ze2", "email": "jddae8446e-e54c-42ab-bf37-e5abff14527e@example.com", "identification": {"country": "NG", "type": "bank_account", "bvn": "123*****543", "account_number": "342****22", "bank_code": "121"}}}'
|
|
89
|
+
>>> signature = ... # x-paystack-signature e.g., "5d049eb93c7c71fa098f5215d7297bda401710b62df8b392b9052adf8d1a02ff308f6ca57a1db14ffeabd5b66264e9c42de029b7067b9c71eb9c231fb2a8e383"
|
|
90
|
+
>>> is_verified_webhook_payload = client.is_verified_webhook_payload(payload,signature)
|
|
91
|
+
>>> print(is_verified_webhook_payload)
|
|
92
|
+
True
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Forward webhook events from paystack to your app running locally
|
|
96
|
+
|
|
97
|
+
**Note:** This requires that you install `pypaystack2[webhook]`
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pypaystack2 webhook start-tunnel-server --addr localhost:8000 --ngrok-auth-token
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Documentation
|
|
104
|
+
|
|
105
|
+
See [Documentation](https://gray-adeyi.github.io/pypaystack2/) for more on this package.
|
|
106
|
+
|
|
107
|
+
## Disclaimer
|
|
108
|
+
|
|
109
|
+
This project is an Open Source client library for [Paystack](https://paystack.com/). It is not officially endorsed or
|
|
110
|
+
affiliated with [Paystack](https://paystack.com/). All trademarks and company names belong to their respective owners.
|
|
111
|
+
|
|
112
|
+
## Contributions
|
|
113
|
+
|
|
114
|
+
Thank you for being interested in contributing to PyPaystack2.
|
|
115
|
+
There are many ways you can contribute to the project:
|
|
116
|
+
|
|
117
|
+
- [Star on GitHub](https://github.com/gray-adeyi/pypaystack2/)
|
|
118
|
+
- Try PyPaystack2 and [report bugs/issues you find](https://github.com/gray-adeyi/pypaystack2/issues/new)
|
|
119
|
+
- [Buy me a coffee](https://www.buymeacoffee.com/jigani)
|
|
120
|
+
|
|
121
|
+
## Other Related Projects
|
|
122
|
+
|
|
123
|
+
| Name | Language | Functionality |
|
|
124
|
+
|------------------------------------------------------------------------------------|-----------------------|----------------------------------------------------------------------------------|
|
|
125
|
+
| [Paystack CLI](https://pypi.org/project/paystack-cli/) | Python | A command line app for interacting with paystack APIs |
|
|
126
|
+
| [paystack](https://github.com/gray-adeyi/paystack) | Go | A client library for integration paystack in go |
|
|
127
|
+
| [@gray-adeyi/paystack-sdk](https://www.npmjs.com/package/@gray-adeyi/paystack-sdk) | Typescript/Javascript | A client library for integrating paystack in Javascript runtimes (Node,Deno,Bun) |
|
|
128
|
+
| [paystack](https://pub.dev/packages/paystack) | Dart | A client library for integration paystack in Dart |
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pypaystack2"
|
|
3
|
+
version = "3.1.0"
|
|
4
|
+
description = "A developer-friendly client library for Paystack"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Gbenga Adeyi", email = "adeyigbenga005@gmail.com" }
|
|
9
|
+
]
|
|
10
|
+
keywords = ["paystack-python", "pypaystack", "paystack", "paystackapi"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
requires-python = ">= 3.11"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"httpx>=0.28.1",
|
|
21
|
+
"pydantic>=2.12.5",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
pypaystack2 = "pypaystack2.cli:cli_app"
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
webhook = [
|
|
29
|
+
"fastapi[standard]>=0.123.10",
|
|
30
|
+
"ngrok>=1.4.0",
|
|
31
|
+
"python-dotenv>=1.2.1",
|
|
32
|
+
"typer-slim[standard]>=0.20.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["uv_build>=0.9.10,<0.10.0"]
|
|
37
|
+
build-backend = "uv_build"
|
|
38
|
+
|
|
39
|
+
[dependency-groups]
|
|
40
|
+
dev = [
|
|
41
|
+
"pre-commit>=4.5.0",
|
|
42
|
+
{ include-group = "format" },
|
|
43
|
+
{ include-group = "test" },
|
|
44
|
+
{ include-group = "coverage" },
|
|
45
|
+
]
|
|
46
|
+
format = [
|
|
47
|
+
"ruff>=0.14.8",
|
|
48
|
+
]
|
|
49
|
+
test = [
|
|
50
|
+
"python-dotenv>=1.2.1",
|
|
51
|
+
"tomli>=2.3.0",
|
|
52
|
+
"typer-slim[standard]>=0.20.0",
|
|
53
|
+
]
|
|
54
|
+
coverage = []
|
|
55
|
+
doc = [
|
|
56
|
+
"mike>=2.1.3",
|
|
57
|
+
"mkdocs>=1.6.1",
|
|
58
|
+
"mkdocs-glightbox>=0.5.2",
|
|
59
|
+
"mkdocs-material>=9.7.0",
|
|
60
|
+
"mkdocstrings>=1.0.0",
|
|
61
|
+
"mkdocstrings-python>=2.0.1",
|
|
62
|
+
]
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This is the package-level documentation for the `pypaystack2` package.
|
|
3
|
+
|
|
4
|
+
The ``pypaystack2`` package provides clients for interacting with Paystack's API in your python project
|
|
5
|
+
it provides ``PaystackClient`` and ``AsyncPaystackClient``. The former for working in synchronous contexts
|
|
6
|
+
and the latter for working in asynchronous contexts. These two classes are considered the main clients
|
|
7
|
+
and provide bindings to other sub-clients as class attributes. E.g. ``PaystackClient.apple_pay``
|
|
8
|
+
|
|
9
|
+
Subpackages:
|
|
10
|
+
- `pypaystack2.sub_clients`: A package containing clients for interacting with specific Paystack's API
|
|
11
|
+
- `pypaystack2.models`: A package containing pydantic model representations of payload and response data
|
|
12
|
+
the individual models may also be referred to as generic type called `PaystackDataModel` which serves
|
|
13
|
+
as a placeholder for the models.
|
|
14
|
+
|
|
15
|
+
Module:
|
|
16
|
+
- `pypaystack2.enum`: A module containing enums used package wide.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Example usage:
|
|
20
|
+
|
|
21
|
+
from pypaystack2 import PaystackClient
|
|
22
|
+
from pypaystack2.enums import Country
|
|
23
|
+
|
|
24
|
+
client = PaystackClient() # Assumes your secret key is set in your environmental variables
|
|
25
|
+
# as PAYSTACK_SECRET_KEY. you may also choose to pass the secret key explicitly on instantiation
|
|
26
|
+
# of the client. `client = PaystackClient(secret_key='<your-secret-key>')`
|
|
27
|
+
|
|
28
|
+
# Initializing a transaction
|
|
29
|
+
response = client.transactions.initialize(amount=10_000,email="johndoe@example.com")
|
|
30
|
+
print(repr(response))
|
|
31
|
+
|
|
32
|
+
# Get banks
|
|
33
|
+
response = client.miscellaneous.get_banks(country=Country.NIGERIA)
|
|
34
|
+
print(repr(response))
|
|
35
|
+
|
|
36
|
+
For more details, refer to the documentation.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
# ruff: noqa: F401
|
|
40
|
+
from pypaystack2._metadata import (
|
|
41
|
+
__title__,
|
|
42
|
+
__version__,
|
|
43
|
+
__author__,
|
|
44
|
+
__license__,
|
|
45
|
+
__copyright__,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
from pypaystack2.main_clients import PaystackClient, AsyncPaystackClient
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
"__title__",
|
|
52
|
+
"__version__",
|
|
53
|
+
"__author__",
|
|
54
|
+
"__license__",
|
|
55
|
+
"__copyright__",
|
|
56
|
+
"PaystackClient",
|
|
57
|
+
"AsyncPaystackClient",
|
|
58
|
+
]
|