wajub 1.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.
- wajub-1.1.0/.gitignore +24 -0
- wajub-1.1.0/LICENSE +21 -0
- wajub-1.1.0/PKG-INFO +255 -0
- wajub-1.1.0/README.md +227 -0
- wajub-1.1.0/pyproject.toml +56 -0
- wajub-1.1.0/src/wajub/py.typed +0 -0
wajub-1.1.0/.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
*.egg
|
|
9
|
+
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.mypy_cache/
|
|
13
|
+
.coverage
|
|
14
|
+
htmlcov/
|
|
15
|
+
|
|
16
|
+
.venv/
|
|
17
|
+
venv/
|
|
18
|
+
.env
|
|
19
|
+
.env.local
|
|
20
|
+
|
|
21
|
+
/.idea/
|
|
22
|
+
/.vscode/
|
|
23
|
+
*.swp
|
|
24
|
+
.DS_Store
|
wajub-1.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wajub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
wajub-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wajub
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Official Wajub Python SDK — server-side payments, webhooks, and merchant API
|
|
5
|
+
Project-URL: Homepage, https://wajub.com
|
|
6
|
+
Project-URL: Documentation, https://docs.wajub.com/libraries/sdks/python
|
|
7
|
+
Project-URL: Repository, https://github.com/wajubhq/wajub-python
|
|
8
|
+
Project-URL: Issues, https://github.com/wajubhq/wajub-python/issues
|
|
9
|
+
Author-email: Wajub <hello@wajub.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: africa,checkout,mobile-money,payments,wajub,webhooks
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: httpx>=0.27.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.9; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# Wajub Python SDK
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/wajub/)
|
|
32
|
+
[](https://pypi.org/project/wajub/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
|
|
35
|
+
Official **server-side** SDK for the [Wajub merchant API](https://docs.wajub.com). Accept mobile-money and card payments across Africa with a Stripe-inspired, resource-oriented client.
|
|
36
|
+
|
|
37
|
+
Use **[Wajub.js](https://docs.wajub.com/libraries/components/js)** for embedded checkout in the browser. Use this SDK on your backend with a secret (`sk_`) or restricted (`rk_`) API key — never expose secret keys in client-side code.
|
|
38
|
+
|
|
39
|
+
This SDK covers the **merchant API**. It does not wrap checkout session endpoints (`/pay/*`), public link checkout (`/q/*`, `/i/*`), or sandbox simulation — those belong to Wajub.js or direct HTTP during the payment flow.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- Resource-oriented API (`wajub.payments`, `wajub.customers`, …)
|
|
44
|
+
- Automatic `Idempotency-Key` on mutating requests (override per call)
|
|
45
|
+
- Typed errors per HTTP status (`AuthenticationError`, `RateLimitError`, …)
|
|
46
|
+
- Automatic retries on 429 and 5xx (max 2, exponential backoff)
|
|
47
|
+
- Page-based pagination with `auto_paging_iter()` and `get_next_page()`
|
|
48
|
+
- Webhook signature verification (HMAC-SHA256, timestamp tolerance)
|
|
49
|
+
|
|
50
|
+
## Requirements
|
|
51
|
+
|
|
52
|
+
| Requirement | Version |
|
|
53
|
+
|-------------|---------|
|
|
54
|
+
| Python | 3.10 or later |
|
|
55
|
+
| HTTP client | [httpx](https://www.python-httpx.org/) 0.27+ (installed automatically) |
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install wajub
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick start
|
|
64
|
+
|
|
65
|
+
Amounts are passed in the **smallest currency unit** (e.g. cents for EUR/USD; whole francs for XAF).
|
|
66
|
+
|
|
67
|
+
### Redirect checkout
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
import os
|
|
71
|
+
from wajub import Wajub
|
|
72
|
+
|
|
73
|
+
wajub = Wajub(api_key=os.environ["WAJUB_API_KEY"])
|
|
74
|
+
|
|
75
|
+
payment = wajub.payments.create({
|
|
76
|
+
"amount": 15000,
|
|
77
|
+
"currency": "XAF",
|
|
78
|
+
"email": "buyer@example.com",
|
|
79
|
+
"callback": "https://shop.example.com/order/complete",
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
print(payment.authorization_url)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Inline / overlay (embed token)
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
embed = wajub.payments.create({
|
|
89
|
+
"amount": 15000,
|
|
90
|
+
"currency": "XAF",
|
|
91
|
+
"metadata": {"mode": "embed"},
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
# Pass to Wajub.js: embed.authorization_token
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`create()` and `retrieve()` return a typed `Payment` object — prefer attribute access (`payment.authorization_url`). List pages from `list()` yield plain dicts.
|
|
98
|
+
|
|
99
|
+
## Django / Flask
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import os
|
|
103
|
+
from wajub import Wajub
|
|
104
|
+
|
|
105
|
+
wajub = Wajub(
|
|
106
|
+
api_key=os.environ["WAJUB_API_KEY"],
|
|
107
|
+
webhook_secret=os.environ.get("WAJUB_WEBHOOK_SECRET"),
|
|
108
|
+
)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Webhook view (Django)
|
|
112
|
+
|
|
113
|
+
Use the **raw request body**:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from django.http import HttpResponse, HttpResponseBadRequest
|
|
117
|
+
from django.views.decorators.csrf import csrf_exempt
|
|
118
|
+
from wajub import Wajub
|
|
119
|
+
from wajub import WebhookSignatureVerificationError
|
|
120
|
+
|
|
121
|
+
wajub = Wajub(api_key=os.environ["WAJUB_API_KEY"], webhook_secret=os.environ["WAJUB_WEBHOOK_SECRET"])
|
|
122
|
+
|
|
123
|
+
@csrf_exempt
|
|
124
|
+
def wajub_webhook(request):
|
|
125
|
+
try:
|
|
126
|
+
event = wajub.webhooks.construct_event(
|
|
127
|
+
request.body, # bytes — not request.POST or parsed JSON
|
|
128
|
+
request.headers.get("X-Wajub-Signature", ""),
|
|
129
|
+
request.headers.get("X-Wajub-Timestamp", ""),
|
|
130
|
+
)
|
|
131
|
+
except WebhookSignatureVerificationError:
|
|
132
|
+
return HttpResponseBadRequest()
|
|
133
|
+
|
|
134
|
+
if event.get("type") == "payment.succeeded":
|
|
135
|
+
pass # fulfill order
|
|
136
|
+
|
|
137
|
+
return HttpResponse(status=200)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
> **Note:** `global` is a Python keyword. Use `wajub.global_` to access global resources.
|
|
141
|
+
|
|
142
|
+
## Configuration
|
|
143
|
+
|
|
144
|
+
| Variable | Description |
|
|
145
|
+
|----------|-------------|
|
|
146
|
+
| `WAJUB_API_KEY` | Secret or restricted API key (`sk_`, `sk_test.`, `rk_`, …) |
|
|
147
|
+
| `WAJUB_WEBHOOK_SECRET` | Webhook signing secret (`whsec_`) for `construct_event()` |
|
|
148
|
+
|
|
149
|
+
Test mode is selected by your API key prefix (`sk_test.…`), not by the API URL. Production calls always go to `https://api.wajub.com`.
|
|
150
|
+
|
|
151
|
+
## Resources (merchant API)
|
|
152
|
+
|
|
153
|
+
| Attribute | Methods |
|
|
154
|
+
|-----------|---------|
|
|
155
|
+
| `wajub.global_` | `ping`, `channels`, `countries`, `currencies` |
|
|
156
|
+
| `wajub.payments` | `create`, `initialize`, `retrieve`, `list`, `cancel`, `process`, `process_split`, `list_refunds` |
|
|
157
|
+
| `wajub.customers` | `create`, `retrieve`, `update`, `delete`, `list`, `block`, `unblock`, `activate`, `deactivate`, `list_tax_ids`, `create_tax_id`, `delete_tax_id` |
|
|
158
|
+
| `wajub.refunds` | `create`, `retrieve`, `list` |
|
|
159
|
+
| `wajub.transfers` | `create`, `retrieve`, `list` |
|
|
160
|
+
| `wajub.beneficiaries` | `create`, `retrieve`, `update`, `delete`, `list` |
|
|
161
|
+
| `wajub.links` | `create`, `retrieve`, `update`, `delete`, `list` |
|
|
162
|
+
| `wajub.invoices` | `create`, `retrieve`, `update`, `delete`, `list`, `send`, `mark_paid`, `cancel` |
|
|
163
|
+
| `wajub.accounts` | `create`, `retrieve`, `update`, `delete`, `list`, `regenerate_token` |
|
|
164
|
+
| `wajub.webhook_endpoints` | `create`, `retrieve`, `update`, `delete`, `list`, `rotate_secret` |
|
|
165
|
+
| `wajub.balance` | `retrieve` |
|
|
166
|
+
| `wajub.events` | `list`, `retrieve`, `resend` |
|
|
167
|
+
| `wajub.disputes` | `list`, `retrieve`, `submit_evidence`, `accept`, `close`, `send_message` |
|
|
168
|
+
| `wajub.identity` | `resolve`, `validate` |
|
|
169
|
+
| `wajub.tax` | `get_settings`, `update_settings`, `rates`, `calculate`, `reports`, `list_codes`, `retrieve_code`, `list_registrations`, `create_registration`, `retrieve_registration`, `update_registration`, `delete_registration`, `jurisdictions`, `thresholds`, `threshold_alerts` |
|
|
170
|
+
| `wajub.shield` | `get_settings`, `update_settings`, `stats`, `list_blocklist`, `add_to_blocklist`, `remove_from_blocklist` |
|
|
171
|
+
| `wajub.listen` | `config`, `auth` |
|
|
172
|
+
| `wajub.webhooks` | `construct_event` (local — no HTTP) |
|
|
173
|
+
|
|
174
|
+
## Sync (Connect)
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
from wajub import RequestOptions
|
|
178
|
+
|
|
179
|
+
wajub.payments.create(params, RequestOptions(sync="acct_sync_ref"))
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Webhooks
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from wajub import WebhookSignatureVerificationError
|
|
186
|
+
|
|
187
|
+
try:
|
|
188
|
+
event = wajub.webhooks.construct_event(
|
|
189
|
+
raw_body, # bytes — must be raw body, not parsed JSON
|
|
190
|
+
request.headers["X-Wajub-Signature"],
|
|
191
|
+
request.headers["X-Wajub-Timestamp"],
|
|
192
|
+
)
|
|
193
|
+
except WebhookSignatureVerificationError:
|
|
194
|
+
return 400
|
|
195
|
+
|
|
196
|
+
if event.get("type") == "payment.succeeded":
|
|
197
|
+
pass # fulfill order
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
During local development, use the [Wajub CLI](https://github.com/wajubhq/wajub-cli) to forward webhooks to your machine.
|
|
201
|
+
|
|
202
|
+
## Pagination
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
page = wajub.payments.list({"per_page": 50})
|
|
206
|
+
|
|
207
|
+
for payment in page.auto_paging_iter():
|
|
208
|
+
print(payment["id"], payment["status"])
|
|
209
|
+
|
|
210
|
+
# Manual page control
|
|
211
|
+
first = wajub.payments.list()
|
|
212
|
+
if first.has_more:
|
|
213
|
+
second = first.get_next_page()
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Idempotency
|
|
217
|
+
|
|
218
|
+
POST and PUT requests automatically receive an `Idempotency-Key` header. Pass your own:
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from wajub import RequestOptions
|
|
222
|
+
|
|
223
|
+
wajub.payments.create(params, RequestOptions(idempotency_key=f"order-{order_id}"))
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Error handling
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
from wajub import AuthenticationError, InvalidRequestError, RateLimitError
|
|
230
|
+
|
|
231
|
+
try:
|
|
232
|
+
wajub.payments.create(params)
|
|
233
|
+
except InvalidRequestError as e:
|
|
234
|
+
print(e.errors) # field-level validation errors
|
|
235
|
+
except AuthenticationError:
|
|
236
|
+
pass # 401 — bad API key
|
|
237
|
+
except RateLimitError:
|
|
238
|
+
pass # 429 — back off and retry
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Development
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
pip install -e ".[dev]"
|
|
245
|
+
pytest
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Documentation & support
|
|
249
|
+
|
|
250
|
+
- Full API reference: [docs.wajub.com/libraries/sdks/python](https://docs.wajub.com/libraries/sdks/python)
|
|
251
|
+
- Report issues: [github.com/wajubhq/wajub-python/issues](https://github.com/wajubhq/wajub-python/issues)
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
MIT — see [LICENSE](LICENSE).
|
wajub-1.1.0/README.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Wajub Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/wajub/)
|
|
4
|
+
[](https://pypi.org/project/wajub/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
Official **server-side** SDK for the [Wajub merchant API](https://docs.wajub.com). Accept mobile-money and card payments across Africa with a Stripe-inspired, resource-oriented client.
|
|
8
|
+
|
|
9
|
+
Use **[Wajub.js](https://docs.wajub.com/libraries/components/js)** for embedded checkout in the browser. Use this SDK on your backend with a secret (`sk_`) or restricted (`rk_`) API key — never expose secret keys in client-side code.
|
|
10
|
+
|
|
11
|
+
This SDK covers the **merchant API**. It does not wrap checkout session endpoints (`/pay/*`), public link checkout (`/q/*`, `/i/*`), or sandbox simulation — those belong to Wajub.js or direct HTTP during the payment flow.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Resource-oriented API (`wajub.payments`, `wajub.customers`, …)
|
|
16
|
+
- Automatic `Idempotency-Key` on mutating requests (override per call)
|
|
17
|
+
- Typed errors per HTTP status (`AuthenticationError`, `RateLimitError`, …)
|
|
18
|
+
- Automatic retries on 429 and 5xx (max 2, exponential backoff)
|
|
19
|
+
- Page-based pagination with `auto_paging_iter()` and `get_next_page()`
|
|
20
|
+
- Webhook signature verification (HMAC-SHA256, timestamp tolerance)
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
| Requirement | Version |
|
|
25
|
+
|-------------|---------|
|
|
26
|
+
| Python | 3.10 or later |
|
|
27
|
+
| HTTP client | [httpx](https://www.python-httpx.org/) 0.27+ (installed automatically) |
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install wajub
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
Amounts are passed in the **smallest currency unit** (e.g. cents for EUR/USD; whole francs for XAF).
|
|
38
|
+
|
|
39
|
+
### Redirect checkout
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import os
|
|
43
|
+
from wajub import Wajub
|
|
44
|
+
|
|
45
|
+
wajub = Wajub(api_key=os.environ["WAJUB_API_KEY"])
|
|
46
|
+
|
|
47
|
+
payment = wajub.payments.create({
|
|
48
|
+
"amount": 15000,
|
|
49
|
+
"currency": "XAF",
|
|
50
|
+
"email": "buyer@example.com",
|
|
51
|
+
"callback": "https://shop.example.com/order/complete",
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
print(payment.authorization_url)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Inline / overlay (embed token)
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
embed = wajub.payments.create({
|
|
61
|
+
"amount": 15000,
|
|
62
|
+
"currency": "XAF",
|
|
63
|
+
"metadata": {"mode": "embed"},
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
# Pass to Wajub.js: embed.authorization_token
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`create()` and `retrieve()` return a typed `Payment` object — prefer attribute access (`payment.authorization_url`). List pages from `list()` yield plain dicts.
|
|
70
|
+
|
|
71
|
+
## Django / Flask
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import os
|
|
75
|
+
from wajub import Wajub
|
|
76
|
+
|
|
77
|
+
wajub = Wajub(
|
|
78
|
+
api_key=os.environ["WAJUB_API_KEY"],
|
|
79
|
+
webhook_secret=os.environ.get("WAJUB_WEBHOOK_SECRET"),
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Webhook view (Django)
|
|
84
|
+
|
|
85
|
+
Use the **raw request body**:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from django.http import HttpResponse, HttpResponseBadRequest
|
|
89
|
+
from django.views.decorators.csrf import csrf_exempt
|
|
90
|
+
from wajub import Wajub
|
|
91
|
+
from wajub import WebhookSignatureVerificationError
|
|
92
|
+
|
|
93
|
+
wajub = Wajub(api_key=os.environ["WAJUB_API_KEY"], webhook_secret=os.environ["WAJUB_WEBHOOK_SECRET"])
|
|
94
|
+
|
|
95
|
+
@csrf_exempt
|
|
96
|
+
def wajub_webhook(request):
|
|
97
|
+
try:
|
|
98
|
+
event = wajub.webhooks.construct_event(
|
|
99
|
+
request.body, # bytes — not request.POST or parsed JSON
|
|
100
|
+
request.headers.get("X-Wajub-Signature", ""),
|
|
101
|
+
request.headers.get("X-Wajub-Timestamp", ""),
|
|
102
|
+
)
|
|
103
|
+
except WebhookSignatureVerificationError:
|
|
104
|
+
return HttpResponseBadRequest()
|
|
105
|
+
|
|
106
|
+
if event.get("type") == "payment.succeeded":
|
|
107
|
+
pass # fulfill order
|
|
108
|
+
|
|
109
|
+
return HttpResponse(status=200)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
> **Note:** `global` is a Python keyword. Use `wajub.global_` to access global resources.
|
|
113
|
+
|
|
114
|
+
## Configuration
|
|
115
|
+
|
|
116
|
+
| Variable | Description |
|
|
117
|
+
|----------|-------------|
|
|
118
|
+
| `WAJUB_API_KEY` | Secret or restricted API key (`sk_`, `sk_test.`, `rk_`, …) |
|
|
119
|
+
| `WAJUB_WEBHOOK_SECRET` | Webhook signing secret (`whsec_`) for `construct_event()` |
|
|
120
|
+
|
|
121
|
+
Test mode is selected by your API key prefix (`sk_test.…`), not by the API URL. Production calls always go to `https://api.wajub.com`.
|
|
122
|
+
|
|
123
|
+
## Resources (merchant API)
|
|
124
|
+
|
|
125
|
+
| Attribute | Methods |
|
|
126
|
+
|-----------|---------|
|
|
127
|
+
| `wajub.global_` | `ping`, `channels`, `countries`, `currencies` |
|
|
128
|
+
| `wajub.payments` | `create`, `initialize`, `retrieve`, `list`, `cancel`, `process`, `process_split`, `list_refunds` |
|
|
129
|
+
| `wajub.customers` | `create`, `retrieve`, `update`, `delete`, `list`, `block`, `unblock`, `activate`, `deactivate`, `list_tax_ids`, `create_tax_id`, `delete_tax_id` |
|
|
130
|
+
| `wajub.refunds` | `create`, `retrieve`, `list` |
|
|
131
|
+
| `wajub.transfers` | `create`, `retrieve`, `list` |
|
|
132
|
+
| `wajub.beneficiaries` | `create`, `retrieve`, `update`, `delete`, `list` |
|
|
133
|
+
| `wajub.links` | `create`, `retrieve`, `update`, `delete`, `list` |
|
|
134
|
+
| `wajub.invoices` | `create`, `retrieve`, `update`, `delete`, `list`, `send`, `mark_paid`, `cancel` |
|
|
135
|
+
| `wajub.accounts` | `create`, `retrieve`, `update`, `delete`, `list`, `regenerate_token` |
|
|
136
|
+
| `wajub.webhook_endpoints` | `create`, `retrieve`, `update`, `delete`, `list`, `rotate_secret` |
|
|
137
|
+
| `wajub.balance` | `retrieve` |
|
|
138
|
+
| `wajub.events` | `list`, `retrieve`, `resend` |
|
|
139
|
+
| `wajub.disputes` | `list`, `retrieve`, `submit_evidence`, `accept`, `close`, `send_message` |
|
|
140
|
+
| `wajub.identity` | `resolve`, `validate` |
|
|
141
|
+
| `wajub.tax` | `get_settings`, `update_settings`, `rates`, `calculate`, `reports`, `list_codes`, `retrieve_code`, `list_registrations`, `create_registration`, `retrieve_registration`, `update_registration`, `delete_registration`, `jurisdictions`, `thresholds`, `threshold_alerts` |
|
|
142
|
+
| `wajub.shield` | `get_settings`, `update_settings`, `stats`, `list_blocklist`, `add_to_blocklist`, `remove_from_blocklist` |
|
|
143
|
+
| `wajub.listen` | `config`, `auth` |
|
|
144
|
+
| `wajub.webhooks` | `construct_event` (local — no HTTP) |
|
|
145
|
+
|
|
146
|
+
## Sync (Connect)
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from wajub import RequestOptions
|
|
150
|
+
|
|
151
|
+
wajub.payments.create(params, RequestOptions(sync="acct_sync_ref"))
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Webhooks
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from wajub import WebhookSignatureVerificationError
|
|
158
|
+
|
|
159
|
+
try:
|
|
160
|
+
event = wajub.webhooks.construct_event(
|
|
161
|
+
raw_body, # bytes — must be raw body, not parsed JSON
|
|
162
|
+
request.headers["X-Wajub-Signature"],
|
|
163
|
+
request.headers["X-Wajub-Timestamp"],
|
|
164
|
+
)
|
|
165
|
+
except WebhookSignatureVerificationError:
|
|
166
|
+
return 400
|
|
167
|
+
|
|
168
|
+
if event.get("type") == "payment.succeeded":
|
|
169
|
+
pass # fulfill order
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
During local development, use the [Wajub CLI](https://github.com/wajubhq/wajub-cli) to forward webhooks to your machine.
|
|
173
|
+
|
|
174
|
+
## Pagination
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
page = wajub.payments.list({"per_page": 50})
|
|
178
|
+
|
|
179
|
+
for payment in page.auto_paging_iter():
|
|
180
|
+
print(payment["id"], payment["status"])
|
|
181
|
+
|
|
182
|
+
# Manual page control
|
|
183
|
+
first = wajub.payments.list()
|
|
184
|
+
if first.has_more:
|
|
185
|
+
second = first.get_next_page()
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Idempotency
|
|
189
|
+
|
|
190
|
+
POST and PUT requests automatically receive an `Idempotency-Key` header. Pass your own:
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
from wajub import RequestOptions
|
|
194
|
+
|
|
195
|
+
wajub.payments.create(params, RequestOptions(idempotency_key=f"order-{order_id}"))
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Error handling
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from wajub import AuthenticationError, InvalidRequestError, RateLimitError
|
|
202
|
+
|
|
203
|
+
try:
|
|
204
|
+
wajub.payments.create(params)
|
|
205
|
+
except InvalidRequestError as e:
|
|
206
|
+
print(e.errors) # field-level validation errors
|
|
207
|
+
except AuthenticationError:
|
|
208
|
+
pass # 401 — bad API key
|
|
209
|
+
except RateLimitError:
|
|
210
|
+
pass # 429 — back off and retry
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
pip install -e ".[dev]"
|
|
217
|
+
pytest
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Documentation & support
|
|
221
|
+
|
|
222
|
+
- Full API reference: [docs.wajub.com/libraries/sdks/python](https://docs.wajub.com/libraries/sdks/python)
|
|
223
|
+
- Report issues: [github.com/wajubhq/wajub-python/issues](https://github.com/wajubhq/wajub-python/issues)
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "wajub"
|
|
7
|
+
version = "1.1.0"
|
|
8
|
+
description = "Official Wajub Python SDK — server-side payments, webhooks, and merchant API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Wajub", email = "hello@wajub.com" }]
|
|
13
|
+
keywords = ["wajub", "payments", "checkout", "mobile-money", "africa", "webhooks"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"httpx>=0.27.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = [
|
|
31
|
+
"pytest>=8.0",
|
|
32
|
+
"ruff>=0.9",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://wajub.com"
|
|
37
|
+
Documentation = "https://docs.wajub.com/libraries/sdks/python"
|
|
38
|
+
Repository = "https://github.com/wajubhq/wajub-python"
|
|
39
|
+
Issues = "https://github.com/wajubhq/wajub-python/issues"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/wajub"]
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.sdist]
|
|
45
|
+
include = ["src/wajub/py.typed"]
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
pythonpath = ["src"]
|
|
49
|
+
testpaths = ["tests"]
|
|
50
|
+
|
|
51
|
+
[tool.ruff]
|
|
52
|
+
line-length = 100
|
|
53
|
+
target-version = "py310"
|
|
54
|
+
|
|
55
|
+
[tool.ruff.lint]
|
|
56
|
+
select = ["E", "F", "I", "UP"]
|
|
File without changes
|