mm-aggr-sdk 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.
Files changed (115) hide show
  1. mm_aggr_sdk-0.1.1/.cursor/rules/api-source-of-truth.mdc +13 -0
  2. mm_aggr_sdk-0.1.1/.cursor/rules/currency-safety.mdc +10 -0
  3. mm_aggr_sdk-0.1.1/.cursor/rules/docs-audience.mdc +13 -0
  4. mm_aggr_sdk-0.1.1/.cursor/rules/license.mdc +10 -0
  5. mm_aggr_sdk-0.1.1/.cursor/rules/python.mdc +10 -0
  6. mm_aggr_sdk-0.1.1/.cursor/skills/add-python-api-resource/SKILL.md +12 -0
  7. mm_aggr_sdk-0.1.1/.env.example +5 -0
  8. mm_aggr_sdk-0.1.1/.github/copilot-instructions.md +7 -0
  9. mm_aggr_sdk-0.1.1/.github/workflows/ci.yml +23 -0
  10. mm_aggr_sdk-0.1.1/.github/workflows/publish.yml +41 -0
  11. mm_aggr_sdk-0.1.1/.gitignore +11 -0
  12. mm_aggr_sdk-0.1.1/.python-version +1 -0
  13. mm_aggr_sdk-0.1.1/AGENTS.md +5 -0
  14. mm_aggr_sdk-0.1.1/CHANGELOG.md +7 -0
  15. mm_aggr_sdk-0.1.1/CLA.md +24 -0
  16. mm_aggr_sdk-0.1.1/CLAUDE.md +3 -0
  17. mm_aggr_sdk-0.1.1/CONTRIBUTING.md +50 -0
  18. mm_aggr_sdk-0.1.1/CONVENTIONS.md +8 -0
  19. mm_aggr_sdk-0.1.1/LICENSE +21 -0
  20. mm_aggr_sdk-0.1.1/PKG-INFO +121 -0
  21. mm_aggr_sdk-0.1.1/README.md +91 -0
  22. mm_aggr_sdk-0.1.1/docs/README.md +4 -0
  23. mm_aggr_sdk-0.1.1/examples/README.md +14 -0
  24. mm_aggr_sdk-0.1.1/examples/django-drf/.env.example +9 -0
  25. mm_aggr_sdk-0.1.1/examples/django-drf/.gitignore +8 -0
  26. mm_aggr_sdk-0.1.1/examples/django-drf/README.md +53 -0
  27. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/__init__.py +0 -0
  28. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/apps.py +6 -0
  29. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/client.py +16 -0
  30. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/management/__init__.py +0 -0
  31. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/management/commands/__init__.py +0 -0
  32. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/management/commands/seed.py +16 -0
  33. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/migrations/0001_initial.py +57 -0
  34. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/migrations/__init__.py +0 -0
  35. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/models.py +37 -0
  36. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/proxy.py +129 -0
  37. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/sessions.py +59 -0
  38. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/urls.py +15 -0
  39. mm_aggr_sdk-0.1.1/examples/django-drf/catalog/views.py +257 -0
  40. mm_aggr_sdk-0.1.1/examples/django-drf/data/initial.sqlite3 +0 -0
  41. mm_aggr_sdk-0.1.1/examples/django-drf/manage.py +18 -0
  42. mm_aggr_sdk-0.1.1/examples/django-drf/pyproject.toml +18 -0
  43. mm_aggr_sdk-0.1.1/examples/django-drf/scripts/export-initial-db +10 -0
  44. mm_aggr_sdk-0.1.1/examples/django-drf/scripts/reset-db +9 -0
  45. mm_aggr_sdk-0.1.1/examples/django-drf/scripts/seed +8 -0
  46. mm_aggr_sdk-0.1.1/examples/django-drf/shop/__init__.py +0 -0
  47. mm_aggr_sdk-0.1.1/examples/django-drf/shop/asgi.py +8 -0
  48. mm_aggr_sdk-0.1.1/examples/django-drf/shop/settings.py +63 -0
  49. mm_aggr_sdk-0.1.1/examples/django-drf/shop/urls.py +7 -0
  50. mm_aggr_sdk-0.1.1/examples/django-drf/shop/wsgi.py +8 -0
  51. mm_aggr_sdk-0.1.1/examples/django-drf/uv.lock +322 -0
  52. mm_aggr_sdk-0.1.1/examples/fastapi/.env.example +7 -0
  53. mm_aggr_sdk-0.1.1/examples/fastapi/.gitignore +8 -0
  54. mm_aggr_sdk-0.1.1/examples/fastapi/README.md +45 -0
  55. mm_aggr_sdk-0.1.1/examples/fastapi/app.py +288 -0
  56. mm_aggr_sdk-0.1.1/examples/fastapi/client.py +16 -0
  57. mm_aggr_sdk-0.1.1/examples/fastapi/data/initial.sqlite3 +0 -0
  58. mm_aggr_sdk-0.1.1/examples/fastapi/db.py +80 -0
  59. mm_aggr_sdk-0.1.1/examples/fastapi/proxy.py +134 -0
  60. mm_aggr_sdk-0.1.1/examples/fastapi/pyproject.toml +18 -0
  61. mm_aggr_sdk-0.1.1/examples/fastapi/scripts/export-initial-db +10 -0
  62. mm_aggr_sdk-0.1.1/examples/fastapi/scripts/reset-db +9 -0
  63. mm_aggr_sdk-0.1.1/examples/fastapi/scripts/seed +8 -0
  64. mm_aggr_sdk-0.1.1/examples/fastapi/sessions.py +59 -0
  65. mm_aggr_sdk-0.1.1/examples/fastapi/uv.lock +954 -0
  66. mm_aggr_sdk-0.1.1/examples/flask/.env.example +7 -0
  67. mm_aggr_sdk-0.1.1/examples/flask/.gitignore +8 -0
  68. mm_aggr_sdk-0.1.1/examples/flask/README.md +45 -0
  69. mm_aggr_sdk-0.1.1/examples/flask/app.py +280 -0
  70. mm_aggr_sdk-0.1.1/examples/flask/client.py +16 -0
  71. mm_aggr_sdk-0.1.1/examples/flask/data/initial.sqlite3 +0 -0
  72. mm_aggr_sdk-0.1.1/examples/flask/db.py +80 -0
  73. mm_aggr_sdk-0.1.1/examples/flask/proxy.py +134 -0
  74. mm_aggr_sdk-0.1.1/examples/flask/pyproject.toml +18 -0
  75. mm_aggr_sdk-0.1.1/examples/flask/scripts/export-initial-db +10 -0
  76. mm_aggr_sdk-0.1.1/examples/flask/scripts/reset-db +9 -0
  77. mm_aggr_sdk-0.1.1/examples/flask/scripts/seed +8 -0
  78. mm_aggr_sdk-0.1.1/examples/flask/sessions.py +59 -0
  79. mm_aggr_sdk-0.1.1/examples/flask/uv.lock +524 -0
  80. mm_aggr_sdk-0.1.1/poetry.lock +738 -0
  81. mm_aggr_sdk-0.1.1/pyproject.toml +78 -0
  82. mm_aggr_sdk-0.1.1/src/mm_aggr/__init__.py +20 -0
  83. mm_aggr_sdk-0.1.1/src/mm_aggr/auth/__init__.py +1 -0
  84. mm_aggr_sdk-0.1.1/src/mm_aggr/auth/access_token.py +24 -0
  85. mm_aggr_sdk-0.1.1/src/mm_aggr/auth/token_store.py +89 -0
  86. mm_aggr_sdk-0.1.1/src/mm_aggr/client.py +71 -0
  87. mm_aggr_sdk-0.1.1/src/mm_aggr/exceptions.py +46 -0
  88. mm_aggr_sdk-0.1.1/src/mm_aggr/http/__init__.py +7 -0
  89. mm_aggr_sdk-0.1.1/src/mm_aggr/http/http_client.py +14 -0
  90. mm_aggr_sdk-0.1.1/src/mm_aggr/http/http_response.py +15 -0
  91. mm_aggr_sdk-0.1.1/src/mm_aggr/http/requests_client.py +64 -0
  92. mm_aggr_sdk-0.1.1/src/mm_aggr/http/transport.py +109 -0
  93. mm_aggr_sdk-0.1.1/src/mm_aggr/py.typed +0 -0
  94. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/__init__.py +1 -0
  95. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/amount_limits.py +13 -0
  96. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/checkout_preferences.py +11 -0
  97. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/countries.py +13 -0
  98. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/customers.py +31 -0
  99. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/deposits.py +20 -0
  100. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/fees.py +16 -0
  101. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/payouts.py +35 -0
  102. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/providers.py +13 -0
  103. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/refunds.py +17 -0
  104. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/remittances.py +17 -0
  105. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/resource.py +15 -0
  106. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/status.py +14 -0
  107. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/transactions.py +16 -0
  108. mm_aggr_sdk-0.1.1/src/mm_aggr/resources/wallets.py +13 -0
  109. mm_aggr_sdk-0.1.1/src/mm_aggr/webhook/__init__.py +1 -0
  110. mm_aggr_sdk-0.1.1/src/mm_aggr/webhook/verifier.py +24 -0
  111. mm_aggr_sdk-0.1.1/tests/__init__.py +0 -0
  112. mm_aggr_sdk-0.1.1/tests/mock_http_client.py +22 -0
  113. mm_aggr_sdk-0.1.1/tests/test_client.py +288 -0
  114. mm_aggr_sdk-0.1.1/tests/test_webhook_verifier.py +41 -0
  115. mm_aggr_sdk-0.1.1/uv.lock +602 -0
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: Merchant OpenAPI is the source of truth; do not invent endpoints
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # API source of truth
7
+
8
+ - Implement only operations in the contrib hub pin
9
+ `contract/openapi/merchants.openapi.yaml` (nested checkout:
10
+ `contrib/contract/` from `mm_aggregator`) and `/api/v1/schema/merchants/`.
11
+ - Cross-check the live schema if the pin may be behind. Do not invent paths,
12
+ headers, or error codes.
13
+ - Never put merchant API keys in frontend or plugin JavaScript.
@@ -0,0 +1,10 @@
1
+ ---
2
+ description: Never mix monetary amounts across currencies
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Currency safety
7
+
8
+ - Never add, subtract, compare, or aggregate amounts across currencies.
9
+ - Group values by currency code. Cross-currency math requires an explicit FX
10
+ context (rate source and applied rate).
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: README is for installers; CONTRIBUTING is for people who change this repo
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Documentation audience
7
+
8
+ - `README.md` is for application developers installing this package. Install,
9
+ requirements, quick start, credentials. No git branches, PR process, or
10
+ coding standards except a single link to `CONTRIBUTING.md`.
11
+ - `CONTRIBUTING.md` is for contributors. Clone, toolchain, tests, CLA, commits.
12
+ Do not duplicate merchant install steps from README.
13
+ - Never mix these audiences.
@@ -0,0 +1,10 @@
1
+ ---
2
+ description: MIT license and CLA for MainMoney SARL
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # License
7
+
8
+ - Copyright (c) MainMoney SARL. Outbound license: MIT.
9
+ - Pull requests require `CLA.md` so contributions vest in MainMoney SARL.
10
+ - Keep the license headers and manifest SPDX ids consistent with `LICENSE`.
@@ -0,0 +1,10 @@
1
+ ---
2
+ description: Python SDK coding standards
3
+ globs: "**/*.py"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Python
8
+
9
+ - Type hints on public functions. pytest for tests. ruff for format and lint.
10
+ - Prefer uv; keep Poetry lockfile in sync when dependencies change.
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: add-python-api-resource
3
+ description: Add a merchant API resource to the MainMoney Python SDK from OpenAPI
4
+ ---
5
+
6
+ # Add a Python API resource
7
+
8
+ 1. Read the pinned contract `contrib/contract/openapi/merchants.openapi.yaml`
9
+ (and `contrib/contract/resources.md`). Cross-check live
10
+ `/api/v1/schema/merchants/` if the pin may be behind. Do not invent endpoints.
11
+ 2. Add a typed method on the client with pytest coverage.
12
+ 3. Update README with the installer-facing call only.
@@ -0,0 +1,5 @@
1
+ MM_CLIENT_ID=
2
+ MM_API_SECRET=
3
+ # Optional. Default production: https://aggregator.mainmoney.net/api/v1/
4
+ # Test: https://testaggregator.mainmoney.net/api/v1/ (Client test=True)
5
+ # MM_BASE_URI=
@@ -0,0 +1,7 @@
1
+ # Copilot instructions
2
+
3
+ Project: MainMoney Python SDK.
4
+
5
+ - Follow CONVENTIONS.md and .cursor/rules.
6
+ - README is for package users; CONTRIBUTING is for repo contributors.
7
+ - Do not invent merchant API endpoints.
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ python: ["3.11", "3.12", "3.13", "3.14"]
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: astral-sh/setup-uv@v6
17
+ with:
18
+ python-version: ${{ matrix.python }}
19
+ - run: uv sync --all-extras --dev
20
+ - run: uv run ruff check .
21
+ - run: uv run ruff format --check .
22
+ - run: uv run mypy src
23
+ - run: uv run pytest
@@ -0,0 +1,41 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: astral-sh/setup-uv@v6
14
+ with:
15
+ python-version: "3.13"
16
+ - name: Tag matches package version
17
+ run: |
18
+ version="$(sed -n 's/^__version__ = "\(.*\)"/\1/p' src/mm_aggr/__init__.py)"
19
+ test "v${version}" = "${GITHUB_REF_NAME}" || { echo "Tag ${GITHUB_REF_NAME} != v${version}"; exit 1; }
20
+ - run: uv sync --all-extras --dev
21
+ - run: uv run ruff check .
22
+ - run: uv run mypy src
23
+ - run: uv run pytest
24
+ - run: uv build
25
+ - uses: actions/upload-artifact@v4
26
+ with:
27
+ name: dist
28
+ path: dist/
29
+
30
+ publish:
31
+ needs: build
32
+ runs-on: ubuntu-latest
33
+ environment: pypi
34
+ permissions:
35
+ id-token: write # PyPI Trusted Publishing
36
+ steps:
37
+ - uses: actions/download-artifact@v4
38
+ with:
39
+ name: dist
40
+ path: dist/
41
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ .mypy_cache/
5
+ .ruff_cache/
6
+ .pytest_cache/
7
+ dist/
8
+ *.egg-info/
9
+ .env
10
+ .env.*
11
+ !.env.example
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,5 @@
1
+ # MainMoney Python SDK — agent instructions
2
+
3
+ Read `CONVENTIONS.md`, `CONTRIBUTING.md`, and `.cursor/rules/` before changing code.
4
+
5
+ `README.md` is for installers only. Do not put contribution workflow there.
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ - Relicensed under the MIT License.
6
+ - Distribution renamed to `mm-aggr-sdk` on PyPI (the import package is still `mm_aggr`).
7
+ - First release published to PyPI.
@@ -0,0 +1,24 @@
1
+ # Contributor License Agreement
2
+
3
+ Copyright owner: **MainMoney SARL**
4
+
5
+ By submitting a contribution (including a pull request, patch, or issue
6
+ attachment) to this repository, you agree that:
7
+
8
+ 1. You grant MainMoney SARL a perpetual, worldwide, irrevocable, royalty-free,
9
+ sublicensable copyright and patent license to use, reproduce, modify,
10
+ create derivative works of, publicly display, publicly perform, and
11
+ distribute your contribution, and to relicense it (including under a
12
+ commercial license).
13
+ 2. You assign to MainMoney SARL all right, title, and interest in the
14
+ contribution to the extent permitted by law. If assignment is not
15
+ effective, the license in (1) still applies.
16
+ 3. You represent that the contribution is your original work, or that you have
17
+ the right to grant these terms, and that the contribution does not
18
+ knowingly infringe third-party rights.
19
+ 4. You retain the right to be identified as the author of the contribution.
20
+
21
+ MainMoney SARL may use contributions in proprietary products and distributes this
22
+ repository under the MIT License.
23
+
24
+ This is not legal advice. Individual and entity contributors are both covered.
@@ -0,0 +1,3 @@
1
+ # MainMoney Python SDK
2
+
3
+ Follow `CONVENTIONS.md` and `.cursor/rules/`. README = installers; CONTRIBUTING = contributors. License is MIT (MainMoney SARL).
@@ -0,0 +1,50 @@
1
+ # Contributing
2
+
3
+ This document is for people who change **this repository**. To install the
4
+ package into an application, see [README.md](README.md).
5
+
6
+ ## Legal
7
+
8
+ Pull requests require agreement to [CLA.md](CLA.md). Contributions are owned
9
+ by MainMoney SARL.
10
+
11
+ ## Clone
12
+
13
+ ```bash
14
+ git clone git@github.com:MainMoney-Inc/mm_aggr_python_sdk.git
15
+ ```
16
+
17
+ ## Setup
18
+
19
+ ```bash
20
+ uv sync --all-extras
21
+ # or: poetry install
22
+ uv run pytest
23
+ uv run mypy src
24
+ uv run ruff check .
25
+ uv run ruff format --check .
26
+ ```
27
+
28
+ ## PyPI
29
+
30
+ The distribution name is `mm-aggr-sdk` (import package `mm_aggr`). Releases are
31
+ automated: bump `__version__` in `src/mm_aggr/__init__.py`, update `CHANGELOG.md`, then
32
+ push an annotated tag `vX.Y.Z`. The `Publish` workflow builds and uploads to
33
+ [PyPI](https://pypi.org/project/mm-aggr-sdk/) through Trusted Publishing (workflow
34
+ `publish.yml`, environment `pypi`). Do not commit PyPI tokens.
35
+
36
+ ## Branches and commits
37
+
38
+ - `feature/<name>`, `bugfix/<name>`, `hotfix/<issue>`, `refactor/<description>`
39
+ - Conventional commits: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
40
+
41
+ ## Pull requests
42
+
43
+ - Include tests for behavior changes.
44
+ - Do not invent merchant API endpoints. Implement from the pinned OpenAPI in
45
+ the contrib hub (`contract/openapi/merchants.openapi.yaml`, checkout path
46
+ `contrib/contract/` from `mm_aggregator`). Cross-check live
47
+ `/api/v1/schema/merchants/` if the pin may be behind.
48
+ - Do not commit secrets.
49
+ - Local demos live under `examples/`. Working SQLite (`db.sqlite3`) is gitignored;
50
+ commit `data/initial.sqlite3` only when the mini-shop schema or catalog changes.
@@ -0,0 +1,8 @@
1
+ # Conventions
2
+
3
+ - Python 3.11+ (develop on 3.13/3.14). Type hints and mypy-compatible code.
4
+ - Package layout: `src/mm_aggr/`. uv is the primary toolchain; Poetry is supported.
5
+ - pytest, ruff. No empty `except:` swallows.
6
+ - HTTP via injectable `HttpClient` (default `RequestsHttpClient`, `requests` runtime dependency).
7
+ - Currency: never mix amounts across currencies.
8
+ - Do not call the aggregator from this SDK with invented paths.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MainMoney SARL
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,121 @@
1
+ Metadata-Version: 2.5
2
+ Name: mm-aggr-sdk
3
+ Version: 0.1.1
4
+ Summary: Python SDK for the MainMoney aggregator merchant API
5
+ Project-URL: Homepage, https://github.com/MainMoney-Inc/mm_aggr_python_sdk
6
+ Project-URL: Issues, https://github.com/MainMoney-Inc/mm_aggr_python_sdk/issues
7
+ Project-URL: Changelog, https://github.com/MainMoney-Inc/mm_aggr_python_sdk/blob/main/CHANGELOG.md
8
+ Project-URL: Source, https://github.com/MainMoney-Inc/mm_aggr_python_sdk
9
+ Author: MainMoney SARL
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: mainmoney,merchant,payments,sdk
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: requests>=2.32.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: mypy>=1.11.0; extra == 'dev'
26
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.6.0; extra == 'dev'
28
+ Requires-Dist: types-requests>=2.32.0; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # MainMoney Python SDK
32
+
33
+ Python client for the MainMoney aggregator merchant API. Install this package
34
+ in your Python application (Django, FastAPI, Flask, or scripts).
35
+
36
+ The [JS/TS frontend SDK](https://github.com/MainMoney-Inc/mm_aggr_js_sdk) can
37
+ be used in the browser only if this SDK (or the PHP or Node SDK) runs on your
38
+ server. Never put merchant API keys in frontend code.
39
+
40
+ ## Requirements
41
+
42
+ - Python 3.11 or later (3.13 or 3.14 recommended)
43
+ - A merchant application on MM Aggregator
44
+
45
+ ## Install
46
+
47
+ With uv (recommended):
48
+
49
+ ```bash
50
+ uv add mm-aggr-sdk
51
+ ```
52
+
53
+ With pip:
54
+
55
+ ```bash
56
+ pip install mm-aggr-sdk
57
+ ```
58
+
59
+ With Poetry:
60
+
61
+ ```bash
62
+ poetry add mm-aggr-sdk
63
+ ```
64
+
65
+ Until the package is on PyPI, install from GitHub:
66
+
67
+ ```bash
68
+ pip install git+https://github.com/MainMoney-Inc/mm_aggr_python_sdk.git
69
+ ```
70
+
71
+ ## Quick start
72
+
73
+ ```python
74
+ import os
75
+
76
+ from mm_aggr import Client
77
+
78
+ client = Client(
79
+ client_id=os.environ["MM_CLIENT_ID"],
80
+ secret=os.environ["MM_API_SECRET"],
81
+ test=True, # https://testaggregator.mainmoney.net — omit for production
82
+ )
83
+
84
+ deposit = client.deposits.create(
85
+ {
86
+ "provider_code": "VODACOM_MPESA_COD",
87
+ "reference": "ORDER-123",
88
+ "amount": "100.00",
89
+ "currency": "USD",
90
+ "customer_phone": "243820000000",
91
+ },
92
+ idempotency_key="ORDER-123",
93
+ )
94
+ ```
95
+
96
+ Defaults: production `https://aggregator.mainmoney.net/api/v1/`, test
97
+ `https://testaggregator.mainmoney.net/api/v1/`. Pass `base_uri` only to override.
98
+ Configure credentials from your environment. Merchant API docs:
99
+ `/api/v1/docs/merchants/` on the aggregator host.
100
+
101
+ Exchange `client_id` and `secret` for a Bearer access token is handled by the
102
+ SDK. There is no `X-API-KEY` header. Reuse the same `reference` and optional
103
+ `Idempotency-Key` when retrying a create. Amounts are decimal strings; do not
104
+ mix currencies.
105
+
106
+ Verify inbound webhooks with
107
+ `client.webhooks.verify(raw_body, signature, secret)`.
108
+
109
+ Do not send merchant API keys to the browser.
110
+
111
+ ## License
112
+
113
+ Copyright (c) 2026 MainMoney SARL. Licensed under the MIT License. See [LICENSE](LICENSE).
114
+
115
+ ## Examples
116
+
117
+ Runnable mini-shops live in [examples/](examples/). Each folder has its own
118
+ README (Django REST Framework, FastAPI, Flask). Pair them with a
119
+ [JS/TS frontend example](https://github.com/MainMoney-Inc/mm_aggr_js_sdk/tree/main/examples).
120
+
121
+ Want to contribute? See [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -0,0 +1,91 @@
1
+ # MainMoney Python SDK
2
+
3
+ Python client for the MainMoney aggregator merchant API. Install this package
4
+ in your Python application (Django, FastAPI, Flask, or scripts).
5
+
6
+ The [JS/TS frontend SDK](https://github.com/MainMoney-Inc/mm_aggr_js_sdk) can
7
+ be used in the browser only if this SDK (or the PHP or Node SDK) runs on your
8
+ server. Never put merchant API keys in frontend code.
9
+
10
+ ## Requirements
11
+
12
+ - Python 3.11 or later (3.13 or 3.14 recommended)
13
+ - A merchant application on MM Aggregator
14
+
15
+ ## Install
16
+
17
+ With uv (recommended):
18
+
19
+ ```bash
20
+ uv add mm-aggr-sdk
21
+ ```
22
+
23
+ With pip:
24
+
25
+ ```bash
26
+ pip install mm-aggr-sdk
27
+ ```
28
+
29
+ With Poetry:
30
+
31
+ ```bash
32
+ poetry add mm-aggr-sdk
33
+ ```
34
+
35
+ Until the package is on PyPI, install from GitHub:
36
+
37
+ ```bash
38
+ pip install git+https://github.com/MainMoney-Inc/mm_aggr_python_sdk.git
39
+ ```
40
+
41
+ ## Quick start
42
+
43
+ ```python
44
+ import os
45
+
46
+ from mm_aggr import Client
47
+
48
+ client = Client(
49
+ client_id=os.environ["MM_CLIENT_ID"],
50
+ secret=os.environ["MM_API_SECRET"],
51
+ test=True, # https://testaggregator.mainmoney.net — omit for production
52
+ )
53
+
54
+ deposit = client.deposits.create(
55
+ {
56
+ "provider_code": "VODACOM_MPESA_COD",
57
+ "reference": "ORDER-123",
58
+ "amount": "100.00",
59
+ "currency": "USD",
60
+ "customer_phone": "243820000000",
61
+ },
62
+ idempotency_key="ORDER-123",
63
+ )
64
+ ```
65
+
66
+ Defaults: production `https://aggregator.mainmoney.net/api/v1/`, test
67
+ `https://testaggregator.mainmoney.net/api/v1/`. Pass `base_uri` only to override.
68
+ Configure credentials from your environment. Merchant API docs:
69
+ `/api/v1/docs/merchants/` on the aggregator host.
70
+
71
+ Exchange `client_id` and `secret` for a Bearer access token is handled by the
72
+ SDK. There is no `X-API-KEY` header. Reuse the same `reference` and optional
73
+ `Idempotency-Key` when retrying a create. Amounts are decimal strings; do not
74
+ mix currencies.
75
+
76
+ Verify inbound webhooks with
77
+ `client.webhooks.verify(raw_body, signature, secret)`.
78
+
79
+ Do not send merchant API keys to the browser.
80
+
81
+ ## License
82
+
83
+ Copyright (c) 2026 MainMoney SARL. Licensed under the MIT License. See [LICENSE](LICENSE).
84
+
85
+ ## Examples
86
+
87
+ Runnable mini-shops live in [examples/](examples/). Each folder has its own
88
+ README (Django REST Framework, FastAPI, Flask). Pair them with a
89
+ [JS/TS frontend example](https://github.com/MainMoney-Inc/mm_aggr_js_sdk/tree/main/examples).
90
+
91
+ Want to contribute? See [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -0,0 +1,4 @@
1
+ # Python SDK docs
2
+
3
+ User install guide: [../README.md](../README.md).
4
+ Contributor setup: [../CONTRIBUTING.md](../CONTRIBUTING.md).
@@ -0,0 +1,14 @@
1
+ # Python SDK examples
2
+
3
+ Standalone mini-shops that use the `mm-aggr-sdk` package. Each folder is its own
4
+ uv project. Start **one** backend, then point a
5
+ [JS/TS frontend example](https://github.com/MainMoney-Inc/mm_aggr_js_sdk/tree/main/examples)
6
+ at it with `VITE_MERCHANT_BACKEND_URL`.
7
+
8
+ | Example | Port | Start |
9
+ | --- | --- | --- |
10
+ | [django-drf](django-drf/) | 8000 | See that folder’s README |
11
+ | [fastapi](fastapi/) | 8001 | See that folder’s README |
12
+ | [flask](flask/) | 8002 | See that folder’s README |
13
+
14
+ Same app in every example: choose a product, pay (deposit), refund, transfer (payout).
@@ -0,0 +1,9 @@
1
+ MM_CLIENT_ID=
2
+ MM_API_SECRET=
3
+ MM_TEST=true
4
+ MM_WEBHOOK_SECRET=
5
+ # Optional. Override aggregator host (local or custom).
6
+ # MM_BASE_URI=https://testaggregator.mainmoney.net/api/v1/
7
+ PORT=8000
8
+ CORS_ORIGINS=http://127.0.0.1:5173,http://127.0.0.1:5174,http://127.0.0.1:5175,http://127.0.0.1:4200,http://localhost:5173,http://localhost:5174,http://localhost:5175,http://localhost:4200
9
+ DJANGO_SECRET_KEY=django-drf-example-change-me
@@ -0,0 +1,8 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ db.sqlite3
5
+ *.sqlite3-journal
6
+ .env
7
+ .env.*
8
+ !.env.example
@@ -0,0 +1,53 @@
1
+ # Django REST Framework mini-shop
2
+
3
+ Standalone example that installs [`mm-aggr-sdk`](https://github.com/MainMoney-Inc/mm_aggr_python_sdk)
4
+ as a package and exposes the same shop API as the other SDK examples.
5
+
6
+ Pages a frontend can drive: products, pay (deposit), refund, transfer (payout).
7
+
8
+ Default port: **8000**.
9
+
10
+ ## Setup
11
+
12
+ ```bash
13
+ cp .env.example .env
14
+ # set MM_CLIENT_ID, MM_API_SECRET, and MM_WEBHOOK_SECRET
15
+ uv sync
16
+ ./scripts/reset-db
17
+ ```
18
+
19
+ Until PyPI lists `mm-aggr-sdk`, `uv sync` installs it from GitHub (see `pyproject.toml`).
20
+
21
+ If `db.sqlite3` is missing, `./scripts/reset-db` copies the committed snapshot
22
+ `data/initial.sqlite3`. To refill products after a migrate:
23
+
24
+ ```bash
25
+ ./scripts/seed
26
+ ```
27
+
28
+ Update `data/initial.sqlite3` only when the schema or catalog changes:
29
+
30
+ ```bash
31
+ uv run python manage.py migrate
32
+ ./scripts/seed
33
+ ./scripts/export-initial-db
34
+ ```
35
+
36
+ Do not commit `db.sqlite3` (local orders and test refunds stay on your machine).
37
+
38
+ ## Run
39
+
40
+ ```bash
41
+ uv run python manage.py runserver 8000
42
+ ```
43
+
44
+ Then start a JS frontend example and set:
45
+
46
+ ```
47
+ VITE_MERCHANT_BACKEND_URL=http://127.0.0.1:8000
48
+ ```
49
+
50
+ Aggregator webhooks cannot reach `localhost`. Use a tunnel if you want
51
+ `POST /webhooks` to fire. Status polling works without a public URL.
52
+
53
+ Webhook URL (after a tunnel): `https://your-host.example/webhooks`
@@ -0,0 +1,6 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class CatalogConfig(AppConfig):
5
+ default_auto_field = "django.db.models.AutoField"
6
+ name = "catalog"
@@ -0,0 +1,16 @@
1
+ """Build a MainMoney SDK client from Django settings."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from django.conf import settings
6
+
7
+
8
+ def get_client():
9
+ from mm_aggr import Client
10
+
11
+ return Client(
12
+ client_id=settings.MM_CLIENT_ID,
13
+ secret=settings.MM_API_SECRET,
14
+ base_uri=settings.MM_BASE_URI,
15
+ test=settings.MM_TEST,
16
+ )
@@ -0,0 +1,16 @@
1
+ from django.core.management.base import BaseCommand
2
+
3
+ from catalog.models import Product
4
+ from catalog.views import DEMO_PRODUCTS
5
+
6
+
7
+ class Command(BaseCommand):
8
+ help = "Insert demo products if the catalog is empty."
9
+
10
+ def handle(self, *args: object, **options: object) -> None:
11
+ created = 0
12
+ for item in DEMO_PRODUCTS:
13
+ _, was_created = Product.objects.get_or_create(sku=item["sku"], defaults=item)
14
+ if was_created:
15
+ created += 1
16
+ self.stdout.write(f"Seeded {created} products ({Product.objects.count()} total).")