sapliyio-fintech 0.0.1__tar.gz → 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,254 @@
1
+ Metadata-Version: 2.4
2
+ Name: sapliyio-fintech
3
+ Version: 1.0.0
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: urllib3<3.0.0,>=2.1.0
14
+ Requires-Dist: python-dateutil>=2.8.2
15
+ Requires-Dist: pydantic>=2.0.0
16
+ Requires-Dist: typing-extensions>=4.7.1
17
+ Dynamic: license-file
18
+
19
+ # sapliyio-fintech
20
+
21
+ [![PyPI version](https://badge.fury.io/py/sapliyio-fintech.svg)](https://badge.fury.io/py/sapliyio-fintech)
22
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
23
+
24
+ Official Python SDK for the Sapliy Fintech Ecosystem. Build financial applications with a clean, Pythonic API.
25
+
26
+ ## Features
27
+
28
+ - **Payments** — Create charges, handle refunds, manage payment lifecycle
29
+ - **Wallets** — User balances and internal accounting
30
+ - **Ledger** — Double-entry bookkeeping for high-integrity transactions
31
+ - **Billing** — Subscriptions and recurring billing
32
+ - **Connect** — Multi-tenant support and managed accounts
33
+ - **Webhooks** — Event handling with signature verification
34
+ - **Type Hints** — Full typing support for IDE autocomplete
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install sapliyio-fintech
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```python
45
+ from sapliyio_fintech import FintechClient
46
+
47
+ client = FintechClient(api_key="sk_test_...")
48
+
49
+ # Create a payment
50
+ payment = client.payments.create(
51
+ amount=2000, # $20.00
52
+ currency="USD",
53
+ source_id="src_123",
54
+ description="Order #1234"
55
+ )
56
+
57
+ print(f"Payment created: {payment.id}")
58
+ ```
59
+
60
+ ## Configuration
61
+
62
+ ```python
63
+ # Custom base URL (for self-hosted)
64
+ client = FintechClient(
65
+ api_key="sk_test_...",
66
+ base_url="https://api.yourdomain.com"
67
+ )
68
+
69
+ # Custom timeout
70
+ client = FintechClient(
71
+ api_key="sk_test_...",
72
+ timeout=30 # seconds
73
+ )
74
+ ```
75
+
76
+ ## API Reference
77
+
78
+ ### Payments
79
+
80
+ ```python
81
+ # Create a charge
82
+ payment = client.payments.create(
83
+ amount=1000,
84
+ currency="USD",
85
+ source_id="src_123",
86
+ description="Coffee"
87
+ )
88
+
89
+ # Get payment details
90
+ payment = client.payments.get("pay_123")
91
+
92
+ # Refund a payment
93
+ payment = client.payments.refund("pay_123", amount=500) # partial refund
94
+ ```
95
+
96
+ ### Wallets
97
+
98
+ ```python
99
+ # Create a wallet
100
+ wallet = client.wallets.create(
101
+ name="User Wallet",
102
+ currency="USD"
103
+ )
104
+
105
+ # Get wallet balance
106
+ wallet = client.wallets.get("wal_123")
107
+
108
+ # Credit (add funds)
109
+ wallet = client.wallets.credit(
110
+ wallet_id="wal_123",
111
+ amount=1000,
112
+ description="Deposit"
113
+ )
114
+
115
+ # Debit (withdraw funds)
116
+ wallet = client.wallets.debit(
117
+ wallet_id="wal_123",
118
+ amount=500,
119
+ description="Purchase"
120
+ )
121
+ ```
122
+
123
+ ### Ledger
124
+
125
+ ```python
126
+ # Record a transaction
127
+ response = client.ledger.record_transaction(
128
+ account_id="acc_123",
129
+ amount=1000,
130
+ currency="USD",
131
+ description="Payment received",
132
+ reference_id="ref_456"
133
+ )
134
+
135
+ # Get account details
136
+ account = client.ledger.get_account("acc_123")
137
+ print(f"Balance: {account.balance}")
138
+ ```
139
+
140
+ ### Billing
141
+
142
+ ```python
143
+ # Create a subscription
144
+ subscription = client.billing.create_subscription(
145
+ customer_id="cust_123",
146
+ plan_id="plan_monthly"
147
+ )
148
+
149
+ # Get subscription
150
+ subscription = client.billing.get_subscription("sub_123")
151
+
152
+ # Cancel subscription
153
+ client.billing.cancel_subscription("sub_123")
154
+ ```
155
+
156
+ ## Webhook Handling
157
+
158
+ ### Flask Example
159
+
160
+ ```python
161
+ from flask import Flask, request
162
+ from sapliyio_fintech import FintechClient
163
+
164
+ app = Flask(__name__)
165
+ client = FintechClient(api_key="sk_test_...")
166
+
167
+ @app.route("/webhooks", methods=["POST"])
168
+ def webhook():
169
+ payload = request.data
170
+ signature = request.headers.get("X-Sapliy-Signature")
171
+ secret = "whsec_..."
172
+
173
+ try:
174
+ event = client.webhooks.construct_event(payload, signature, secret)
175
+ except ValueError:
176
+ return "Invalid signature", 400
177
+
178
+ if event.type == "payment.succeeded":
179
+ payment = event.data.object
180
+ # Handle successful payment
181
+ elif event.type == "payment.failed":
182
+ # Handle failed payment
183
+ pass
184
+
185
+ return {"received": True}
186
+ ```
187
+
188
+ ### Django Example
189
+
190
+ ```python
191
+ from django.http import JsonResponse
192
+ from django.views.decorators.csrf import csrf_exempt
193
+ from sapliyio_fintech import FintechClient
194
+
195
+ client = FintechClient(api_key="sk_test_...")
196
+
197
+ @csrf_exempt
198
+ def webhook_view(request):
199
+ payload = request.body
200
+ signature = request.headers.get("X-Sapliy-Signature")
201
+ secret = "whsec_..."
202
+
203
+ try:
204
+ event = client.webhooks.construct_event(payload, signature, secret)
205
+ except ValueError:
206
+ return JsonResponse({"error": "Invalid signature"}, status=400)
207
+
208
+ # Handle event
209
+ return JsonResponse({"received": True})
210
+ ```
211
+
212
+ ## Async Support
213
+
214
+ ```python
215
+ import asyncio
216
+ from sapliyio_fintech import AsyncFintechClient
217
+
218
+ async def main():
219
+ client = AsyncFintechClient(api_key="sk_test_...")
220
+
221
+ payment = await client.payments.create(
222
+ amount=2000,
223
+ currency="USD",
224
+ source_id="src_123",
225
+ description="Async payment"
226
+ )
227
+
228
+ print(f"Payment: {payment.id}")
229
+
230
+ asyncio.run(main())
231
+ ```
232
+
233
+ ## Error Handling
234
+
235
+ ```python
236
+ from sapliyio_fintech.exceptions import FintechError, PaymentError
237
+
238
+ try:
239
+ payment = client.payments.get("invalid_id")
240
+ except PaymentError as e:
241
+ print(f"Payment error: {e.message}")
242
+ except FintechError as e:
243
+ print(f"API error ({e.status_code}): {e.message}")
244
+ ```
245
+
246
+ ## Part of Sapliy Fintech Ecosystem
247
+
248
+ - [fintech-ecosystem](https://github.com/Sapliy/fintech-ecosystem) — Core backend
249
+ - [fintech-sdk-node](https://github.com/Sapliy/fintech-sdk-node) — Node.js SDK
250
+ - [fintech-sdk-go](https://github.com/Sapliy/fintech-sdk-go) — Go SDK
251
+
252
+ ## License
253
+
254
+ MIT © [Sapliy](https://github.com/sapliy)
@@ -0,0 +1,236 @@
1
+ # sapliyio-fintech
2
+
3
+ [![PyPI version](https://badge.fury.io/py/sapliyio-fintech.svg)](https://badge.fury.io/py/sapliyio-fintech)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Official Python SDK for the Sapliy Fintech Ecosystem. Build financial applications with a clean, Pythonic API.
7
+
8
+ ## Features
9
+
10
+ - **Payments** — Create charges, handle refunds, manage payment lifecycle
11
+ - **Wallets** — User balances and internal accounting
12
+ - **Ledger** — Double-entry bookkeeping for high-integrity transactions
13
+ - **Billing** — Subscriptions and recurring billing
14
+ - **Connect** — Multi-tenant support and managed accounts
15
+ - **Webhooks** — Event handling with signature verification
16
+ - **Type Hints** — Full typing support for IDE autocomplete
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install sapliyio-fintech
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ ```python
27
+ from sapliyio_fintech import FintechClient
28
+
29
+ client = FintechClient(api_key="sk_test_...")
30
+
31
+ # Create a payment
32
+ payment = client.payments.create(
33
+ amount=2000, # $20.00
34
+ currency="USD",
35
+ source_id="src_123",
36
+ description="Order #1234"
37
+ )
38
+
39
+ print(f"Payment created: {payment.id}")
40
+ ```
41
+
42
+ ## Configuration
43
+
44
+ ```python
45
+ # Custom base URL (for self-hosted)
46
+ client = FintechClient(
47
+ api_key="sk_test_...",
48
+ base_url="https://api.yourdomain.com"
49
+ )
50
+
51
+ # Custom timeout
52
+ client = FintechClient(
53
+ api_key="sk_test_...",
54
+ timeout=30 # seconds
55
+ )
56
+ ```
57
+
58
+ ## API Reference
59
+
60
+ ### Payments
61
+
62
+ ```python
63
+ # Create a charge
64
+ payment = client.payments.create(
65
+ amount=1000,
66
+ currency="USD",
67
+ source_id="src_123",
68
+ description="Coffee"
69
+ )
70
+
71
+ # Get payment details
72
+ payment = client.payments.get("pay_123")
73
+
74
+ # Refund a payment
75
+ payment = client.payments.refund("pay_123", amount=500) # partial refund
76
+ ```
77
+
78
+ ### Wallets
79
+
80
+ ```python
81
+ # Create a wallet
82
+ wallet = client.wallets.create(
83
+ name="User Wallet",
84
+ currency="USD"
85
+ )
86
+
87
+ # Get wallet balance
88
+ wallet = client.wallets.get("wal_123")
89
+
90
+ # Credit (add funds)
91
+ wallet = client.wallets.credit(
92
+ wallet_id="wal_123",
93
+ amount=1000,
94
+ description="Deposit"
95
+ )
96
+
97
+ # Debit (withdraw funds)
98
+ wallet = client.wallets.debit(
99
+ wallet_id="wal_123",
100
+ amount=500,
101
+ description="Purchase"
102
+ )
103
+ ```
104
+
105
+ ### Ledger
106
+
107
+ ```python
108
+ # Record a transaction
109
+ response = client.ledger.record_transaction(
110
+ account_id="acc_123",
111
+ amount=1000,
112
+ currency="USD",
113
+ description="Payment received",
114
+ reference_id="ref_456"
115
+ )
116
+
117
+ # Get account details
118
+ account = client.ledger.get_account("acc_123")
119
+ print(f"Balance: {account.balance}")
120
+ ```
121
+
122
+ ### Billing
123
+
124
+ ```python
125
+ # Create a subscription
126
+ subscription = client.billing.create_subscription(
127
+ customer_id="cust_123",
128
+ plan_id="plan_monthly"
129
+ )
130
+
131
+ # Get subscription
132
+ subscription = client.billing.get_subscription("sub_123")
133
+
134
+ # Cancel subscription
135
+ client.billing.cancel_subscription("sub_123")
136
+ ```
137
+
138
+ ## Webhook Handling
139
+
140
+ ### Flask Example
141
+
142
+ ```python
143
+ from flask import Flask, request
144
+ from sapliyio_fintech import FintechClient
145
+
146
+ app = Flask(__name__)
147
+ client = FintechClient(api_key="sk_test_...")
148
+
149
+ @app.route("/webhooks", methods=["POST"])
150
+ def webhook():
151
+ payload = request.data
152
+ signature = request.headers.get("X-Sapliy-Signature")
153
+ secret = "whsec_..."
154
+
155
+ try:
156
+ event = client.webhooks.construct_event(payload, signature, secret)
157
+ except ValueError:
158
+ return "Invalid signature", 400
159
+
160
+ if event.type == "payment.succeeded":
161
+ payment = event.data.object
162
+ # Handle successful payment
163
+ elif event.type == "payment.failed":
164
+ # Handle failed payment
165
+ pass
166
+
167
+ return {"received": True}
168
+ ```
169
+
170
+ ### Django Example
171
+
172
+ ```python
173
+ from django.http import JsonResponse
174
+ from django.views.decorators.csrf import csrf_exempt
175
+ from sapliyio_fintech import FintechClient
176
+
177
+ client = FintechClient(api_key="sk_test_...")
178
+
179
+ @csrf_exempt
180
+ def webhook_view(request):
181
+ payload = request.body
182
+ signature = request.headers.get("X-Sapliy-Signature")
183
+ secret = "whsec_..."
184
+
185
+ try:
186
+ event = client.webhooks.construct_event(payload, signature, secret)
187
+ except ValueError:
188
+ return JsonResponse({"error": "Invalid signature"}, status=400)
189
+
190
+ # Handle event
191
+ return JsonResponse({"received": True})
192
+ ```
193
+
194
+ ## Async Support
195
+
196
+ ```python
197
+ import asyncio
198
+ from sapliyio_fintech import AsyncFintechClient
199
+
200
+ async def main():
201
+ client = AsyncFintechClient(api_key="sk_test_...")
202
+
203
+ payment = await client.payments.create(
204
+ amount=2000,
205
+ currency="USD",
206
+ source_id="src_123",
207
+ description="Async payment"
208
+ )
209
+
210
+ print(f"Payment: {payment.id}")
211
+
212
+ asyncio.run(main())
213
+ ```
214
+
215
+ ## Error Handling
216
+
217
+ ```python
218
+ from sapliyio_fintech.exceptions import FintechError, PaymentError
219
+
220
+ try:
221
+ payment = client.payments.get("invalid_id")
222
+ except PaymentError as e:
223
+ print(f"Payment error: {e.message}")
224
+ except FintechError as e:
225
+ print(f"API error ({e.status_code}): {e.message}")
226
+ ```
227
+
228
+ ## Part of Sapliy Fintech Ecosystem
229
+
230
+ - [fintech-ecosystem](https://github.com/Sapliy/fintech-ecosystem) — Core backend
231
+ - [fintech-sdk-node](https://github.com/Sapliy/fintech-sdk-node) — Node.js SDK
232
+ - [fintech-sdk-go](https://github.com/Sapliy/fintech-sdk-go) — Go SDK
233
+
234
+ ## License
235
+
236
+ MIT © [Sapliy](https://github.com/sapliy)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sapliyio-fintech"
7
- version = "0.0.1"
7
+ version = "1.0.0"
8
8
  authors = [
9
9
  { name="Sapliy", email="dev@sapliy.com" },
10
10
  ]
@@ -17,8 +17,14 @@ classifiers = [
17
17
  "Operating System :: OS Independent",
18
18
  ]
19
19
  dependencies = [
20
- "requests>=2.25.0",
20
+ "urllib3 >= 2.1.0, < 3.0.0",
21
+ "python-dateutil >= 2.8.2",
22
+ "pydantic >= 2.0.0",
23
+ "typing-extensions >= 4.7.1",
21
24
  ]
22
25
 
23
26
  [project.urls]
24
27
  "Homepage" = "https://github.com/Sapliy/fintech-ecosystem"
28
+
29
+ [tool.setuptools]
30
+ packages = ["sapliyio_fintech"]
@@ -0,0 +1,28 @@
1
+ from .api_client import ApiClient
2
+ from .configuration import Configuration
3
+ from .api.auth_service_api import AuthServiceApi
4
+ from .api.billing_service_api import BillingServiceApi
5
+ from .api.ledger_service_api import LedgerServiceApi
6
+ from .api.notification_service_api import NotificationServiceApi
7
+ from .api.payment_service_api import PaymentServiceApi
8
+ from .api.wallet_service_api import WalletServiceApi
9
+ # form .api.flow_service_api import FlowServiceApi
10
+ # from .api.zone_service_api import ZoneServiceApi
11
+
12
+ class SapliyClient:
13
+ def __init__(self, api_key: str, base_url: str = "http://localhost:8080"):
14
+ self.configuration = Configuration(
15
+ host=base_url,
16
+ )
17
+ self.configuration.api_key['X-API-Key'] = api_key
18
+
19
+ self.api_client = ApiClient(self.configuration)
20
+
21
+ self.auth = AuthServiceApi(self.api_client)
22
+ self.billing = BillingServiceApi(self.api_client)
23
+ self.ledger = LedgerServiceApi(self.api_client)
24
+ self.notifications = NotificationServiceApi(self.api_client)
25
+ self.payments = PaymentServiceApi(self.api_client)
26
+ self.wallets = WalletServiceApi(self.api_client)
27
+ # self.flows = FlowServiceApi(self.api_client)
28
+ # self.zones = ZoneServiceApi(self.api_client)