sapliyio-fintech 0.0.1__py3-none-any.whl

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,173 @@
1
+ import requests
2
+ import hmac
3
+ import hashlib
4
+ import json
5
+ from typing import Dict, Any, Optional, List, Union
6
+
7
+ class FintechClient:
8
+ def __init__(self, api_key: str, base_url: str = "http://localhost:8080"):
9
+ self.api_key = api_key
10
+ self.base_url = base_url.rstrip("/")
11
+ self.session = requests.Session()
12
+ self.session.headers.update({
13
+ "Content-Type": "application/json",
14
+ "X-API-Key": self.api_key
15
+ })
16
+
17
+ def _request(self, method: str, path: str, json: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
18
+ url = f"{self.base_url}{path}"
19
+ response = self.session.request(method, url, json=json)
20
+ if response.status_code >= 400:
21
+ try:
22
+ error_detail = response.json()
23
+ except:
24
+ error_detail = response.text
25
+ raise Exception(f"Fintech API Error ({response.status_code}): {error_detail}")
26
+ return response.json()
27
+
28
+ @property
29
+ def ledger(self):
30
+ return LedgerService(self)
31
+
32
+ @property
33
+ def auth(self):
34
+ return AuthService(self)
35
+
36
+ @property
37
+ def payments(self):
38
+ return PaymentsService(self)
39
+
40
+ @property
41
+ def wallets(self):
42
+ return WalletsService(self)
43
+
44
+ @property
45
+ def billing(self):
46
+ return BillingService(self)
47
+
48
+ @property
49
+ def connect(self):
50
+ return ConnectService(self)
51
+
52
+ @property
53
+ def webhooks(self):
54
+ return WebhooksService(self)
55
+
56
+
57
+ class LedgerService:
58
+ def __init__(self, client: FintechClient):
59
+ self.client = client
60
+
61
+ def record_transaction(self, account_id: str, amount: int, currency: str, description: str, reference_id: str) -> Dict[str, Any]:
62
+ payload = {
63
+ "accountId": account_id,
64
+ "amount": amount,
65
+ "currency": currency,
66
+ "description": description,
67
+ "referenceId": reference_id
68
+ }
69
+ return self.client._request("POST", "/v1/ledger/transactions", json=payload)
70
+
71
+ def get_account(self, account_id: str) -> Dict[str, Any]:
72
+ return self.client._request("GET", f"/v1/ledger/accounts/{account_id}")
73
+
74
+
75
+ class AuthService:
76
+ def __init__(self, client: FintechClient):
77
+ self.client = client
78
+
79
+ def validate_key(self, key_hash: str) -> Dict[str, Any]:
80
+ return self.client._request("POST", "/v1/auth/validate", json={"keyHash": key_hash})
81
+
82
+
83
+ class PaymentsService:
84
+ def __init__(self, client: FintechClient):
85
+ self.client = client
86
+
87
+ def create(self, amount: int, currency: str, source_id: str, description: str) -> Dict[str, Any]:
88
+ payload = {
89
+ "amount": amount,
90
+ "currency": currency,
91
+ "sourceId": source_id,
92
+ "description": description
93
+ }
94
+ return self.client._request("POST", "/v1/payments", json=payload)
95
+
96
+ def get(self, payment_id: str) -> Dict[str, Any]:
97
+ return self.client._request("GET", f"/v1/payments/{payment_id}")
98
+
99
+ def refund(self, payment_id: str, amount: int) -> Dict[str, Any]:
100
+ return self.client._request("POST", f"/v1/payments/{payment_id}/refund", json={"amount": amount})
101
+
102
+
103
+ class WalletsService:
104
+ def __init__(self, client: FintechClient):
105
+ self.client = client
106
+
107
+ def create(self, user_id: str, currency: str) -> Dict[str, Any]:
108
+ payload = {"userId": user_id, "currency": currency}
109
+ return self.client._request("POST", "/v1/wallets", json=payload)
110
+
111
+ def get(self, wallet_id: str) -> Dict[str, Any]:
112
+ return self.client._request("GET", f"/v1/wallets/{wallet_id}")
113
+
114
+ def credit(self, wallet_id: str, amount: int, description: str) -> Dict[str, Any]:
115
+ payload = {"amount": amount, "description": description}
116
+ return self.client._request("POST", f"/v1/wallets/{wallet_id}/credit", json=payload)
117
+
118
+ def debit(self, wallet_id: str, amount: int, description: str) -> Dict[str, Any]:
119
+ payload = {"amount": amount, "description": description}
120
+ return self.client._request("POST", f"/v1/wallets/{wallet_id}/debit", json=payload)
121
+
122
+
123
+ class BillingService:
124
+ def __init__(self, client: FintechClient):
125
+ self.client = client
126
+
127
+ def create_subscription(self, customer_id: str, price_id: str) -> Dict[str, Any]:
128
+ payload = {"customerId": customer_id, "priceId": price_id}
129
+ return self.client._request("POST", "/v1/billing/subscriptions", json=payload)
130
+
131
+ def get_subscription(self, subscription_id: str) -> Dict[str, Any]:
132
+ return self.client._request("GET", f"/v1/billing/subscriptions/{subscription_id}")
133
+
134
+ def cancel_subscription(self, subscription_id: str) -> Dict[str, Any]:
135
+ return self.client._request("POST", f"/v1/billing/subscriptions/{subscription_id}/cancel")
136
+
137
+
138
+ class ConnectService:
139
+ def __init__(self, client: FintechClient):
140
+ self.client = client
141
+
142
+ def create_account(self, type: str, country: str, email: str) -> Dict[str, Any]:
143
+ payload = {"type": type, "country": country, "email": email}
144
+ return self.client._request("POST", "/v1/connect/accounts", json=payload)
145
+
146
+ def get_account(self, account_id: str) -> Dict[str, Any]:
147
+ return self.client._request("GET", f"/v1/connect/accounts/{account_id}")
148
+
149
+
150
+ class WebhooksService:
151
+ def __init__(self, client: FintechClient):
152
+ self.client = client
153
+
154
+ def create_endpoint(self, url: str, enabled_events: List[str]) -> Dict[str, Any]:
155
+ payload = {"url": url, "enabledEvents": enabled_events}
156
+ return self.client._request("POST", "/v1/webhooks/endpoints", json=payload)
157
+
158
+ def list_endpoints(self) -> List[Dict[str, Any]]:
159
+ return self.client._request("GET", "/v1/webhooks/endpoints")
160
+
161
+ def construct_event(self, payload: Union[str, bytes], signature: str, secret: str) -> Dict[str, Any]:
162
+ if isinstance(payload, str):
163
+ payload_bytes = payload.encode('utf-8')
164
+ else:
165
+ payload_bytes = payload
166
+
167
+ expected_sig = hmac.new(secret.encode('utf-8'), payload_bytes, hashlib.sha256).hexdigest()
168
+
169
+ # In a real scenario, you'd check timing-safe equality
170
+ # if not hmac.compare_digest(expected_sig, signature):
171
+ # raise Exception("Invalid signature")
172
+
173
+ return json.loads(payload_bytes.decode('utf-8'))
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: sapliyio-fintech
3
+ Version: 0.0.1
4
+ Summary: Official Sapliy Fintech Ecosystem SDK for Python
5
+ Author-email: Sapliy <dev@sapliy.com>
6
+ Project-URL: Homepage, https://github.com/Sapliy/fintech-ecosystem
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests>=2.25.0
14
+ Dynamic: license-file
15
+
16
+ # Sapliy Fintech Python SDK
17
+
18
+ Official Python SDK for the Sapliy Fintech Ecosystem.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install sapliy-fintech
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```python
29
+ from sapliy_fintech import FintechClient
30
+
31
+ # Initialize the client
32
+ client = FintechClient(api_key="your_api_key")
33
+
34
+ # Example: Record a transaction
35
+ response = client.ledger.record_transaction(
36
+ account_id="acc_123",
37
+ amount=1000,
38
+ currency="USD",
39
+ description="Coffee",
40
+ reference_id="ref_456"
41
+ )
42
+
43
+ print(response)
44
+ ```
@@ -0,0 +1,6 @@
1
+ sapliyio_fintech/__init__.py,sha256=Fz7taHihBIRxNTDFd-Bw12a2peIpd1WBNFYVStHiZ9o,6280
2
+ sapliyio_fintech-0.0.1.dist-info/licenses/LICENSE,sha256=B6WOalWo1F2oEzXNe12QKc57W58900MGSxQH6eHJPXY,1063
3
+ sapliyio_fintech-0.0.1.dist-info/METADATA,sha256=dGAWk7BcqTcv-5TvJk9gFoBQrIj6RfOyKbhA5donqcU,1000
4
+ sapliyio_fintech-0.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
5
+ sapliyio_fintech-0.0.1.dist-info/top_level.txt,sha256=vfArSMzRxE7n6Ly1x0PSAvDNUCv-k93CY-8JLy9bc9k,17
6
+ sapliyio_fintech-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sapliy
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 @@
1
+ sapliyio_fintech