clickpesa-python-sdk 0.1.0__tar.gz → 0.1.1__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.
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/PKG-INFO +1 -1
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/pyproject.toml +1 -1
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/security.py +19 -12
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa_python_sdk.egg-info/PKG-INFO +1 -1
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/LICENSE +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/README.md +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/setup.cfg +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/__init__.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/_version.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/async_client.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/client.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/exceptions.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/py.typed +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/__init__.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/account.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/billpay.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/exchange.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/links.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/payments.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/payouts.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/webhooks.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa_python_sdk.egg-info/SOURCES.txt +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa_python_sdk.egg-info/dependency_links.txt +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa_python_sdk.egg-info/requires.txt +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa_python_sdk.egg-info/top_level.txt +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/tests/test_async_client.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/tests/test_billpay.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/tests/test_client.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/tests/test_links.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/tests/test_payments.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/tests/test_payouts.py +0 -0
- {clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/tests/test_webhook.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clickpesa-python-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Production-grade Python SDK for the ClickPesa API — sync & async, collections, payouts, BillPay and more
|
|
5
5
|
Author-email: Jackson Linus <jacksonlinus95@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,26 +8,37 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
import hmac
|
|
10
10
|
import hashlib
|
|
11
|
+
import json
|
|
11
12
|
import logging
|
|
13
|
+
from typing import Any
|
|
12
14
|
|
|
13
15
|
logger = logging.getLogger(__name__)
|
|
14
16
|
|
|
15
17
|
|
|
18
|
+
def _canonicalize(obj: Any) -> Any:
|
|
19
|
+
"""Recursively sort all object keys alphabetically at every nesting level."""
|
|
20
|
+
if obj is None or not isinstance(obj, (dict, list)):
|
|
21
|
+
return obj
|
|
22
|
+
if isinstance(obj, list):
|
|
23
|
+
return [_canonicalize(item) for item in obj]
|
|
24
|
+
return {key: _canonicalize(obj[key]) for key in sorted(obj.keys())}
|
|
25
|
+
|
|
26
|
+
|
|
16
27
|
class SecurityManager:
|
|
17
28
|
@staticmethod
|
|
18
29
|
def create_checksum(checksum_key: str, payload: dict) -> str:
|
|
19
30
|
"""
|
|
20
31
|
Generate a ClickPesa-compatible HMAC-SHA256 checksum for a request payload.
|
|
21
32
|
|
|
22
|
-
Algorithm:
|
|
23
|
-
1.
|
|
24
|
-
2.
|
|
25
|
-
|
|
26
|
-
3. Return the hex digest of HMAC-SHA256(key, concatenated_string).
|
|
33
|
+
Algorithm (per ClickPesa docs):
|
|
34
|
+
1. Canonicalize payload — recursively sort all object keys alphabetically.
|
|
35
|
+
2. Serialize to compact JSON (no extra whitespace).
|
|
36
|
+
3. Return the hex digest of HMAC-SHA256(key, json_string).
|
|
27
37
|
|
|
28
38
|
Args:
|
|
29
39
|
checksum_key: Your application's checksum secret key.
|
|
30
|
-
payload: The request body dict (
|
|
40
|
+
payload: The request body dict (must NOT include ``checksum`` or
|
|
41
|
+
``checksumMethod`` fields).
|
|
31
42
|
|
|
32
43
|
Returns:
|
|
33
44
|
Hex-encoded HMAC-SHA256 string, or ``""`` if ``checksum_key`` is falsy.
|
|
@@ -35,12 +46,8 @@ class SecurityManager:
|
|
|
35
46
|
if not checksum_key:
|
|
36
47
|
return ""
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
payload_string = ""
|
|
40
|
-
str(payload[k])
|
|
41
|
-
for k in sorted_keys
|
|
42
|
-
if not isinstance(payload[k], (dict, list))
|
|
43
|
-
)
|
|
49
|
+
canonical = _canonicalize(payload)
|
|
50
|
+
payload_string = json.dumps(canonical, separators=(",", ":"), sort_keys=False)
|
|
44
51
|
|
|
45
52
|
return hmac.new(
|
|
46
53
|
checksum_key.encode("utf-8"),
|
{clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa_python_sdk.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clickpesa-python-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Production-grade Python SDK for the ClickPesa API — sync & async, collections, payouts, BillPay and more
|
|
5
5
|
Author-email: Jackson Linus <jacksonlinus95@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/exchange.py
RENAMED
|
File without changes
|
|
File without changes
|
{clickpesa_python_sdk-0.1.0 → clickpesa_python_sdk-0.1.1}/src/clickpesa/services/payments.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|