python-getpaid-paynow 3.0.0a4__tar.gz → 3.0.0a5__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 (41) hide show
  1. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/PKG-INFO +3 -3
  2. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/README.md +1 -1
  3. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/pyproject.toml +1 -1
  4. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/__init__.py +1 -1
  5. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/simulator/plugin.py +1 -0
  6. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/simulator/routes.py +24 -9
  7. python_getpaid_paynow-3.0.0a5/tests/test_public_api.py +18 -0
  8. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/tests/test_simulator_plugin.py +5 -0
  9. python_getpaid_paynow-3.0.0a4/tests/test_public_api.py +0 -7
  10. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/.github/workflows/ci.yml +0 -0
  11. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/.gitignore +0 -0
  12. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/.pre-commit-config.yaml +0 -0
  13. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/.readthedocs.yml +0 -0
  14. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/CODE_OF_CONDUCT.md +0 -0
  15. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/CONTRIBUTING.md +0 -0
  16. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/LICENSE +0 -0
  17. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/changelog.md +0 -0
  18. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/codeofconduct.md +0 -0
  19. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/concepts.md +0 -0
  20. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/conf.py +0 -0
  21. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/configuration.md +0 -0
  22. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/contributing.md +0 -0
  23. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/getting-started.md +0 -0
  24. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/index.md +0 -0
  25. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/license.md +0 -0
  26. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/reference.md +0 -0
  27. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/docs/requirements.txt +0 -0
  28. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/client.py +0 -0
  29. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/processor.py +0 -0
  30. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/py.typed +0 -0
  31. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/simulator/__init__.py +0 -0
  32. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/simulator/signing.py +0 -0
  33. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/simulator/transitions.py +0 -0
  34. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/simulator/webhooks.py +0 -0
  35. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/src/getpaid_paynow/types.py +0 -0
  36. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/tests/__init__.py +0 -0
  37. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/tests/conftest.py +0 -0
  38. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/tests/test_callback.py +0 -0
  39. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/tests/test_client.py +0 -0
  40. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/tests/test_processor.py +0 -0
  41. {python_getpaid_paynow-3.0.0a4 → python_getpaid_paynow-3.0.0a5}/tests/test_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-getpaid-paynow
3
- Version: 3.0.0a4
3
+ Version: 3.0.0a5
4
4
  Summary: Paynow payment gateway integration for python-getpaid ecosystem.
5
5
  Project-URL: Homepage, https://github.com/django-getpaid/python-getpaid-paynow
6
6
  Project-URL: Repository, https://github.com/django-getpaid/python-getpaid-paynow
@@ -18,7 +18,7 @@ Classifier: Topic :: Office/Business :: Financial :: Point-Of-Sale
18
18
  Classifier: Typing :: Typed
19
19
  Requires-Python: >=3.12
20
20
  Requires-Dist: httpx>=0.27.0
21
- Requires-Dist: python-getpaid-core>=3.0.0a3
21
+ Requires-Dist: python-getpaid-core>=3.0.0a4
22
22
  Provides-Extra: simulator
23
23
  Requires-Dist: litestar>=2.0; extra == 'simulator'
24
24
  Requires-Dist: python-getpaid-simulator>=3.0.0a3; extra == 'simulator'
@@ -169,7 +169,7 @@ GETPAID_BACKEND_SETTINGS = {
169
169
  ## Requirements
170
170
 
171
171
  - Python 3.12+
172
- - `python-getpaid-core >= 3.0.0a3`
172
+ - `python-getpaid-core >= 3.0.0a4`
173
173
  - `httpx >= 0.27.0`
174
174
 
175
175
  ## Links
@@ -143,7 +143,7 @@ GETPAID_BACKEND_SETTINGS = {
143
143
  ## Requirements
144
144
 
145
145
  - Python 3.12+
146
- - `python-getpaid-core >= 3.0.0a3`
146
+ - `python-getpaid-core >= 3.0.0a4`
147
147
  - `httpx >= 0.27.0`
148
148
 
149
149
  ## Links
@@ -19,7 +19,7 @@ classifiers = [
19
19
  'Typing :: Typed',
20
20
  ]
21
21
  dependencies = [
22
- 'python-getpaid-core>=3.0.0a3',
22
+ 'python-getpaid-core>=3.0.0a4',
23
23
  'httpx>=0.27.0',
24
24
  ]
25
25
 
@@ -1,6 +1,6 @@
1
1
  """Paynow V3 payment gateway integration for python-getpaid ecosystem."""
2
2
 
3
- __version__ = "3.0.0a4"
3
+ __version__ = "3.0.0a5"
4
4
 
5
5
  __all__ = [
6
6
  "PaynowClient",
@@ -29,6 +29,7 @@ def load_provider_config(
29
29
  ) -> dict[str, Any]:
30
30
  environment = env or os.environ
31
31
  return {
32
+ "amount_minor_unit_places": 2,
32
33
  "api_key": environment.get(
33
34
  "SIMULATOR_PAYNOW_API_KEY",
34
35
  "sim-paynow-api-key",
@@ -3,6 +3,8 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import logging
6
+ from decimal import Decimal
7
+ from decimal import InvalidOperation
6
8
  from typing import Any
7
9
  from typing import TypedDict
8
10
  from typing import cast
@@ -115,6 +117,24 @@ def _provider_config(request: Request[Any, Any, Any]) -> dict[str, Any]:
115
117
  return dict(request.app.state.provider_configs["paynow"])
116
118
 
117
119
 
120
+ def _format_amount_for_display(
121
+ payment: dict[str, Any],
122
+ provider_config: dict[str, Any],
123
+ ) -> str:
124
+ amount_raw = payment.get("amount", payment.get("totalAmount", 0))
125
+ try:
126
+ amount_value = Decimal(str(amount_raw))
127
+ except (InvalidOperation, TypeError, ValueError):
128
+ return str(amount_raw)
129
+
130
+ minor_unit_places = int(provider_config.get("amount_minor_unit_places", 2))
131
+ if minor_unit_places >= 0:
132
+ amount_value /= Decimal(10) ** minor_unit_places
133
+
134
+ currency = payment.get("currency", payment.get("currencyCode", "PLN"))
135
+ return f"{amount_value:.2f} {currency}"
136
+
137
+
118
138
  def _error_response(
119
139
  status_code: int,
120
140
  error_type: str,
@@ -346,15 +366,10 @@ async def paynow_authorize_get(
346
366
  if payment.get("status") in ("CONFIRMED", "REJECTED"):
347
367
  raise HTTPException(status_code=400, detail="Payment already processed")
348
368
 
349
- amount_raw = payment.get("amount", payment.get("totalAmount", 0))
350
- try:
351
- amount_value = float(amount_raw) / 100
352
- formatted_amount = (
353
- f"{amount_value:.2f} "
354
- f"{payment.get('currency', payment.get('currencyCode', 'PLN'))}"
355
- )
356
- except (ValueError, TypeError):
357
- formatted_amount = str(amount_raw)
369
+ formatted_amount = _format_amount_for_display(
370
+ payment,
371
+ _provider_config(request),
372
+ )
358
373
 
359
374
  return Template(
360
375
  template_name="authorize.html",
@@ -0,0 +1,18 @@
1
+ """Tests for the public package API."""
2
+
3
+ import tomllib
4
+ from pathlib import Path
5
+
6
+ import getpaid_paynow
7
+
8
+
9
+ def test_version() -> None:
10
+ assert getpaid_paynow.__version__ == "3.0.0a4"
11
+
12
+
13
+ def test_core_dependency_floor() -> None:
14
+ pyproject_data = tomllib.loads(Path("pyproject.toml").read_text())
15
+ assert (
16
+ "python-getpaid-core>=3.0.0a4"
17
+ in pyproject_data["project"]["dependencies"]
18
+ )
@@ -96,12 +96,17 @@ def test_load_provider_config_reads_env_overrides(
96
96
  )
97
97
 
98
98
  assert load_provider_config() == {
99
+ "amount_minor_unit_places": 2,
99
100
  "api_key": "override-api-key",
100
101
  "signature_key": "override-signature",
101
102
  "notify_url": "https://merchant.example/paynow/callback",
102
103
  }
103
104
 
104
105
 
106
+ def test_load_provider_config_includes_amount_minor_unit_places() -> None:
107
+ assert load_provider_config()["amount_minor_unit_places"] == 2
108
+
109
+
105
110
  @pytest.mark.asyncio
106
111
  async def test_trigger_paynow_webhook_uses_provider_notify_url_fallback() -> (
107
112
  None
@@ -1,7 +0,0 @@
1
- """Tests for the public package API."""
2
-
3
- import getpaid_paynow
4
-
5
-
6
- def test_version() -> None:
7
- assert getpaid_paynow.__version__ == "3.0.0a4"