python-getpaid-paynow 0.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.
- python_getpaid_paynow-0.1.0/.gitignore +20 -0
- python_getpaid_paynow-0.1.0/.readthedocs.yml +12 -0
- python_getpaid_paynow-0.1.0/CODE_OF_CONDUCT.md +132 -0
- python_getpaid_paynow-0.1.0/CONTRIBUTING.md +61 -0
- python_getpaid_paynow-0.1.0/LICENSE +21 -0
- python_getpaid_paynow-0.1.0/PKG-INFO +154 -0
- python_getpaid_paynow-0.1.0/README.md +131 -0
- python_getpaid_paynow-0.1.0/docs/changelog.md +19 -0
- python_getpaid_paynow-0.1.0/docs/codeofconduct.md +2 -0
- python_getpaid_paynow-0.1.0/docs/concepts.md +194 -0
- python_getpaid_paynow-0.1.0/docs/conf.py +29 -0
- python_getpaid_paynow-0.1.0/docs/configuration.md +62 -0
- python_getpaid_paynow-0.1.0/docs/contributing.md +2 -0
- python_getpaid_paynow-0.1.0/docs/getting-started.md +103 -0
- python_getpaid_paynow-0.1.0/docs/index.md +17 -0
- python_getpaid_paynow-0.1.0/docs/license.md +7 -0
- python_getpaid_paynow-0.1.0/docs/reference.md +25 -0
- python_getpaid_paynow-0.1.0/docs/requirements.txt +3 -0
- python_getpaid_paynow-0.1.0/pyproject.toml +117 -0
- python_getpaid_paynow-0.1.0/src/getpaid_paynow/__init__.py +19 -0
- python_getpaid_paynow-0.1.0/src/getpaid_paynow/client.py +389 -0
- python_getpaid_paynow-0.1.0/src/getpaid_paynow/processor.py +238 -0
- python_getpaid_paynow-0.1.0/src/getpaid_paynow/py.typed +0 -0
- python_getpaid_paynow-0.1.0/src/getpaid_paynow/types.py +218 -0
- python_getpaid_paynow-0.1.0/tests/__init__.py +0 -0
- python_getpaid_paynow-0.1.0/tests/conftest.py +143 -0
- python_getpaid_paynow-0.1.0/tests/test_callback.py +315 -0
- python_getpaid_paynow-0.1.0/tests/test_client.py +589 -0
- python_getpaid_paynow-0.1.0/tests/test_processor.py +373 -0
- python_getpaid_paynow-0.1.0/tests/test_types.py +226 -0
- python_getpaid_paynow-0.1.0/uv.lock +925 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# Coverage
|
|
13
|
+
.coverage
|
|
14
|
+
htmlcov/
|
|
15
|
+
|
|
16
|
+
# Implementation plans (local only)
|
|
17
|
+
.plans/
|
|
18
|
+
|
|
19
|
+
# Sphinx build output
|
|
20
|
+
docs/_build/
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
- Demonstrating empathy and kindness toward other people
|
|
21
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
- Giving and gracefully accepting constructive feedback
|
|
23
|
+
- Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
- Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
- The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
- Public or private harassment
|
|
34
|
+
- Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[dominik@kozaczko.info](mailto:dominik@kozaczko.info).
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][mozilla coc].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][faq]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[mozilla coc]: https://github.com/mozilla/diversity
|
|
131
|
+
[faq]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Contributor Guide
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in improving getpaid-paynow.
|
|
4
|
+
This project is open-source under the [MIT license](https://github.com/django-getpaid/python-getpaid-paynow/blob/main/LICENSE) and
|
|
5
|
+
welcomes contributions in the form of bug reports, feature requests, and pull requests.
|
|
6
|
+
|
|
7
|
+
## Resources
|
|
8
|
+
|
|
9
|
+
- [Source Code](https://github.com/django-getpaid/python-getpaid-paynow)
|
|
10
|
+
- [Documentation](https://getpaid-paynow.readthedocs.io/)
|
|
11
|
+
- [Issue Tracker](https://github.com/django-getpaid/python-getpaid-paynow/issues)
|
|
12
|
+
|
|
13
|
+
## How to report a bug
|
|
14
|
+
|
|
15
|
+
Report bugs on the [Issue Tracker](https://github.com/django-getpaid/python-getpaid-paynow/issues).
|
|
16
|
+
|
|
17
|
+
When filing an issue, include:
|
|
18
|
+
|
|
19
|
+
- Operating system and Python version
|
|
20
|
+
- getpaid-paynow version
|
|
21
|
+
- Steps to reproduce
|
|
22
|
+
- Expected vs actual behavior
|
|
23
|
+
|
|
24
|
+
## How to set up your development environment
|
|
25
|
+
|
|
26
|
+
You need Python 3.12+ and [uv](https://docs.astral.sh/uv/).
|
|
27
|
+
|
|
28
|
+
Clone and install:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/django-getpaid/python-getpaid-paynow.git
|
|
32
|
+
cd python-getpaid-paynow
|
|
33
|
+
uv sync
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Run tests:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uv run pytest
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Run linting:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv run ruff check src/ tests/
|
|
46
|
+
uv run ruff format --check src/ tests/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## How to submit changes
|
|
50
|
+
|
|
51
|
+
1. Fork the repository and create a feature branch
|
|
52
|
+
2. Write tests for your changes
|
|
53
|
+
3. Ensure all tests pass: `uv run pytest`
|
|
54
|
+
4. Ensure linting passes: `uv run ruff check src/ tests/`
|
|
55
|
+
5. Open a pull request
|
|
56
|
+
|
|
57
|
+
Your pull request needs to:
|
|
58
|
+
|
|
59
|
+
- Pass the test suite without errors
|
|
60
|
+
- Include tests for new functionality
|
|
61
|
+
- Update documentation if adding features
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2022 Dominik Kozaczko
|
|
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.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-getpaid-paynow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Paynow payment gateway integration for python-getpaid ecosystem.
|
|
5
|
+
Project-URL: Homepage, https://github.com/django-getpaid/python-getpaid-paynow
|
|
6
|
+
Project-URL: Repository, https://github.com/django-getpaid/python-getpaid-paynow
|
|
7
|
+
Project-URL: Changelog, https://github.com/django-getpaid/python-getpaid-paynow/releases
|
|
8
|
+
Author-email: Dominik Kozaczko <dominik@kozaczko.info>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
17
|
+
Classifier: Topic :: Office/Business :: Financial :: Point-Of-Sale
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: httpx>=0.27.0
|
|
21
|
+
Requires-Dist: python-getpaid-core>=0.1.0
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# getpaid-paynow
|
|
25
|
+
|
|
26
|
+
[](https://pypi.org/project/python-getpaid-paynow/)
|
|
27
|
+
[](https://pypi.org/project/python-getpaid-paynow/)
|
|
28
|
+
[](https://github.com/django-getpaid/python-getpaid-paynow/blob/main/LICENSE)
|
|
29
|
+
|
|
30
|
+
[Paynow](https://www.paynow.pl/) payment gateway plugin for the
|
|
31
|
+
[python-getpaid](https://github.com/django-getpaid) ecosystem. Provides an
|
|
32
|
+
async HTTP client (`PaynowClient`) and a payment processor (`PaynowProcessor`)
|
|
33
|
+
that integrates with getpaid-core's `BaseProcessor` interface. Authentication
|
|
34
|
+
uses API Key + HMAC-SHA256 signature against the Paynow V3 REST API.
|
|
35
|
+
|
|
36
|
+
## Architecture
|
|
37
|
+
|
|
38
|
+
The plugin is split into two layers:
|
|
39
|
+
|
|
40
|
+
- **`PaynowClient`** -- low-level async HTTP client wrapping the Paynow V3
|
|
41
|
+
REST API. Uses `httpx.AsyncClient` with API Key authentication and
|
|
42
|
+
HMAC-SHA256 request signing. Can be used standalone or as an async context
|
|
43
|
+
manager for connection reuse.
|
|
44
|
+
- **`PaynowProcessor`** -- high-level payment processor implementing
|
|
45
|
+
`BaseProcessor`. Orchestrates payment creation, callback/notification
|
|
46
|
+
handling, status polling, and refunds. Integrates with the getpaid-core FSM
|
|
47
|
+
for state transitions.
|
|
48
|
+
|
|
49
|
+
## Key Features
|
|
50
|
+
|
|
51
|
+
- **Create payment** -- register a payment and get a redirect URL
|
|
52
|
+
- **Notification handling** -- verify HMAC signature and process status changes
|
|
53
|
+
- **Status polling** -- fetch current payment status via API
|
|
54
|
+
- **Refund** -- create, check, and cancel refunds
|
|
55
|
+
- **Payment methods** -- retrieve available payment methods
|
|
56
|
+
- **HMAC-SHA256 signatures** -- automatic request and notification signing
|
|
57
|
+
- **PUSH and PULL** -- notification-based flow with optional status polling
|
|
58
|
+
|
|
59
|
+
## Quick Usage
|
|
60
|
+
|
|
61
|
+
### Standalone Client
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import asyncio
|
|
65
|
+
from decimal import Decimal
|
|
66
|
+
from getpaid_paynow import PaynowClient
|
|
67
|
+
|
|
68
|
+
async def main():
|
|
69
|
+
async with PaynowClient(
|
|
70
|
+
api_key="your-api-key",
|
|
71
|
+
signature_key="your-signature-key",
|
|
72
|
+
api_url="https://api.sandbox.paynow.pl",
|
|
73
|
+
) as client:
|
|
74
|
+
# Create a payment
|
|
75
|
+
response = await client.create_payment(
|
|
76
|
+
amount=Decimal("49.99"),
|
|
77
|
+
currency="PLN",
|
|
78
|
+
external_id="order-001",
|
|
79
|
+
description="Order #001",
|
|
80
|
+
buyer_email="buyer@example.com",
|
|
81
|
+
continue_url="https://shop.example.com/return/order-001",
|
|
82
|
+
)
|
|
83
|
+
redirect_url = response["redirectUrl"]
|
|
84
|
+
print(f"Redirect buyer to: {redirect_url}")
|
|
85
|
+
|
|
86
|
+
asyncio.run(main())
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### With django-getpaid
|
|
90
|
+
|
|
91
|
+
Register the plugin via entry point in `pyproject.toml`:
|
|
92
|
+
|
|
93
|
+
```toml
|
|
94
|
+
[project.entry-points."getpaid.backends"]
|
|
95
|
+
paynow = "getpaid_paynow.processor:PaynowProcessor"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Then configure in your Django settings (or config dict):
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
GETPAID_BACKEND_SETTINGS = {
|
|
102
|
+
"paynow": {
|
|
103
|
+
"api_key": "your-api-key",
|
|
104
|
+
"signature_key": "your-signature-key",
|
|
105
|
+
"sandbox": True,
|
|
106
|
+
"notification_url": "https://shop.example.com/payments/{payment_id}/callback/",
|
|
107
|
+
"continue_url": "https://shop.example.com/payments/{payment_id}/return/",
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Configuration Reference
|
|
113
|
+
|
|
114
|
+
| Key | Type | Default | Description |
|
|
115
|
+
|-----|------|---------|-------------|
|
|
116
|
+
| `api_key` | `str` | *required* | API key from Paynow merchant panel |
|
|
117
|
+
| `signature_key` | `str` | *required* | Signature key for HMAC calculation |
|
|
118
|
+
| `sandbox` | `bool` | `True` | Use sandbox or production API |
|
|
119
|
+
| `notification_url` | `str` | `""` | Notification URL template; use `{payment_id}` placeholder |
|
|
120
|
+
| `continue_url` | `str` | `""` | Return URL template; use `{payment_id}` placeholder |
|
|
121
|
+
|
|
122
|
+
## Supported Currencies
|
|
123
|
+
|
|
124
|
+
PLN, EUR, USD, GBP (4 total).
|
|
125
|
+
|
|
126
|
+
## Limitations
|
|
127
|
+
|
|
128
|
+
Paynow does not support pre-authorization. The `charge()` and
|
|
129
|
+
`release_lock()` methods raise `NotImplementedError`.
|
|
130
|
+
|
|
131
|
+
## Requirements
|
|
132
|
+
|
|
133
|
+
- Python 3.12+
|
|
134
|
+
- `python-getpaid-core >= 0.1.0`
|
|
135
|
+
- `httpx >= 0.27.0`
|
|
136
|
+
|
|
137
|
+
## Related Projects
|
|
138
|
+
|
|
139
|
+
- [python-getpaid-core](https://github.com/django-getpaid/python-getpaid-core) -- core abstractions (protocols, FSM, processor base class)
|
|
140
|
+
- [django-getpaid](https://github.com/django-getpaid/django-getpaid) -- Django adapter (models, views, admin)
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT
|
|
145
|
+
|
|
146
|
+
## Disclaimer
|
|
147
|
+
|
|
148
|
+
This project has nothing in common with the
|
|
149
|
+
[getpaid](http://code.google.com/p/getpaid/) plone project.
|
|
150
|
+
It is part of the `django-getpaid` / `python-getpaid` ecosystem.
|
|
151
|
+
|
|
152
|
+
## Credits
|
|
153
|
+
|
|
154
|
+
Created by [Dominik Kozaczko](https://github.com/dekoza).
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# getpaid-paynow
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/python-getpaid-paynow/)
|
|
4
|
+
[](https://pypi.org/project/python-getpaid-paynow/)
|
|
5
|
+
[](https://github.com/django-getpaid/python-getpaid-paynow/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
[Paynow](https://www.paynow.pl/) payment gateway plugin for the
|
|
8
|
+
[python-getpaid](https://github.com/django-getpaid) ecosystem. Provides an
|
|
9
|
+
async HTTP client (`PaynowClient`) and a payment processor (`PaynowProcessor`)
|
|
10
|
+
that integrates with getpaid-core's `BaseProcessor` interface. Authentication
|
|
11
|
+
uses API Key + HMAC-SHA256 signature against the Paynow V3 REST API.
|
|
12
|
+
|
|
13
|
+
## Architecture
|
|
14
|
+
|
|
15
|
+
The plugin is split into two layers:
|
|
16
|
+
|
|
17
|
+
- **`PaynowClient`** -- low-level async HTTP client wrapping the Paynow V3
|
|
18
|
+
REST API. Uses `httpx.AsyncClient` with API Key authentication and
|
|
19
|
+
HMAC-SHA256 request signing. Can be used standalone or as an async context
|
|
20
|
+
manager for connection reuse.
|
|
21
|
+
- **`PaynowProcessor`** -- high-level payment processor implementing
|
|
22
|
+
`BaseProcessor`. Orchestrates payment creation, callback/notification
|
|
23
|
+
handling, status polling, and refunds. Integrates with the getpaid-core FSM
|
|
24
|
+
for state transitions.
|
|
25
|
+
|
|
26
|
+
## Key Features
|
|
27
|
+
|
|
28
|
+
- **Create payment** -- register a payment and get a redirect URL
|
|
29
|
+
- **Notification handling** -- verify HMAC signature and process status changes
|
|
30
|
+
- **Status polling** -- fetch current payment status via API
|
|
31
|
+
- **Refund** -- create, check, and cancel refunds
|
|
32
|
+
- **Payment methods** -- retrieve available payment methods
|
|
33
|
+
- **HMAC-SHA256 signatures** -- automatic request and notification signing
|
|
34
|
+
- **PUSH and PULL** -- notification-based flow with optional status polling
|
|
35
|
+
|
|
36
|
+
## Quick Usage
|
|
37
|
+
|
|
38
|
+
### Standalone Client
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import asyncio
|
|
42
|
+
from decimal import Decimal
|
|
43
|
+
from getpaid_paynow import PaynowClient
|
|
44
|
+
|
|
45
|
+
async def main():
|
|
46
|
+
async with PaynowClient(
|
|
47
|
+
api_key="your-api-key",
|
|
48
|
+
signature_key="your-signature-key",
|
|
49
|
+
api_url="https://api.sandbox.paynow.pl",
|
|
50
|
+
) as client:
|
|
51
|
+
# Create a payment
|
|
52
|
+
response = await client.create_payment(
|
|
53
|
+
amount=Decimal("49.99"),
|
|
54
|
+
currency="PLN",
|
|
55
|
+
external_id="order-001",
|
|
56
|
+
description="Order #001",
|
|
57
|
+
buyer_email="buyer@example.com",
|
|
58
|
+
continue_url="https://shop.example.com/return/order-001",
|
|
59
|
+
)
|
|
60
|
+
redirect_url = response["redirectUrl"]
|
|
61
|
+
print(f"Redirect buyer to: {redirect_url}")
|
|
62
|
+
|
|
63
|
+
asyncio.run(main())
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### With django-getpaid
|
|
67
|
+
|
|
68
|
+
Register the plugin via entry point in `pyproject.toml`:
|
|
69
|
+
|
|
70
|
+
```toml
|
|
71
|
+
[project.entry-points."getpaid.backends"]
|
|
72
|
+
paynow = "getpaid_paynow.processor:PaynowProcessor"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Then configure in your Django settings (or config dict):
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
GETPAID_BACKEND_SETTINGS = {
|
|
79
|
+
"paynow": {
|
|
80
|
+
"api_key": "your-api-key",
|
|
81
|
+
"signature_key": "your-signature-key",
|
|
82
|
+
"sandbox": True,
|
|
83
|
+
"notification_url": "https://shop.example.com/payments/{payment_id}/callback/",
|
|
84
|
+
"continue_url": "https://shop.example.com/payments/{payment_id}/return/",
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Configuration Reference
|
|
90
|
+
|
|
91
|
+
| Key | Type | Default | Description |
|
|
92
|
+
|-----|------|---------|-------------|
|
|
93
|
+
| `api_key` | `str` | *required* | API key from Paynow merchant panel |
|
|
94
|
+
| `signature_key` | `str` | *required* | Signature key for HMAC calculation |
|
|
95
|
+
| `sandbox` | `bool` | `True` | Use sandbox or production API |
|
|
96
|
+
| `notification_url` | `str` | `""` | Notification URL template; use `{payment_id}` placeholder |
|
|
97
|
+
| `continue_url` | `str` | `""` | Return URL template; use `{payment_id}` placeholder |
|
|
98
|
+
|
|
99
|
+
## Supported Currencies
|
|
100
|
+
|
|
101
|
+
PLN, EUR, USD, GBP (4 total).
|
|
102
|
+
|
|
103
|
+
## Limitations
|
|
104
|
+
|
|
105
|
+
Paynow does not support pre-authorization. The `charge()` and
|
|
106
|
+
`release_lock()` methods raise `NotImplementedError`.
|
|
107
|
+
|
|
108
|
+
## Requirements
|
|
109
|
+
|
|
110
|
+
- Python 3.12+
|
|
111
|
+
- `python-getpaid-core >= 0.1.0`
|
|
112
|
+
- `httpx >= 0.27.0`
|
|
113
|
+
|
|
114
|
+
## Related Projects
|
|
115
|
+
|
|
116
|
+
- [python-getpaid-core](https://github.com/django-getpaid/python-getpaid-core) -- core abstractions (protocols, FSM, processor base class)
|
|
117
|
+
- [django-getpaid](https://github.com/django-getpaid/django-getpaid) -- Django adapter (models, views, admin)
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
|
122
|
+
|
|
123
|
+
## Disclaimer
|
|
124
|
+
|
|
125
|
+
This project has nothing in common with the
|
|
126
|
+
[getpaid](http://code.google.com/p/getpaid/) plone project.
|
|
127
|
+
It is part of the `django-getpaid` / `python-getpaid` ecosystem.
|
|
128
|
+
|
|
129
|
+
## Credits
|
|
130
|
+
|
|
131
|
+
Created by [Dominik Kozaczko](https://github.com/dekoza).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v0.1.0 (2026-02-14)
|
|
4
|
+
|
|
5
|
+
Initial release.
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- Full Paynow V3 REST API coverage
|
|
10
|
+
- Async HTTP client (`PaynowClient`) with API Key + HMAC-SHA256 signing
|
|
11
|
+
- Payment processor (`PaynowProcessor`) implementing `BaseProcessor`
|
|
12
|
+
- Payment creation with redirect URL
|
|
13
|
+
- HMAC-SHA256 signature calculation and verification
|
|
14
|
+
- Notification (PUSH) callback handling
|
|
15
|
+
- Status polling (PULL) via API
|
|
16
|
+
- Refund support (create, check status, cancel)
|
|
17
|
+
- Payment methods retrieval
|
|
18
|
+
- Amount conversion (`Decimal` ↔ integer lowest currency unit)
|
|
19
|
+
- Support for PLN, EUR, USD, GBP currencies
|