Shopline Python SDK
版本:0.2.0
功能概述
- OAuth 授权与 token 刷新
- Product / Order / Customer OpenAPI 封装
- Webhook 订阅管理接口
- Webhook verification token 与签名校验辅助方法
Webhook 用法
from shopline.api import ShoplineAPI
client = ShoplineAPI(
client_id="your_app_id",
client_secretkey="your_app_secret",
handle="Your App",
merchant_id="your_merchant_id",
)
client.set_access_token("your_access_token")
# 创建 webhook
webhook = client.webhook.create_webhook(
address="https://example.com/shopline/webhook",
topics=["order/create", "order/update"],
)
# 查询 webhook 列表
webhooks = client.webhook.get_webhooks(per_page=20, page=1)
# 查询单个 webhook
detail = client.webhook.get_webhook(webhook["id"])
# 更新 webhook
updated = client.webhook.update_webhook(
webhook["id"],
topics=["order/create", "order/paid"],
)
# 删除 webhook
client.webhook.delete_webhook(webhook["id"])
Webhook 接收辅助
SHOPLINE 在验证 webhook endpoint 时,会先发一个 {"topic": "webhook/verification"} 的 POST 请求。你的服务需要返回纯文本 verification token。
# App token 模式: 返回 base64(app_id)
plain_text = client.webhook.get_webhook_verification_token(use_app_token=True)
# Merchant token 模式: 返回 base64(merchant_id)
plain_text = client.webhook.get_webhook_verification_token(use_app_token=False)
如果后续需要校验 sign 参数,可以直接使用 SDK helper:
payload = {
"topic": "application/uninstall",
"merchant_id": "5dad5d2604515400018dcc90",
}
timestamp = "1618994178"
signature = client.webhook.generate_webhook_signature(payload, timestamp)
is_valid = client.webhook.verify_webhook_signature(payload, timestamp, signature)
Metadata
Release files for shopline-sdk 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shopline_sdk-0.2.0.tar.gz | 11.1 kB | Without provenance | Details for shopline_sdk-0.2.0.tar.gz |
Release files / shopline_sdk-0.2.0.tar.gz
| Download URL | shopline_sdk-0.2.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3eb9061d3306b308d82d86dc008fcaeadd6f58bb3fb92961981ddb8f61996db
|
|
BLAKE2b-256 checksum How to use checksums |
a65164a12968a082c6b9030076ac2c0a6926955e12dcd4829ffb79ac15d3a1b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.4.2 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/1.0.0 tqdm/4.30.0 CPython/3.8.10
|
Security for shopline-sdk 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.