bpay 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.
Files changed (53) hide show
  1. bpay-0.1.0/.github/workflows/ci.yml +0 -0
  2. bpay-0.1.0/.gitignore +10 -0
  3. bpay-0.1.0/.python-version +1 -0
  4. bpay-0.1.0/LICENSE +21 -0
  5. bpay-0.1.0/Makefile +35 -0
  6. bpay-0.1.0/PKG-INFO +293 -0
  7. bpay-0.1.0/README.md +269 -0
  8. bpay-0.1.0/docs/architecture.md +0 -0
  9. bpay-0.1.0/examples/bkash_auth.py +24 -0
  10. bpay-0.1.0/examples/bkash_example.py +14 -0
  11. bpay-0.1.0/examples/callback_example.py +14 -0
  12. bpay-0.1.0/examples/create_bkash_agreement.py +36 -0
  13. bpay-0.1.0/examples/create_bkash_payment.py +57 -0
  14. bpay-0.1.0/examples/full_agreement_flow.py +31 -0
  15. bpay-0.1.0/examples/sdk_usage.py +29 -0
  16. bpay-0.1.0/pyproject.toml +72 -0
  17. bpay-0.1.0/src/bpay/__init__.py +5 -0
  18. bpay-0.1.0/src/bpay/client.py +157 -0
  19. bpay-0.1.0/src/bpay/config/__init__.py +0 -0
  20. bpay-0.1.0/src/bpay/config/environments.py +6 -0
  21. bpay-0.1.0/src/bpay/config.py +0 -0
  22. bpay-0.1.0/src/bpay/exceptions.py +52 -0
  23. bpay-0.1.0/src/bpay/providers/__init__.py +0 -0
  24. bpay-0.1.0/src/bpay/providers/base.py +15 -0
  25. bpay-0.1.0/src/bpay/providers/bkash/__init__.py +0 -0
  26. bpay-0.1.0/src/bpay/providers/bkash/agreement.py +96 -0
  27. bpay-0.1.0/src/bpay/providers/bkash/auth.py +87 -0
  28. bpay-0.1.0/src/bpay/providers/bkash/callbacks.py +21 -0
  29. bpay-0.1.0/src/bpay/providers/bkash/constants.py +17 -0
  30. bpay-0.1.0/src/bpay/providers/bkash/payment.py +103 -0
  31. bpay-0.1.0/src/bpay/providers/bkash/payment_callbacks.py +22 -0
  32. bpay-0.1.0/src/bpay/providers/bkash/provider.py +117 -0
  33. bpay-0.1.0/src/bpay/providers/bkash/schemas.py +15 -0
  34. bpay-0.1.0/src/bpay/providers/bkash/verification.py +84 -0
  35. bpay-0.1.0/src/bpay/providers/nagad/__init__.py +0 -0
  36. bpay-0.1.0/src/bpay/providers/registry.py +5 -0
  37. bpay-0.1.0/src/bpay/providers/sslcommerz/__init__.py +0 -0
  38. bpay-0.1.0/src/bpay/schemas/__init__.py +0 -0
  39. bpay-0.1.0/src/bpay/schemas/agreement.py +15 -0
  40. bpay-0.1.0/src/bpay/schemas/callback.py +10 -0
  41. bpay-0.1.0/src/bpay/schemas/payment.py +20 -0
  42. bpay-0.1.0/src/bpay/schemas/payment_callback.py +9 -0
  43. bpay-0.1.0/src/bpay/schemas/verification.py +12 -0
  44. bpay-0.1.0/src/bpay/security/__init__.py +0 -0
  45. bpay-0.1.0/src/bpay/transports/__init__.py +0 -0
  46. bpay-0.1.0/src/bpay/transports/http.py +15 -0
  47. bpay-0.1.0/src/bpay/types.py +21 -0
  48. bpay-0.1.0/src/bpay/webhooks/__init__.py +0 -0
  49. bpay-0.1.0/tests/__init__.py +0 -0
  50. bpay-0.1.0/tests/unit/test_agreement_callback.py +32 -0
  51. bpay-0.1.0/tests/unit/test_client.py +13 -0
  52. bpay-0.1.0/tests/unit/test_payment_callback.py +26 -0
  53. bpay-0.1.0/uv.lock +944 -0
File without changes
bpay-0.1.0/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
@@ -0,0 +1 @@
1
+ 3.13
bpay-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ayon
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.
bpay-0.1.0/Makefile ADDED
@@ -0,0 +1,35 @@
1
+ .PHONY: install sync test lint format typecheck check clean build
2
+
3
+ install:
4
+ uv sync
5
+
6
+ sync:
7
+ uv sync
8
+
9
+ test:
10
+ uv run pytest
11
+
12
+ lint:
13
+ uv run ruff check .
14
+
15
+ format:
16
+ uv run ruff format .
17
+
18
+ typecheck:
19
+ uv run mypy src
20
+
21
+ check:
22
+ uv run ruff check .
23
+ uv run mypy src
24
+ uv run pytest
25
+
26
+ build:
27
+ uv build
28
+
29
+ clean:
30
+ rm -rf .pytest_cache
31
+ rm -rf .mypy_cache
32
+ rm -rf .ruff_cache
33
+ rm -rf dist
34
+ rm -rf build
35
+ find . -type d -name "__pycache__" -exec rm -rf {} +
bpay-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,293 @@
1
+ Metadata-Version: 2.4
2
+ Name: bpay
3
+ Version: 0.1.0
4
+ Summary: Unified Python SDK for Bangladeshi payment gateways
5
+ Project-URL: Homepage, https://github.com/thatsayon/bpay-python
6
+ Project-URL: Repository, https://github.com/thatsayon/bpay-python
7
+ Project-URL: Issues, https://github.com/thatsayon/bpay-python/issues
8
+ Author: Ayon
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: bangladesh,bkash,nagad,payments,sslcommerz
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 :: Only
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.13
21
+ Requires-Dist: httpx>=0.28.1
22
+ Requires-Dist: pydantic>=2.13.4
23
+ Description-Content-Type: text/markdown
24
+
25
+ # bpay
26
+
27
+ Unified Python SDK for Bangladeshi payment gateways.
28
+
29
+ `bpay` provides a clean, typed, async-first developer experience for integrating Bangladeshi payment providers like bKash, Nagad, and SSLCommerz.
30
+
31
+ ---
32
+
33
+ ## Features
34
+
35
+ - Async-first architecture
36
+ - Typed request & response models
37
+ - Sandbox & production environment support
38
+ - Hosted checkout workflows
39
+ - Agreement/tokenized checkout support
40
+ - Payment callback parsing
41
+ - Payment verification support
42
+ - Provider abstraction layer
43
+ - Modern Python packaging with `uv`
44
+
45
+ ---
46
+
47
+ ## Supported Providers
48
+
49
+ | Provider | Status |
50
+ |---|---|
51
+ | bKash | In Progress |
52
+ | Nagad | Planned |
53
+ | SSLCommerz | Planned |
54
+
55
+ ---
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ pip install bpay
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Quick Start
66
+
67
+ ### Create a One-Time Payment
68
+
69
+ ```python
70
+ import asyncio
71
+
72
+ from bpay import BPay
73
+ from bpay.config.environments import (
74
+ Environment,
75
+ )
76
+ from bpay.schemas.payment import (
77
+ CreatePaymentRequest,
78
+ )
79
+
80
+
81
+ async def main() -> None:
82
+ client = BPay(
83
+ provider="bkash",
84
+ environment=Environment.SANDBOX,
85
+ username="YOUR_USERNAME",
86
+ password="YOUR_PASSWORD",
87
+ app_key="YOUR_APP_KEY",
88
+ app_secret="YOUR_APP_SECRET",
89
+ )
90
+
91
+ payment = await client.create_payment(
92
+ CreatePaymentRequest(
93
+ amount=100,
94
+ merchant_invoice_number="INV-1001",
95
+ callback_url=(
96
+ "https://yourdomain.com/callback"
97
+ ),
98
+ )
99
+ )
100
+
101
+ print(payment.checkout_url)
102
+
103
+
104
+ if __name__ == "__main__":
105
+ asyncio.run(main())
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Agreement / Tokenized Checkout
111
+
112
+ Agreements allow merchants to create reusable customer payment authorizations for recurring or saved payments.
113
+
114
+ ### Create Agreement
115
+
116
+ ```python
117
+ import asyncio
118
+
119
+ from bpay import BPay
120
+ from bpay.config.environments import (
121
+ Environment,
122
+ )
123
+ from bpay.schemas.agreement import (
124
+ CreateAgreementRequest,
125
+ )
126
+
127
+
128
+ async def main() -> None:
129
+ client = BPay(
130
+ provider="bkash",
131
+ environment=Environment.SANDBOX,
132
+ username="YOUR_USERNAME",
133
+ password="YOUR_PASSWORD",
134
+ app_key="YOUR_APP_KEY",
135
+ app_secret="YOUR_APP_SECRET",
136
+ )
137
+
138
+ agreement = await (
139
+ client.create_agreement(
140
+ CreateAgreementRequest(
141
+ customer_phone="017XXXXXXXX",
142
+ callback_url=(
143
+ "https://yourdomain.com/callback"
144
+ ),
145
+ )
146
+ )
147
+ )
148
+
149
+ print(agreement.checkout_url)
150
+
151
+
152
+ if __name__ == "__main__":
153
+ asyncio.run(main())
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Callback Parsing
159
+
160
+ ### Payment Callback
161
+
162
+ ```python
163
+ from bpay import BPay
164
+
165
+ client = BPay(...)
166
+
167
+ callback = client.parse_payment_callback(
168
+ {
169
+ "paymentID": "PAY123",
170
+ "status": "success",
171
+ "signature": "abc123",
172
+ }
173
+ )
174
+
175
+ print(callback.status)
176
+ ```
177
+
178
+ ---
179
+
180
+ ### Agreement Callback
181
+
182
+ ```python
183
+ from bpay import BPay
184
+
185
+ client = BPay(...)
186
+
187
+ callback = (
188
+ client.parse_agreement_callback(
189
+ {
190
+ "paymentID": "PAY123",
191
+ "agreementID": "AGR123",
192
+ "status": "success",
193
+ "signature": "abc123",
194
+ }
195
+ )
196
+ )
197
+
198
+ print(callback.status)
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Payment Verification
204
+
205
+ ```python
206
+ verification = await client.verify_payment(
207
+ payment_id="PAY123"
208
+ )
209
+
210
+ print(verification.status)
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Environments
216
+
217
+ `bpay` supports both sandbox and production environments.
218
+
219
+ ### Sandbox
220
+
221
+ ```python
222
+ from bpay.config.environments import (
223
+ Environment,
224
+ )
225
+
226
+ Environment.SANDBOX
227
+ ```
228
+
229
+ ### Production
230
+
231
+ ```python
232
+ from bpay.config.environments import (
233
+ Environment,
234
+ )
235
+
236
+ Environment.PRODUCTION
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Development
242
+
243
+ ### Setup
244
+
245
+ ```bash
246
+ uv sync
247
+ ```
248
+
249
+ ### Run Checks
250
+
251
+ ```bash
252
+ make check
253
+ ```
254
+
255
+ ### Run Tests
256
+
257
+ ```bash
258
+ uv run pytest
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Project Structure
264
+
265
+ ```text
266
+ src/bpay/
267
+ ├── client.py
268
+ ├── exceptions.py
269
+ ├── config/
270
+ ├── providers/
271
+ ├── schemas/
272
+ ├── transports/
273
+ └── types.py
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Roadmap
279
+
280
+ - Full bKash recurring payment workflow
281
+ - Nagad integration
282
+ - SSLCommerz integration
283
+ - Refund support
284
+ - Webhook signature verification
285
+ - Automatic retry handling
286
+ - Sync client support
287
+ - Logging middleware
288
+
289
+ ---
290
+
291
+ ## License
292
+
293
+ MIT License
bpay-0.1.0/README.md ADDED
@@ -0,0 +1,269 @@
1
+ # bpay
2
+
3
+ Unified Python SDK for Bangladeshi payment gateways.
4
+
5
+ `bpay` provides a clean, typed, async-first developer experience for integrating Bangladeshi payment providers like bKash, Nagad, and SSLCommerz.
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - Async-first architecture
12
+ - Typed request & response models
13
+ - Sandbox & production environment support
14
+ - Hosted checkout workflows
15
+ - Agreement/tokenized checkout support
16
+ - Payment callback parsing
17
+ - Payment verification support
18
+ - Provider abstraction layer
19
+ - Modern Python packaging with `uv`
20
+
21
+ ---
22
+
23
+ ## Supported Providers
24
+
25
+ | Provider | Status |
26
+ |---|---|
27
+ | bKash | In Progress |
28
+ | Nagad | Planned |
29
+ | SSLCommerz | Planned |
30
+
31
+ ---
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install bpay
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Quick Start
42
+
43
+ ### Create a One-Time Payment
44
+
45
+ ```python
46
+ import asyncio
47
+
48
+ from bpay import BPay
49
+ from bpay.config.environments import (
50
+ Environment,
51
+ )
52
+ from bpay.schemas.payment import (
53
+ CreatePaymentRequest,
54
+ )
55
+
56
+
57
+ async def main() -> None:
58
+ client = BPay(
59
+ provider="bkash",
60
+ environment=Environment.SANDBOX,
61
+ username="YOUR_USERNAME",
62
+ password="YOUR_PASSWORD",
63
+ app_key="YOUR_APP_KEY",
64
+ app_secret="YOUR_APP_SECRET",
65
+ )
66
+
67
+ payment = await client.create_payment(
68
+ CreatePaymentRequest(
69
+ amount=100,
70
+ merchant_invoice_number="INV-1001",
71
+ callback_url=(
72
+ "https://yourdomain.com/callback"
73
+ ),
74
+ )
75
+ )
76
+
77
+ print(payment.checkout_url)
78
+
79
+
80
+ if __name__ == "__main__":
81
+ asyncio.run(main())
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Agreement / Tokenized Checkout
87
+
88
+ Agreements allow merchants to create reusable customer payment authorizations for recurring or saved payments.
89
+
90
+ ### Create Agreement
91
+
92
+ ```python
93
+ import asyncio
94
+
95
+ from bpay import BPay
96
+ from bpay.config.environments import (
97
+ Environment,
98
+ )
99
+ from bpay.schemas.agreement import (
100
+ CreateAgreementRequest,
101
+ )
102
+
103
+
104
+ async def main() -> None:
105
+ client = BPay(
106
+ provider="bkash",
107
+ environment=Environment.SANDBOX,
108
+ username="YOUR_USERNAME",
109
+ password="YOUR_PASSWORD",
110
+ app_key="YOUR_APP_KEY",
111
+ app_secret="YOUR_APP_SECRET",
112
+ )
113
+
114
+ agreement = await (
115
+ client.create_agreement(
116
+ CreateAgreementRequest(
117
+ customer_phone="017XXXXXXXX",
118
+ callback_url=(
119
+ "https://yourdomain.com/callback"
120
+ ),
121
+ )
122
+ )
123
+ )
124
+
125
+ print(agreement.checkout_url)
126
+
127
+
128
+ if __name__ == "__main__":
129
+ asyncio.run(main())
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Callback Parsing
135
+
136
+ ### Payment Callback
137
+
138
+ ```python
139
+ from bpay import BPay
140
+
141
+ client = BPay(...)
142
+
143
+ callback = client.parse_payment_callback(
144
+ {
145
+ "paymentID": "PAY123",
146
+ "status": "success",
147
+ "signature": "abc123",
148
+ }
149
+ )
150
+
151
+ print(callback.status)
152
+ ```
153
+
154
+ ---
155
+
156
+ ### Agreement Callback
157
+
158
+ ```python
159
+ from bpay import BPay
160
+
161
+ client = BPay(...)
162
+
163
+ callback = (
164
+ client.parse_agreement_callback(
165
+ {
166
+ "paymentID": "PAY123",
167
+ "agreementID": "AGR123",
168
+ "status": "success",
169
+ "signature": "abc123",
170
+ }
171
+ )
172
+ )
173
+
174
+ print(callback.status)
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Payment Verification
180
+
181
+ ```python
182
+ verification = await client.verify_payment(
183
+ payment_id="PAY123"
184
+ )
185
+
186
+ print(verification.status)
187
+ ```
188
+
189
+ ---
190
+
191
+ ## Environments
192
+
193
+ `bpay` supports both sandbox and production environments.
194
+
195
+ ### Sandbox
196
+
197
+ ```python
198
+ from bpay.config.environments import (
199
+ Environment,
200
+ )
201
+
202
+ Environment.SANDBOX
203
+ ```
204
+
205
+ ### Production
206
+
207
+ ```python
208
+ from bpay.config.environments import (
209
+ Environment,
210
+ )
211
+
212
+ Environment.PRODUCTION
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Development
218
+
219
+ ### Setup
220
+
221
+ ```bash
222
+ uv sync
223
+ ```
224
+
225
+ ### Run Checks
226
+
227
+ ```bash
228
+ make check
229
+ ```
230
+
231
+ ### Run Tests
232
+
233
+ ```bash
234
+ uv run pytest
235
+ ```
236
+
237
+ ---
238
+
239
+ ## Project Structure
240
+
241
+ ```text
242
+ src/bpay/
243
+ ├── client.py
244
+ ├── exceptions.py
245
+ ├── config/
246
+ ├── providers/
247
+ ├── schemas/
248
+ ├── transports/
249
+ └── types.py
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Roadmap
255
+
256
+ - Full bKash recurring payment workflow
257
+ - Nagad integration
258
+ - SSLCommerz integration
259
+ - Refund support
260
+ - Webhook signature verification
261
+ - Automatic retry handling
262
+ - Sync client support
263
+ - Logging middleware
264
+
265
+ ---
266
+
267
+ ## License
268
+
269
+ MIT License
File without changes
@@ -0,0 +1,24 @@
1
+ import asyncio
2
+
3
+ from bpay.providers.bkash.auth import BkashAuth
4
+ from bpay.providers.bkash.schemas import BkashCredentials
5
+
6
+
7
+ async def main() -> None:
8
+ credentials = BkashCredentials(
9
+ username="sandboxTokenizedUser02",
10
+ password="sandboxTokenizedUser02@12345",
11
+ app_key="4f6o0cjiki2rfm34kfdadl1eqq",
12
+ app_secret="2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b",
13
+ )
14
+
15
+ auth = BkashAuth(credentials=credentials)
16
+
17
+ token = await auth.authenticate()
18
+
19
+ print("Token Type:", token.token_type)
20
+ print("Expires In:", token.expires_in)
21
+
22
+
23
+ if __name__ == "__main__":
24
+ asyncio.run(main())
@@ -0,0 +1,14 @@
1
+ import asyncio
2
+
3
+ from bpay.client import BPay
4
+
5
+
6
+ async def main() -> None:
7
+ client = BPay(provider="bkash")
8
+
9
+ result = await client.provider.create_payment()
10
+
11
+ print(result)
12
+
13
+
14
+ asyncio.run(main())
@@ -0,0 +1,14 @@
1
+ from bpay.providers.bkash.callbacks import (
2
+ parse_agreement_callback,
3
+ )
4
+
5
+ params = {
6
+ "paymentID": "TR001",
7
+ "status": "success",
8
+ "signature": "abc123",
9
+ "agreementID": "AGR001",
10
+ }
11
+
12
+ callback = parse_agreement_callback(params)
13
+
14
+ print(callback)