clickpesa-python-sdk 0.1.3__tar.gz → 0.1.4__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.
Files changed (33) hide show
  1. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/PKG-INFO +1 -1
  2. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/pyproject.toml +1 -1
  3. clickpesa_python_sdk-0.1.4/src/clickpesa/_version.py +1 -0
  4. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/security.py +1 -7
  5. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa_python_sdk.egg-info/PKG-INFO +1 -1
  6. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/tests/test_webhook.py +19 -6
  7. clickpesa_python_sdk-0.1.3/src/clickpesa/_version.py +0 -1
  8. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/LICENSE +0 -0
  9. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/README.md +0 -0
  10. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/setup.cfg +0 -0
  11. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/__init__.py +0 -0
  12. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/async_client.py +0 -0
  13. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/client.py +0 -0
  14. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/exceptions.py +0 -0
  15. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/py.typed +0 -0
  16. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/services/__init__.py +0 -0
  17. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/services/account.py +0 -0
  18. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/services/billpay.py +0 -0
  19. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/services/exchange.py +0 -0
  20. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/services/links.py +0 -0
  21. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/services/payments.py +0 -0
  22. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/services/payouts.py +0 -0
  23. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa/webhooks.py +0 -0
  24. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa_python_sdk.egg-info/SOURCES.txt +0 -0
  25. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa_python_sdk.egg-info/dependency_links.txt +0 -0
  26. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa_python_sdk.egg-info/requires.txt +0 -0
  27. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/src/clickpesa_python_sdk.egg-info/top_level.txt +0 -0
  28. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/tests/test_async_client.py +0 -0
  29. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/tests/test_billpay.py +0 -0
  30. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/tests/test_client.py +0 -0
  31. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/tests/test_links.py +0 -0
  32. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/tests/test_payments.py +0 -0
  33. {clickpesa_python_sdk-0.1.3 → clickpesa_python_sdk-0.1.4}/tests/test_payouts.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clickpesa-python-sdk
3
- Version: 0.1.3
3
+ Version: 0.1.4
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "clickpesa-python-sdk"
7
- version = "0.1.3"
7
+ version = "0.1.4"
8
8
  authors = [
9
9
  { name = "Jackson Linus", email = "jacksonlinus95@gmail.com" },
10
10
  ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.4"
@@ -63,11 +63,6 @@ class SecurityManager:
63
63
  Uses ``hmac.compare_digest`` for constant-time comparison to prevent
64
64
  timing-based side-channel attacks.
65
65
 
66
- ClickPesa only signs top-level scalar fields in webhook payloads —
67
- nested dicts and lists are excluded from the signature. This mirrors
68
- their signing algorithm so extra envelope fields (e.g. ``customer``,
69
- ``metadata``) don't cause verification to fail.
70
-
71
66
  Args:
72
67
  checksum_key: Your application's checksum secret key.
73
68
  payload: The parsed webhook body dict.
@@ -79,8 +74,7 @@ class SecurityManager:
79
74
  if not signature:
80
75
  return False
81
76
 
82
- flat_payload = {k: v for k, v in payload.items() if not isinstance(v, (dict, list))}
83
- computed = SecurityManager.create_checksum(checksum_key, flat_payload)
77
+ computed = SecurityManager.create_checksum(checksum_key, payload)
84
78
  return hmac.compare_digest(computed, signature)
85
79
 
86
80
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clickpesa-python-sdk
3
- Version: 0.1.3
3
+ Version: 0.1.4
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
@@ -48,12 +48,25 @@ def test_verify_empty_signature_returns_false():
48
48
  assert WebhookValidator.verify(PAYLOAD, "", CHECKSUM_KEY) is False
49
49
 
50
50
 
51
- def test_verify_nested_fields_excluded():
52
- """Nested dicts and lists are ignored in the checksum — a flat signature
53
- still verifies a payload that has extra nested fields."""
54
- flat_sig = _sig()
55
- payload_with_nested = {**PAYLOAD, "customer": {"name": "Alice"}, "items": [1, 2, 3]}
56
- assert WebhookValidator.verify(payload_with_nested, flat_sig, CHECKSUM_KEY) is True
51
+ def test_verify_real_webhook_structure():
52
+ """Signature covers the full payload including nested data — mirrors ClickPesa's
53
+ actual webhook shape: {"event": "...", "data": {...nested...}}."""
54
+ webhook = {
55
+ "event": "PAYMENT RECEIVED",
56
+ "data": {
57
+ "id": "ORD123LCP456",
58
+ "status": "SUCCESS",
59
+ "orderReference": "ORD123",
60
+ "collectedAmount": "10000",
61
+ "collectedCurrency": "TZS",
62
+ "customer": {
63
+ "customerName": "John Doe",
64
+ "customerPhoneNumber": "255700000000",
65
+ },
66
+ },
67
+ }
68
+ sig = SecurityManager.create_checksum(CHECKSUM_KEY, webhook)
69
+ assert WebhookValidator.verify(webhook, sig, CHECKSUM_KEY) is True
57
70
 
58
71
 
59
72
  # ---------------------------------------------------------------------------
@@ -1 +0,0 @@
1
- __version__ = "0.1.3"