stableops 0.7.1__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,61 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ tags:
7
+ - 'v*.*.*'
8
+
9
+ jobs:
10
+ publish:
11
+ name: Build and publish
12
+ runs-on: ubuntu-latest
13
+ timeout-minutes: 15
14
+ permissions:
15
+ contents: read
16
+ id-token: write
17
+
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v7
21
+
22
+ - name: Setup Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: '3.12'
26
+
27
+ - name: Show tool versions
28
+ run: |
29
+ python --version
30
+ pip --version
31
+
32
+ - name: Install dependencies
33
+ run: |
34
+ python -m pip install --upgrade pip
35
+ pip install -e ".[dev]"
36
+
37
+ - name: Lint
38
+ run: ruff check .
39
+
40
+ - name: Typecheck
41
+ run: mypy stableops/ tests/
42
+
43
+ - name: Test
44
+ run: pytest
45
+
46
+ - name: Build
47
+ run: pip install build && python -m build
48
+
49
+ - name: Verify tag matches package version
50
+ if: startsWith(github.ref, 'refs/tags/')
51
+ shell: bash
52
+ run: |
53
+ PACKAGE_VERSION="$(python -c "import tomllib; f=open('pyproject.toml','rb'); print(tomllib.load(f)['project']['version'])")"
54
+ TAG_VERSION="${GITHUB_REF_NAME#v}"
55
+ if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
56
+ echo "Tag v${TAG_VERSION} does not match pyproject.toml version ${PACKAGE_VERSION}."
57
+ exit 1
58
+ fi
59
+
60
+ - name: Publish to PyPI
61
+ uses: pypa/gh-action-pypi-publish@v1.12.4
@@ -0,0 +1,26 @@
1
+ # Byte-compiled / optimized
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+ .eggs/
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # Test / coverage / type-check caches
18
+ .coverage
19
+ .coverage.*
20
+ htmlcov/
21
+ .pytest_cache/
22
+ .mypy_cache/
23
+ .ruff_cache/
24
+
25
+ # OS / editor
26
+ .DS_Store
@@ -0,0 +1,65 @@
1
+ [MASTER]
2
+ ignore=.venv,venv,env,__pycache__,build,dist
3
+ persistent=no
4
+ jobs=0
5
+
6
+ [MESSAGES CONTROL]
7
+ disable=
8
+ C,
9
+ R,
10
+ too-few-public-methods,
11
+ too-many-arguments,
12
+ too-many-locals,
13
+ too-many-branches,
14
+ too-many-statements,
15
+ too-many-return-statements,
16
+ too-many-instance-attributes,
17
+ too-many-public-methods,
18
+ too-many-nested-blocks,
19
+ too-many-ancestors,
20
+ too-many-lines,
21
+ duplicate-code,
22
+ missing-module-docstring,
23
+ missing-class-docstring,
24
+ missing-function-docstring,
25
+ import-error,
26
+ no-name-in-module,
27
+ broad-exception-caught,
28
+ broad-except,
29
+ fixme,
30
+ wrong-import-position,
31
+ redefined-outer-name,
32
+ unspecified-encoding,
33
+ unused-argument,
34
+ raise-missing-from,
35
+
36
+ [REFORMAT]
37
+ max-line-length=100
38
+ single-line-if-stmt=no
39
+ single-line-class-stmt=no
40
+
41
+ [BASIC]
42
+ good-names=i,j,k,x,y,z,ex,_,pk
43
+ bad-names=foo,bar,baz,toto,tata,tutu
44
+ module-rgx=^[a-z][a-z0-9_]*$
45
+ class-rgx=^_?[A-Z][a-zA-Z0-9]*$
46
+ function-rgx=^_?[a-z][a-z0-9_]*$
47
+ method-rgx=^_?[a-z][a-z0-9_]*$
48
+ attr-rgx=^_?[a-z][a-z0-9_]*$
49
+ argument-rgx=^[a-z][a-z0-9_]*$
50
+ variable-rgx=^_?[a-z][a-z0-9_]*$
51
+ class-attribute-naming-style=snake_case
52
+ inlinevar-rgx=^[a-z][a-z0-9_]*$
53
+
54
+ [DESIGN]
55
+ max-args=10
56
+ max-locals=25
57
+ max-returns=6
58
+ max-branches=20
59
+ max-statements=100
60
+ max-parents=7
61
+ max-attributes=10
62
+ min-public-methods=1
63
+
64
+ [EXCEPTIONS]
65
+ overgeneral-exceptions=builtins.Exception
@@ -0,0 +1,184 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form,
34
+ made available under the License, as indicated by a copyright notice that is
35
+ included in or attached to the work (an example is provided in the Appendix
36
+ below).
37
+
38
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
39
+ is based on (or derived from) the Work and for which the editorial revisions,
40
+ annotations, elaborations, or other modifications represent, as a whole, an
41
+ original work of authorship. For the purposes of this License, Derivative Works
42
+ shall not include works that remain separable from, or merely link (or bind by
43
+ name) to the interfaces of, the Work and Derivative Works thereof.
44
+
45
+ "Contribution" shall mean any work of authorship, including the original
46
+ version of the Work and any modifications or additions to that Work or
47
+ Derivative Works thereof, that is intentionally submitted to Licensor for
48
+ inclusion in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes of this
50
+ definition, "submitted" means any form of electronic, verbal, or written
51
+ communication sent to the Licensor or its representatives, including but not
52
+ limited to communication on electronic mailing lists, source code control
53
+ systems, and issue tracking systems that are managed by, or on behalf of, the
54
+ Licensor for the purpose of discussing and improving the Work, but excluding
55
+ communication that is conspicuously marked or otherwise designated in writing by
56
+ the copyright owner as "Not a Contribution."
57
+
58
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
59
+ of whom a Contribution has been received by Licensor and subsequently
60
+ incorporated within the Work.
61
+
62
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
63
+ License, each Contributor hereby grants to You a perpetual, worldwide,
64
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
65
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
66
+ sublicense, and distribute the Work and such Derivative Works in Source or
67
+ Object form.
68
+
69
+ 3. Grant of Patent License. Subject to the terms and conditions of this
70
+ License, each Contributor hereby grants to You a perpetual, worldwide,
71
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
72
+ section) patent license to make, have made, use, offer to sell, sell, import,
73
+ and otherwise transfer the Work, where such license applies only to those patent
74
+ claims licensable by such Contributor that are necessarily infringed by their
75
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
76
+ to which such Contribution(s) was submitted. If You institute patent litigation
77
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
78
+ alleging that the Work or a Contribution incorporated within the Work
79
+ constitutes direct or contributory patent infringement, then any patent licenses
80
+ granted to You under this License for that Work shall terminate as of the date
81
+ such litigation is filed.
82
+
83
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
84
+ Derivative Works thereof in any medium, with or without modifications, and in
85
+ Source or Object form, provided that You meet the following conditions:
86
+
87
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
88
+ this License; and
89
+
90
+ (b) You must cause any modified files to carry prominent notices stating that
91
+ You changed the files; and
92
+
93
+ (c) You must retain, in the Source form of any Derivative Works that You
94
+ distribute, all copyright, patent, trademark, and attribution notices from the
95
+ Source form of the Work, excluding those notices that do not pertain to any part
96
+ of the Derivative Works; and
97
+
98
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
99
+ any Derivative Works that You distribute must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, excluding those notices
101
+ that do not pertain to any part of the Derivative Works, in at least one of the
102
+ following places: within a NOTICE text file distributed as part of the
103
+ Derivative Works; within the Source form or documentation, if provided along
104
+ with the Derivative Works; or, within a display generated by the Derivative
105
+ Works, if and wherever such third-party notices normally appear. The contents of
106
+ the NOTICE file are for informational purposes only and do not modify the
107
+ License. You may add Your own attribution notices within Derivative Works that
108
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
109
+ provided that such additional attribution notices cannot be construed as
110
+ modifying the License.
111
+
112
+ You may add Your own copyright statement to Your modifications and may provide
113
+ additional or different license terms and conditions for use, reproduction, or
114
+ distribution of Your modifications, or for any such Derivative Works as a whole,
115
+ provided Your use, reproduction, and distribution of the Work otherwise complies
116
+ with the conditions stated in this License.
117
+
118
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
119
+ Contribution intentionally submitted for inclusion in the Work by You to the
120
+ Licensor shall be under the terms and conditions of this License, without any
121
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
122
+ supersede or modify the terms of any separate license agreement you may have
123
+ executed with Licensor regarding such Contributions.
124
+
125
+ 6. Trademarks. This License does not grant permission to use the trade names,
126
+ trademarks, service marks, or product names of the Licensor, except as required
127
+ for reasonable and customary use in describing the origin of the Work and
128
+ reproducing the content of the NOTICE file.
129
+
130
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
131
+ writing, Licensor provides the Work (and each Contributor provides its
132
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
133
+ KIND, either express or implied, including, without limitation, any warranties
134
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
135
+ PARTICULAR PURPOSE. You are solely responsible for determining the
136
+ appropriateness of using or redistributing the Work and assume any risks
137
+ associated with Your exercise of permissions under this License.
138
+
139
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
140
+ tort (including negligence), contract, or otherwise, unless required by
141
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
142
+ writing, shall any Contributor be liable to You for damages, including any
143
+ direct, indirect, special, incidental, or consequential damages of any
144
+ character arising as a result of this License or out of the use or inability to
145
+ use the Work (including but not limited to damages for loss of goodwill, work
146
+ stoppage, computer failure or malfunction, or any and all other commercial
147
+ damages or losses), even if such Contributor has been advised of the
148
+ possibility of such damages.
149
+
150
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
151
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
152
+ acceptance of support, warranty, indemnity, or other liability obligations
153
+ and/or rights consistent with this License. However, in accepting such
154
+ obligations, You may act only on Your own behalf and on Your sole
155
+ responsibility, not on behalf of any other Contributor, and only if You agree
156
+ to indemnify, defend, and hold each Contributor harmless for any liability
157
+ incurred by, or claims asserted against, such Contributor by reason of your
158
+ accepting any such warranty or additional liability.
159
+
160
+ END OF TERMS AND CONDITIONS
161
+
162
+ APPENDIX: How to apply the Apache License to your work.
163
+
164
+ To apply the Apache License to your work, attach the following boilerplate
165
+ notice, with the fields enclosed by brackets "[]" replaced with your own
166
+ identifying information. (Don't include the brackets!) The text should be
167
+ enclosed in the appropriate comment syntax for the file format. We also
168
+ recommend that a file or class name and description of purpose be included on
169
+ the same "printed page" as the copyright notice for easier identification
170
+ within third-party archives.
171
+
172
+ Copyright [yyyy] [name of copyright owner]
173
+
174
+ Licensed under the Apache License, Version 2.0 (the "License");
175
+ you may not use this file except in compliance with the License.
176
+ You may obtain a copy of the License at
177
+
178
+ https://www.apache.org/licenses/LICENSE-2.0
179
+
180
+ Unless required by applicable law or agreed to in writing, software
181
+ distributed under the License is distributed on an "AS IS" BASIS,
182
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183
+ See the License for the specific language governing permissions and
184
+ limitations under the License.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: stableops
3
+ Version: 0.7.1
4
+ Summary: Official Python SDK for StableOps - Stablecoin payment infrastructure
5
+ Project-URL: Homepage, https://stableops.dev
6
+ Project-URL: Documentation, https://docs.stableops.dev
7
+ Project-URL: Repository, https://github.com/stableops/stableops
8
+ Project-URL: Bug Tracker, https://github.com/stableops/stableops/issues
9
+ Author-email: StableOps <hello@stableops.dev>
10
+ License: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: blockchain,crypto,payments,stablecoin,stableops,usdc,usdt
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Office/Business :: Financial
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.8
25
+ Requires-Dist: httpx>=0.24.0
26
+ Requires-Dist: pydantic>=2.0.0
27
+ Requires-Dist: typing-extensions>=4.5.0; python_version < '3.11'
28
+ Provides-Extra: dev
29
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
30
+ Requires-Dist: pylint>=3.0.0; extra == 'dev'
31
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
32
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
33
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
34
+ Requires-Dist: respx>=0.20.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # StableOps Python SDK
39
+
40
+ [![PyPI version](https://img.shields.io/pypi/v/stableops)](https://pypi.org/project/stableops/) [![PyPI downloads](https://img.shields.io/pypi/dm/stableops)](https://pypi.org/project/stableops/) [![License](https://img.shields.io/pypi/l/stableops)](./LICENSE) [![Python](https://img.shields.io/badge/Python-%3E%3D3.8-3776AB)](https://www.python.org)
41
+
42
+ [中文文档](./README.zh-CN.md)
43
+
44
+ StableOps turns on-chain stablecoin transfers into familiar payment primitives:
45
+ payment orders, deterministic status transitions, signed webhooks, retries, and
46
+ confirmation tracking. StableOps watches supported chains, matches transfers,
47
+ tracks confirmations, checks reorgs, and delivers webhook events to your app.
48
+
49
+ This SDK is for server-side Python applications that create payment orders and
50
+ checkout sessions, manage webhook endpoints, and verify webhook signatures.
51
+
52
+ ## Features
53
+
54
+ - Type-safe client (Pydantic v2 models) for payment orders, checkout sessions, and webhooks.
55
+ - Sync (`StableOps`) and async (`AsyncStableOps`) clients with an identical API.
56
+ - Built-in request retries and explicit idempotency for write operations.
57
+ - Constant-time webhook signature verification.
58
+
59
+ ## Requirements
60
+
61
+ - Python 3.8 or newer.
62
+ - A StableOps API key.
63
+ - A server-side environment. Do not expose your API key in browser code.
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ pip install stableops
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ ```python
74
+ import os
75
+
76
+ from stableops import StableOps
77
+
78
+ client = StableOps(api_key=os.environ["STABLEOPS_API_KEY"])
79
+
80
+ order = client.payment_orders.create(
81
+ merchant_order_id="order_123",
82
+ amount="49.00",
83
+ accepted_assets=[
84
+ {"chain": "base", "asset": "USDC"},
85
+ {"chain": "tron", "asset": "USDT"},
86
+ ],
87
+ expires_at="2026-12-31T23:59:59Z",
88
+ )
89
+
90
+ print(order.payment_instructions)
91
+ ```
92
+
93
+ The environment (sandbox / live) is determined by the API key prefix
94
+ (`sk_sandbox_…` / `sk_live_…`). Return only the order id, amount, and
95
+ `payment_instructions` to your frontend; the API key stays on your server.
96
+
97
+ ## Documentation
98
+
99
+ For complete guides, configuration, checkout sessions, webhook verification, and
100
+ the full API reference, see the official documentation:
101
+
102
+ - English docs: https://stableops.dev/en/docs/sdk/python-api-sdk
103
+ - Chinese docs: https://stableops.dev/zh/docs/sdk/python-api-sdk
104
+
105
+ ## Supported Chains and Assets
106
+
107
+ - Chains: Ethereum, Base, Arbitrum, Polygon, Optimism, BSC, TRON, Solana, and supported testnets.
108
+ - Assets: USDC and USDT.
109
+
110
+ ## License
111
+
112
+ This SDK is licensed under `Apache-2.0`. See [LICENSE](./LICENSE).
@@ -0,0 +1,75 @@
1
+ # StableOps Python SDK
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/stableops)](https://pypi.org/project/stableops/) [![PyPI downloads](https://img.shields.io/pypi/dm/stableops)](https://pypi.org/project/stableops/) [![License](https://img.shields.io/pypi/l/stableops)](./LICENSE) [![Python](https://img.shields.io/badge/Python-%3E%3D3.8-3776AB)](https://www.python.org)
4
+
5
+ [中文文档](./README.zh-CN.md)
6
+
7
+ StableOps turns on-chain stablecoin transfers into familiar payment primitives:
8
+ payment orders, deterministic status transitions, signed webhooks, retries, and
9
+ confirmation tracking. StableOps watches supported chains, matches transfers,
10
+ tracks confirmations, checks reorgs, and delivers webhook events to your app.
11
+
12
+ This SDK is for server-side Python applications that create payment orders and
13
+ checkout sessions, manage webhook endpoints, and verify webhook signatures.
14
+
15
+ ## Features
16
+
17
+ - Type-safe client (Pydantic v2 models) for payment orders, checkout sessions, and webhooks.
18
+ - Sync (`StableOps`) and async (`AsyncStableOps`) clients with an identical API.
19
+ - Built-in request retries and explicit idempotency for write operations.
20
+ - Constant-time webhook signature verification.
21
+
22
+ ## Requirements
23
+
24
+ - Python 3.8 or newer.
25
+ - A StableOps API key.
26
+ - A server-side environment. Do not expose your API key in browser code.
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install stableops
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```python
37
+ import os
38
+
39
+ from stableops import StableOps
40
+
41
+ client = StableOps(api_key=os.environ["STABLEOPS_API_KEY"])
42
+
43
+ order = client.payment_orders.create(
44
+ merchant_order_id="order_123",
45
+ amount="49.00",
46
+ accepted_assets=[
47
+ {"chain": "base", "asset": "USDC"},
48
+ {"chain": "tron", "asset": "USDT"},
49
+ ],
50
+ expires_at="2026-12-31T23:59:59Z",
51
+ )
52
+
53
+ print(order.payment_instructions)
54
+ ```
55
+
56
+ The environment (sandbox / live) is determined by the API key prefix
57
+ (`sk_sandbox_…` / `sk_live_…`). Return only the order id, amount, and
58
+ `payment_instructions` to your frontend; the API key stays on your server.
59
+
60
+ ## Documentation
61
+
62
+ For complete guides, configuration, checkout sessions, webhook verification, and
63
+ the full API reference, see the official documentation:
64
+
65
+ - English docs: https://stableops.dev/en/docs/sdk/python-api-sdk
66
+ - Chinese docs: https://stableops.dev/zh/docs/sdk/python-api-sdk
67
+
68
+ ## Supported Chains and Assets
69
+
70
+ - Chains: Ethereum, Base, Arbitrum, Polygon, Optimism, BSC, TRON, Solana, and supported testnets.
71
+ - Assets: USDC and USDT.
72
+
73
+ ## License
74
+
75
+ This SDK is licensed under `Apache-2.0`. See [LICENSE](./LICENSE).
@@ -0,0 +1,72 @@
1
+ # StableOps Python SDK
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/stableops)](https://pypi.org/project/stableops/) [![PyPI downloads](https://img.shields.io/pypi/dm/stableops)](https://pypi.org/project/stableops/) [![License](https://img.shields.io/pypi/l/stableops)](./LICENSE) [![Python](https://img.shields.io/badge/Python-%3E%3D3.8-3776AB)](https://www.python.org)
4
+
5
+ [English](./README.md)
6
+
7
+ StableOps 把链上稳定币转账封装成熟悉的支付原语:支付订单、确定性状态流转、签名
8
+ Webhook、自动重试与确认数跟踪。StableOps 负责扫描支持的链、匹配转账、跟踪确认数、
9
+ 校验 reorg,并把 Webhook 事件投递到你的应用。
10
+
11
+ 本 SDK 面向服务端 Python 应用:创建支付订单与 Checkout Session、管理 Webhook 端点、
12
+ 校验 Webhook 签名。
13
+
14
+ ## 特性
15
+
16
+ - 类型安全客户端(Pydantic v2 模型),覆盖支付订单、Checkout Session、Webhook。
17
+ - 同步(`StableOps`)与异步(`AsyncStableOps`)客户端,API 一致。
18
+ - 内置请求重试,写操作显式幂等。
19
+ - 常数时间的 Webhook 签名校验。
20
+
21
+ ## 要求
22
+
23
+ - Python 3.8 及以上。
24
+ - 一个 StableOps API Key。
25
+ - 服务端环境。不要在浏览器代码中暴露 API Key。
26
+
27
+ ## 安装
28
+
29
+ ```bash
30
+ pip install stableops
31
+ ```
32
+
33
+ ## 快速开始
34
+
35
+ ```python
36
+ import os
37
+
38
+ from stableops import StableOps
39
+
40
+ client = StableOps(api_key=os.environ["STABLEOPS_API_KEY"])
41
+
42
+ order = client.payment_orders.create(
43
+ merchant_order_id="order_123",
44
+ amount="49.00",
45
+ accepted_assets=[
46
+ {"chain": "base", "asset": "USDC"},
47
+ {"chain": "tron", "asset": "USDT"},
48
+ ],
49
+ expires_at="2026-12-31T23:59:59Z",
50
+ )
51
+
52
+ print(order.payment_instructions)
53
+ ```
54
+
55
+ 环境(sandbox / live)由 API Key 前缀(`sk_sandbox_…` / `sk_live_…`)决定。前端只接收
56
+ 订单 id、金额和 `payment_instructions`,API Key 始终留在你的服务端。
57
+
58
+ ## 文档
59
+
60
+ 完整的指南、配置、Checkout Session、Webhook 校验与 API 参考,请查阅官网文档:
61
+
62
+ - 中文文档:https://stableops.dev/zh/docs/sdk/python-api-sdk
63
+ - English docs:https://stableops.dev/en/docs/sdk/python-api-sdk
64
+
65
+ ## 支持的链与资产
66
+
67
+ - 链:Ethereum、Base、Arbitrum、Polygon、Optimism、BSC、TRON、Solana 及对应测试网。
68
+ - 资产:USDC、USDT。
69
+
70
+ ## 许可证
71
+
72
+ 本 SDK 使用 `Apache-2.0` 许可证,详见 [LICENSE](./LICENSE)。
@@ -0,0 +1,75 @@
1
+ # Python SDK Examples
2
+
3
+ This directory contains example code for using the StableOps Python SDK.
4
+
5
+ ## Examples
6
+
7
+ ### Basic Usage
8
+
9
+ **create_order.py** - Create and monitor a payment order
10
+
11
+ ```bash
12
+ export STABLEOPS_API_KEY=your_api_key
13
+ python examples/create_order.py
14
+ ```
15
+
16
+ ### Webhook Handler
17
+
18
+ **webhook_handler.py** - Flask webhook handler with signature verification
19
+
20
+ ```bash
21
+ export STABLEOPS_WEBHOOK_SECRET=whsec_...
22
+ python examples/webhook_handler.py
23
+
24
+ # In another terminal, expose with ngrok
25
+ ngrok http 5000
26
+ ```
27
+
28
+ ### Async Usage
29
+
30
+ **async_example.py** - Async client with AsyncStableOps
31
+
32
+ ```bash
33
+ export STABLEOPS_API_KEY=your_api_key
34
+ python examples/async_example.py
35
+ ```
36
+
37
+ ## Requirements
38
+
39
+ Install example dependencies:
40
+
41
+ ```bash
42
+ pip install stableops flask
43
+ ```
44
+
45
+ For async example:
46
+
47
+ ```bash
48
+ pip install stableops
49
+ ```
50
+
51
+ ## Testing Webhooks Locally
52
+
53
+ 1. Start the webhook handler:
54
+
55
+ ```bash
56
+ python examples/webhook_handler.py
57
+ ```
58
+
59
+ 2. Expose with ngrok:
60
+
61
+ ```bash
62
+ ngrok http 5000
63
+ ```
64
+
65
+ 3. Add webhook endpoint in StableOps dashboard:
66
+ - URL: `https://your-ngrok-url.ngrok.io/webhooks/stableops`
67
+ - Events: Select events to receive
68
+
69
+ 4. Create a test payment order and send a test payment
70
+
71
+ ## Documentation
72
+
73
+ - [API Documentation](https://docs.stableops.dev)
74
+ - [Integration Guides](https://docs.stableops.dev/guides)
75
+ - [Python SDK Reference](https://docs.stableops.dev/sdk/python)