moneypulse 1.0.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,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: moneypulse
3
+ Version: 1.0.0
4
+ Summary: Official Money-Pulse Python SDK — Accept payments and process payouts across Africa.
5
+ Home-page: https://github.com/nocyl-pulse/moneypulse-python
6
+ Author: NOCYL-PULSE
7
+ Author-email: NOCYL-PULSE <dev@money-pulse.org>
8
+ License: MIT
9
+ Project-URL: Homepage, https://money-pulse.org
10
+ Project-URL: Repository, https://github.com/nocyl-pulse/moneypulse-python
11
+ Project-URL: Issues, https://github.com/nocyl-pulse/moneypulse-python/issues
12
+ Keywords: money-pulse,payments,africa,mobile-money,sdk
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Office/Business :: Financial
18
+ Classifier: Intended Audience :: Developers
19
+ Requires-Python: >=3.7
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: requests>=2.25.0
22
+ Dynamic: author
23
+ Dynamic: home-page
24
+ Dynamic: requires-python
25
+
26
+ # moneypulse
27
+
28
+ Official Python SDK for [Money-Pulse](https://money-pulse.org).
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install moneypulse
34
+ ```
35
+
36
+ ## Quick start
37
+
38
+ ```python
39
+ import moneypulse
40
+ client = moneypulse.Client("mp_live_xxx")
41
+
42
+ payment = client.payments.create(
43
+ amount=10000, currency="XOF", country="CI",
44
+ customer={"email": "client@email.com", "phone": "+22507000000"},
45
+ callback_url="https://your-site.com/webhook",
46
+ )
47
+ print(payment["checkout_url"])
48
+ ```
49
+
50
+ ## Payouts
51
+
52
+ ```python
53
+ payout = client.payouts.create(
54
+ amount=50000, currency="XOF", country="CI",
55
+ recipient={"type": "mobile_money", "phone": "+22507000000", "name": "Jean Kouassi"},
56
+ )
57
+ ```
58
+
59
+ ## Webhook verification (HMAC SHA-256)
60
+
61
+ ### Django
62
+
63
+ ```python
64
+ import hmac, hashlib, json
65
+ from django.http import HttpResponse
66
+ from django.views.decorators.csrf import csrf_exempt
67
+
68
+ @csrf_exempt
69
+ def mp_webhook(request):
70
+ signature = request.headers.get("X-MoneyPulse-Signature", "")
71
+ expected = hmac.new(
72
+ settings.MP_WEBHOOK_SECRET.encode(),
73
+ request.body, hashlib.sha256
74
+ ).hexdigest()
75
+ if not hmac.compare_digest(signature, expected):
76
+ return HttpResponse(status=401)
77
+
78
+ event = json.loads(request.body)
79
+ if event["type"] == "payment.success":
80
+ # fulfill order
81
+ pass
82
+ return HttpResponse(status=200)
83
+ ```
84
+
85
+ ### FastAPI
86
+
87
+ ```python
88
+ from fastapi import FastAPI, Request, HTTPException
89
+ import hmac, hashlib
90
+
91
+ app = FastAPI()
92
+
93
+ @app.post("/webhook")
94
+ async def webhook(req: Request):
95
+ body = await req.body()
96
+ signature = req.headers.get("x-moneypulse-signature", "")
97
+ expected = hmac.new(SECRET.encode(), body, hashlib.sha256).hexdigest()
98
+ if not hmac.compare_digest(signature, expected):
99
+ raise HTTPException(401)
100
+ return {"received": True}
101
+ ```
102
+
103
+ ## Simulation mode
104
+
105
+ ```python
106
+ result = client.payments.create(
107
+ amount=1000, currency="XOF", country="CI",
108
+ customer={"email": "t@t.com"},
109
+ simulate=True, # no funds, no webhook, no billing
110
+ )
111
+ ```
112
+
113
+ ## Error handling
114
+
115
+ ```python
116
+ from moneypulse.client import MoneyPulseError
117
+
118
+ try:
119
+ client.payments.create(...)
120
+ except MoneyPulseError as e:
121
+ print(e.code, e.status_code, e)
122
+ ```
123
+
124
+ ## License
125
+
126
+ MIT © NOCYL-PULSE
@@ -0,0 +1,101 @@
1
+ # moneypulse
2
+
3
+ Official Python SDK for [Money-Pulse](https://money-pulse.org).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install moneypulse
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```python
14
+ import moneypulse
15
+ client = moneypulse.Client("mp_live_xxx")
16
+
17
+ payment = client.payments.create(
18
+ amount=10000, currency="XOF", country="CI",
19
+ customer={"email": "client@email.com", "phone": "+22507000000"},
20
+ callback_url="https://your-site.com/webhook",
21
+ )
22
+ print(payment["checkout_url"])
23
+ ```
24
+
25
+ ## Payouts
26
+
27
+ ```python
28
+ payout = client.payouts.create(
29
+ amount=50000, currency="XOF", country="CI",
30
+ recipient={"type": "mobile_money", "phone": "+22507000000", "name": "Jean Kouassi"},
31
+ )
32
+ ```
33
+
34
+ ## Webhook verification (HMAC SHA-256)
35
+
36
+ ### Django
37
+
38
+ ```python
39
+ import hmac, hashlib, json
40
+ from django.http import HttpResponse
41
+ from django.views.decorators.csrf import csrf_exempt
42
+
43
+ @csrf_exempt
44
+ def mp_webhook(request):
45
+ signature = request.headers.get("X-MoneyPulse-Signature", "")
46
+ expected = hmac.new(
47
+ settings.MP_WEBHOOK_SECRET.encode(),
48
+ request.body, hashlib.sha256
49
+ ).hexdigest()
50
+ if not hmac.compare_digest(signature, expected):
51
+ return HttpResponse(status=401)
52
+
53
+ event = json.loads(request.body)
54
+ if event["type"] == "payment.success":
55
+ # fulfill order
56
+ pass
57
+ return HttpResponse(status=200)
58
+ ```
59
+
60
+ ### FastAPI
61
+
62
+ ```python
63
+ from fastapi import FastAPI, Request, HTTPException
64
+ import hmac, hashlib
65
+
66
+ app = FastAPI()
67
+
68
+ @app.post("/webhook")
69
+ async def webhook(req: Request):
70
+ body = await req.body()
71
+ signature = req.headers.get("x-moneypulse-signature", "")
72
+ expected = hmac.new(SECRET.encode(), body, hashlib.sha256).hexdigest()
73
+ if not hmac.compare_digest(signature, expected):
74
+ raise HTTPException(401)
75
+ return {"received": True}
76
+ ```
77
+
78
+ ## Simulation mode
79
+
80
+ ```python
81
+ result = client.payments.create(
82
+ amount=1000, currency="XOF", country="CI",
83
+ customer={"email": "t@t.com"},
84
+ simulate=True, # no funds, no webhook, no billing
85
+ )
86
+ ```
87
+
88
+ ## Error handling
89
+
90
+ ```python
91
+ from moneypulse.client import MoneyPulseError
92
+
93
+ try:
94
+ client.payments.create(...)
95
+ except MoneyPulseError as e:
96
+ print(e.code, e.status_code, e)
97
+ ```
98
+
99
+ ## License
100
+
101
+ MIT © NOCYL-PULSE
@@ -0,0 +1,4 @@
1
+ from .client import MoneyPulseClient as Client
2
+
3
+ __version__ = "1.0.0"
4
+ __all__ = ["Client"]
@@ -0,0 +1,81 @@
1
+ """Money-Pulse Python SDK"""
2
+ import requests
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class MoneyPulseError(Exception):
7
+ def __init__(self, message: str, code: str = "unknown", status_code: int = 0):
8
+ super().__init__(message)
9
+ self.code = code
10
+ self.status_code = status_code
11
+
12
+
13
+ class _Resource:
14
+ def __init__(self, client: "MoneyPulseClient", prefix: str, create_prefix: str = None):
15
+ self._client = client
16
+ self._prefix = prefix
17
+ self._create_prefix = create_prefix or prefix
18
+
19
+ def create(self, **params) -> Dict[str, Any]:
20
+ return self._client._request("POST", self._create_prefix, json=params)
21
+
22
+ def retrieve(self, id: str) -> Dict[str, Any]:
23
+ return self._client._request("GET", f"{self._prefix}/{id}")
24
+
25
+ def verify(self, id: str) -> Dict[str, Any]:
26
+ return self._client._request("GET", f"{self._prefix}/{id}/verify")
27
+
28
+ def list(self, page: int = 1, limit: int = 20, **filters) -> Dict[str, Any]:
29
+ params = {"page": page, "limit": limit, **filters}
30
+ return self._client._request("GET", self._prefix, params=params)
31
+
32
+
33
+ class _PaymentResource(_Resource):
34
+ def __init__(self, client: "MoneyPulseClient"):
35
+ super().__init__(client, "/api/v1/payments", "/api/v1/payments/initiate")
36
+
37
+
38
+ class _PayoutResource(_Resource):
39
+ def __init__(self, client: "MoneyPulseClient"):
40
+ super().__init__(client, "/api/v1/payouts", "/api/v1/payouts/initiate")
41
+
42
+
43
+ class MoneyPulseClient:
44
+ """
45
+ Official Money-Pulse Python client.
46
+
47
+ Usage:
48
+ import moneypulse
49
+ client = moneypulse.Client("mp_live_votre_cle_api")
50
+ payment = client.payments.create(
51
+ amount=10000, currency="XOF", country="CI",
52
+ customer={"email": "client@email.com"},
53
+ callback_url="https://your-site.com/webhook"
54
+ )
55
+ """
56
+
57
+ def __init__(self, api_key: str, base_url: str = "https://api.money-pulse.org"):
58
+ self._api_key = api_key
59
+ self._base_url = base_url.rstrip("/")
60
+ self._session = requests.Session()
61
+ self._session.headers.update({
62
+ "X-Api-Key": self._api_key,
63
+ "Content-Type": "application/json",
64
+ "X-SDK": "moneypulse-python/1.0.0",
65
+ })
66
+ self.payments = _PaymentResource(self)
67
+ self.payouts = _PayoutResource(self)
68
+
69
+ def _request(self, method: str, path: str, json: Optional[dict] = None, params: Optional[dict] = None) -> Dict[str, Any]:
70
+ url = f"{self._base_url}{path}"
71
+ response = self._session.request(method, url, json=json, params=params, timeout=30)
72
+
73
+ data = response.json()
74
+
75
+ if response.status_code >= 400:
76
+ error = data.get("error", {})
77
+ msg = error.get("message", str(error)) if isinstance(error, dict) else str(error)
78
+ code = error.get("code", "unknown") if isinstance(error, dict) else "unknown"
79
+ raise MoneyPulseError(msg, code, response.status_code)
80
+
81
+ return data.get("data", data)
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: moneypulse
3
+ Version: 1.0.0
4
+ Summary: Official Money-Pulse Python SDK — Accept payments and process payouts across Africa.
5
+ Home-page: https://github.com/nocyl-pulse/moneypulse-python
6
+ Author: NOCYL-PULSE
7
+ Author-email: NOCYL-PULSE <dev@money-pulse.org>
8
+ License: MIT
9
+ Project-URL: Homepage, https://money-pulse.org
10
+ Project-URL: Repository, https://github.com/nocyl-pulse/moneypulse-python
11
+ Project-URL: Issues, https://github.com/nocyl-pulse/moneypulse-python/issues
12
+ Keywords: money-pulse,payments,africa,mobile-money,sdk
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Office/Business :: Financial
18
+ Classifier: Intended Audience :: Developers
19
+ Requires-Python: >=3.7
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: requests>=2.25.0
22
+ Dynamic: author
23
+ Dynamic: home-page
24
+ Dynamic: requires-python
25
+
26
+ # moneypulse
27
+
28
+ Official Python SDK for [Money-Pulse](https://money-pulse.org).
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install moneypulse
34
+ ```
35
+
36
+ ## Quick start
37
+
38
+ ```python
39
+ import moneypulse
40
+ client = moneypulse.Client("mp_live_xxx")
41
+
42
+ payment = client.payments.create(
43
+ amount=10000, currency="XOF", country="CI",
44
+ customer={"email": "client@email.com", "phone": "+22507000000"},
45
+ callback_url="https://your-site.com/webhook",
46
+ )
47
+ print(payment["checkout_url"])
48
+ ```
49
+
50
+ ## Payouts
51
+
52
+ ```python
53
+ payout = client.payouts.create(
54
+ amount=50000, currency="XOF", country="CI",
55
+ recipient={"type": "mobile_money", "phone": "+22507000000", "name": "Jean Kouassi"},
56
+ )
57
+ ```
58
+
59
+ ## Webhook verification (HMAC SHA-256)
60
+
61
+ ### Django
62
+
63
+ ```python
64
+ import hmac, hashlib, json
65
+ from django.http import HttpResponse
66
+ from django.views.decorators.csrf import csrf_exempt
67
+
68
+ @csrf_exempt
69
+ def mp_webhook(request):
70
+ signature = request.headers.get("X-MoneyPulse-Signature", "")
71
+ expected = hmac.new(
72
+ settings.MP_WEBHOOK_SECRET.encode(),
73
+ request.body, hashlib.sha256
74
+ ).hexdigest()
75
+ if not hmac.compare_digest(signature, expected):
76
+ return HttpResponse(status=401)
77
+
78
+ event = json.loads(request.body)
79
+ if event["type"] == "payment.success":
80
+ # fulfill order
81
+ pass
82
+ return HttpResponse(status=200)
83
+ ```
84
+
85
+ ### FastAPI
86
+
87
+ ```python
88
+ from fastapi import FastAPI, Request, HTTPException
89
+ import hmac, hashlib
90
+
91
+ app = FastAPI()
92
+
93
+ @app.post("/webhook")
94
+ async def webhook(req: Request):
95
+ body = await req.body()
96
+ signature = req.headers.get("x-moneypulse-signature", "")
97
+ expected = hmac.new(SECRET.encode(), body, hashlib.sha256).hexdigest()
98
+ if not hmac.compare_digest(signature, expected):
99
+ raise HTTPException(401)
100
+ return {"received": True}
101
+ ```
102
+
103
+ ## Simulation mode
104
+
105
+ ```python
106
+ result = client.payments.create(
107
+ amount=1000, currency="XOF", country="CI",
108
+ customer={"email": "t@t.com"},
109
+ simulate=True, # no funds, no webhook, no billing
110
+ )
111
+ ```
112
+
113
+ ## Error handling
114
+
115
+ ```python
116
+ from moneypulse.client import MoneyPulseError
117
+
118
+ try:
119
+ client.payments.create(...)
120
+ except MoneyPulseError as e:
121
+ print(e.code, e.status_code, e)
122
+ ```
123
+
124
+ ## License
125
+
126
+ MIT © NOCYL-PULSE
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ moneypulse/__init__.py
5
+ moneypulse/client.py
6
+ moneypulse.egg-info/PKG-INFO
7
+ moneypulse.egg-info/SOURCES.txt
8
+ moneypulse.egg-info/dependency_links.txt
9
+ moneypulse.egg-info/requires.txt
10
+ moneypulse.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.25.0
@@ -0,0 +1 @@
1
+ moneypulse
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "moneypulse"
7
+ version = "1.0.0"
8
+ description = "Official Money-Pulse Python SDK — Accept payments and process payouts across Africa."
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "NOCYL-PULSE", email = "dev@money-pulse.org" }]
13
+ keywords = ["money-pulse", "payments", "africa", "mobile-money", "sdk"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Topic :: Office/Business :: Financial",
20
+ "Intended Audience :: Developers",
21
+ ]
22
+ dependencies = ["requests>=2.25.0"]
23
+
24
+ [project.urls]
25
+ Homepage = "https://money-pulse.org"
26
+ Repository = "https://github.com/nocyl-pulse/moneypulse-python"
27
+ Issues = "https://github.com/nocyl-pulse/moneypulse-python/issues"
28
+
29
+ [tool.setuptools.packages.find]
30
+ include = ["moneypulse*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="moneypulse",
5
+ version="1.0.0",
6
+ description="Official Money-Pulse Python SDK — Accept payments and process payouts across Africa.",
7
+ long_description=open("README.md").read(),
8
+ long_description_content_type="text/markdown",
9
+ author="NOCYL-PULSE",
10
+ author_email="dev@money-pulse.org",
11
+ url="https://github.com/nocyl-pulse/moneypulse-python",
12
+ packages=find_packages(),
13
+ python_requires=">=3.7",
14
+ install_requires=["requests>=2.25.0"],
15
+ classifiers=[
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ ],
20
+ )