Python client library for the Paylio API
Project description
Paylio Python SDK
Python client library for the Paylio API.
Installation
pip install paylio
Usage
import paylio
client = paylio.PaylioClient("sk_live_xxx")
# Get current subscription
sub = client.subscription.retrieve("user_123")
print(sub.status) # "active"
print(sub.plan.name) # "Pro Plan"
print(sub.plan.amount) # 999
# List subscription history
history = client.subscription.list("user_123", page=1, page_size=10)
for item in history.items:
print(item.plan_name, item.status)
if history.has_more:
next_page = client.subscription.list("user_123", page=2)
# Cancel subscription (safe default: cancels at end of billing period)
result = client.subscription.cancel("subscription-uuid")
print(result.success) # True
# Cancel immediately
result = client.subscription.cancel("subscription-uuid", cancel_now=True)
Context Manager
with paylio.PaylioClient("sk_live_xxx") as client:
sub = client.subscription.retrieve("user_123")
Custom Base URL
client = paylio.PaylioClient("sk_test_xxx", base_url="https://api.paylio.pro/flying/v1")
Error Handling
import paylio
client = paylio.PaylioClient("sk_live_xxx")
try:
sub = client.subscription.retrieve("user_123")
except paylio.AuthenticationError:
print("Invalid API key")
except paylio.NotFoundError:
print("Subscription not found")
except paylio.InvalidRequestError as e:
print(f"Bad request: {e.message}")
except paylio.APIError as e:
print(f"API error: {e.message} (status {e.http_status})")
except paylio.APIConnectionError:
print("Network error")
Requirements
- Python 3.9+
- httpx
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
paylio-0.1.1.tar.gz
(8.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paylio-0.1.1.tar.gz.
File metadata
- Download URL: paylio-0.1.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e8e65d1255165e1cbd77c9bc5aefda55c4bf82f645b60cd8e722494a7a51f9c
|
|
| MD5 |
1d8bf6e890944983dd24468370a414d2
|
|
| BLAKE2b-256 |
5b946bab1cd97fbdb3381a1dd20634073a2f59ac07b93686fb349f9c77fe50d1
|
File details
Details for the file paylio-0.1.1-py3-none-any.whl.
File metadata
- Download URL: paylio-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e69cd6ff6315686db7527be71dcca6b679bbf774d7b3b32c5712a61d112eab4c
|
|
| MD5 |
e629e75e620ea90bf012493791a766b4
|
|
| BLAKE2b-256 |
f907cc49a38e01664c6d0379c3f553e9e9e2ba912539d62cf402547e9fb6f62f
|