mtnmomo-py 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.
@@ -0,0 +1,68 @@
1
+ name: Test, Build, and Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "*"
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ jobs:
13
+ test:
14
+ name: Test (Python ${{ matrix.python-version }})
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+ - name: Install package and test dependencies
26
+ run: python -m pip install --upgrade pip && python -m pip install -e ".[test]"
27
+ - name: Run unit tests
28
+ run: python -m pytest -m "not integration"
29
+
30
+ build:
31
+ name: Build distribution
32
+ needs: test
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@v4
36
+ - uses: actions/setup-python@v5
37
+ with:
38
+ python-version: "3.13"
39
+ - name: Install build tooling
40
+ run: python -m pip install --upgrade pip build twine
41
+ - name: Build package
42
+ run: python -m build
43
+ - name: Verify distribution metadata
44
+ run: python -m twine check dist/*
45
+ - name: Upload distribution artifact
46
+ uses: actions/upload-artifact@v4
47
+ with:
48
+ name: python-distribution
49
+ path: dist/
50
+ if-no-files-found: error
51
+
52
+ publish:
53
+ name: Publish to PyPI
54
+ needs: build
55
+ runs-on: ubuntu-latest
56
+ environment:
57
+ name: pypi
58
+ url: https://pypi.org/p/mtnmomo-py
59
+ permissions:
60
+ id-token: write
61
+ steps:
62
+ - name: Download distribution artifact
63
+ uses: actions/download-artifact@v4
64
+ with:
65
+ name: python-distribution
66
+ path: dist/
67
+ - name: Publish distribution to PyPI
68
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,13 @@
1
+ credentials.json
2
+ .env
3
+ .venv/
4
+ venv/
5
+ __pycache__/
6
+ *.py[cod]
7
+ .pytest_cache/
8
+ .coverage
9
+ coverage.xml
10
+ htmlcov/
11
+ build/
12
+ dist/
13
+ *.egg-info/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Robin
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,128 @@
1
+ Metadata-Version: 2.4
2
+ Name: mtnmomo-py
3
+ Version: 0.1.0
4
+ Summary: Typed synchronous client for the MTN MoMo APIs
5
+ Project-URL: Homepage, https://github.com/robin-001/mtnmomo-py
6
+ Project-URL: Repository, https://github.com/robin-001/mtnmomo-py.git
7
+ Project-URL: Issues, https://github.com/robin-001/mtnmomo-py/issues
8
+ Author: Robin
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: api-client,mobile-money,momo,mtn,payments
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: httpx<1,>=0.27
24
+ Provides-Extra: test
25
+ Requires-Dist: build<2,>=1.2; extra == 'test'
26
+ Requires-Dist: pytest<9,>=8; extra == 'test'
27
+ Requires-Dist: respx<1,>=0.21; extra == 'test'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # mtnmomo-py
31
+
32
+ `mtnmomo-py` is a synchronous Python 3.10+ client for the MTN MoMo Collection, Disbursement, OAuth/CIBA, and Sandbox Provisioning APIs.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install mtnmomo-py
38
+ ```
39
+
40
+ ## Configure
41
+
42
+ Supply credentials explicitly or through environment variables. Do not commit API keys, subscription keys, or `credentials.json`.
43
+
44
+ ```python
45
+ from mtnmomo import MoMoClient, MoMoConfig, ProductCredentials
46
+
47
+ config = MoMoConfig(
48
+ collection=ProductCredentials(
49
+ subscription_key="collection-subscription-key",
50
+ api_user="collection-api-user",
51
+ api_key="collection-api-key",
52
+ ),
53
+ disbursement=ProductCredentials(
54
+ subscription_key="disbursement-subscription-key",
55
+ api_user="disbursement-api-user",
56
+ api_key="disbursement-api-key",
57
+ ),
58
+ target_environment="sandbox",
59
+ )
60
+
61
+ with MoMoClient(config) as client:
62
+ balance = client.collection.get_account_balance()
63
+ print(balance.available_balance, balance.currency)
64
+ ```
65
+
66
+ `MoMoConfig.from_env()` reads:
67
+
68
+ - `MTN_MOMO_COLLECTION_SUBSCRIPTION_KEY`
69
+ - `MTN_MOMO_COLLECTION_API_USER`
70
+ - `MTN_MOMO_COLLECTION_API_KEY`
71
+ - `MTN_MOMO_DISBURSEMENT_SUBSCRIPTION_KEY`
72
+ - `MTN_MOMO_DISBURSEMENT_API_USER`
73
+ - `MTN_MOMO_DISBURSEMENT_API_KEY`
74
+ - `MTN_MOMO_TARGET_ENVIRONMENT` (defaults to `sandbox`)
75
+ - `MTN_MOMO_BASE_URL` (defaults to the MTN sandbox URL)
76
+ - `MTN_MOMO_TIMEOUT` (defaults to `30` seconds)
77
+
78
+ ## Collection example
79
+
80
+ ```python
81
+ from mtnmomo import Party
82
+
83
+ reference_id = client.collection.request_to_pay(
84
+ {
85
+ "amount": "100",
86
+ "currency": "EUR",
87
+ "externalId": "order-123",
88
+ "payer": Party("MSISDN", "46733123453"),
89
+ "payerMessage": "Order 123",
90
+ "payeeNote": "Order 123",
91
+ },
92
+ callback_url="https://merchant.example/momo/callback",
93
+ )
94
+ status = client.collection.get_request_to_pay_status(reference_id)
95
+ ```
96
+
97
+ ## Disbursement example
98
+
99
+ ```python
100
+ reference_id = client.disbursement.transfer(
101
+ {
102
+ "amount": "100",
103
+ "currency": "EUR",
104
+ "externalId": "payout-123",
105
+ "payee": Party("MSISDN", "46733123453"),
106
+ },
107
+ callback_url="https://merchant.example/momo/callback",
108
+ )
109
+ ```
110
+
111
+ ## Testing
112
+
113
+ ```bash
114
+ pip install -e .[test]
115
+ pytest
116
+ ```
117
+
118
+ Tests are network-free by default. Safe sandbox token tests require explicit environment configuration and opt-in:
119
+
120
+ ```bash
121
+ MTN_MOMO_RUN_INTEGRATION=1 pytest -m integration
122
+ ```
123
+
124
+ State-changing sandbox operations remain mocked by default.
125
+
126
+ ## Publishing
127
+
128
+ Build artifacts with `python -m build`; inspect them to confirm secrets are absent. Publish using a user-managed PyPI token or Trusted Publishing after testing the release on TestPyPI.
@@ -0,0 +1,99 @@
1
+ # mtnmomo-py
2
+
3
+ `mtnmomo-py` is a synchronous Python 3.10+ client for the MTN MoMo Collection, Disbursement, OAuth/CIBA, and Sandbox Provisioning APIs.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install mtnmomo-py
9
+ ```
10
+
11
+ ## Configure
12
+
13
+ Supply credentials explicitly or through environment variables. Do not commit API keys, subscription keys, or `credentials.json`.
14
+
15
+ ```python
16
+ from mtnmomo import MoMoClient, MoMoConfig, ProductCredentials
17
+
18
+ config = MoMoConfig(
19
+ collection=ProductCredentials(
20
+ subscription_key="collection-subscription-key",
21
+ api_user="collection-api-user",
22
+ api_key="collection-api-key",
23
+ ),
24
+ disbursement=ProductCredentials(
25
+ subscription_key="disbursement-subscription-key",
26
+ api_user="disbursement-api-user",
27
+ api_key="disbursement-api-key",
28
+ ),
29
+ target_environment="sandbox",
30
+ )
31
+
32
+ with MoMoClient(config) as client:
33
+ balance = client.collection.get_account_balance()
34
+ print(balance.available_balance, balance.currency)
35
+ ```
36
+
37
+ `MoMoConfig.from_env()` reads:
38
+
39
+ - `MTN_MOMO_COLLECTION_SUBSCRIPTION_KEY`
40
+ - `MTN_MOMO_COLLECTION_API_USER`
41
+ - `MTN_MOMO_COLLECTION_API_KEY`
42
+ - `MTN_MOMO_DISBURSEMENT_SUBSCRIPTION_KEY`
43
+ - `MTN_MOMO_DISBURSEMENT_API_USER`
44
+ - `MTN_MOMO_DISBURSEMENT_API_KEY`
45
+ - `MTN_MOMO_TARGET_ENVIRONMENT` (defaults to `sandbox`)
46
+ - `MTN_MOMO_BASE_URL` (defaults to the MTN sandbox URL)
47
+ - `MTN_MOMO_TIMEOUT` (defaults to `30` seconds)
48
+
49
+ ## Collection example
50
+
51
+ ```python
52
+ from mtnmomo import Party
53
+
54
+ reference_id = client.collection.request_to_pay(
55
+ {
56
+ "amount": "100",
57
+ "currency": "EUR",
58
+ "externalId": "order-123",
59
+ "payer": Party("MSISDN", "46733123453"),
60
+ "payerMessage": "Order 123",
61
+ "payeeNote": "Order 123",
62
+ },
63
+ callback_url="https://merchant.example/momo/callback",
64
+ )
65
+ status = client.collection.get_request_to_pay_status(reference_id)
66
+ ```
67
+
68
+ ## Disbursement example
69
+
70
+ ```python
71
+ reference_id = client.disbursement.transfer(
72
+ {
73
+ "amount": "100",
74
+ "currency": "EUR",
75
+ "externalId": "payout-123",
76
+ "payee": Party("MSISDN", "46733123453"),
77
+ },
78
+ callback_url="https://merchant.example/momo/callback",
79
+ )
80
+ ```
81
+
82
+ ## Testing
83
+
84
+ ```bash
85
+ pip install -e .[test]
86
+ pytest
87
+ ```
88
+
89
+ Tests are network-free by default. Safe sandbox token tests require explicit environment configuration and opt-in:
90
+
91
+ ```bash
92
+ MTN_MOMO_RUN_INTEGRATION=1 pytest -m integration
93
+ ```
94
+
95
+ State-changing sandbox operations remain mocked by default.
96
+
97
+ ## Publishing
98
+
99
+ Build artifacts with `python -m build`; inspect them to confirm secrets are absent. Publish using a user-managed PyPI token or Trusted Publishing after testing the release on TestPyPI.