An unofficial SDK for Paddle's billing API and webhooks.
Project description
Unofficial Paddle Billing Python SDK
A small Paddle Billing SDK. It uses pydantic for schemas derived from the Paddle Billing OpenAPI file.
Installation
To install the package, install it from pypi:
uv add python-paddle
# or
pip install python-paddle
Or your favorite package manager.
Usage
Currently, the SDK does not provide functions to call the API for all resources. It does provide two things:
- API schemas as Pydantic models
- Webhook validation
- Operations on customers
- Operations on transactions
Calling the API
To call the API, you need to initialize a client:
from paddle import Paddle
client = Paddle(token="...")
In case you're using the sandbox environment, pass production = False as an argument when
initializing the Paddle class.
client = Paddle(token="...", production=False)
Once you have the client, you can call any methods on it asynchronously. For example:
transaction = await client.get_transaction(transaction_id)
Schemas
The schemas can be found under paddle.schemas, like paddle.schemas.Transaction.
Webhooks
Webhooks can be validated using paddle.webhooks.verify. For example:
from paddle import webhooks
webhooks.verify(
secret="YOUR_WEBHOOK_SECRET",
signature="YOUR_WEBHOOK_SIGNATURE", # Extract this value from the `Paddle-Signature` in the webhook request
body="THE_REQUEST_BODY",
)
It'll raise a paddle.webhooks.exceptions.ValidationError if the webhook could not be verified,
otherwise it'll return True.
To instead get a bool returned from the function, without an error raised on failure, pass the
error=False argument.
from paddle import webhooks
is_valid = webhooks.verify(
secret="YOUR_WEBHOOK_SECRET",
signature="YOUR_WEBHOOK_SIGNATURE", # Extract this value from the `Paddle-Signature` in the webhook request
body="THE_REQUEST_BODY",
error=False,
)
if is_valid:
print("Great!")
else:
print("Damn")
Exceptions
All exceptions raised by this library inherit from paddle.exceptions.PaddleException.
Contributing
All contributions are welcome! Whether it's tests, bugs, documentation, or anything else, open an issue in our GitHub repository. Thanks for your interest!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 python_paddle-0.2.14.tar.gz.
File metadata
- Download URL: python_paddle-0.2.14.tar.gz
- Upload date:
- Size: 47.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffd7f3d6fd389f59eda6d770e5cbb83c54552f45ba5c4f5a57068adc5d2b3a89
|
|
| MD5 |
c7a21bf3d844761776dc036fa64e7f4e
|
|
| BLAKE2b-256 |
54053b0880a213decd0b62d141ad019e4ebfa3556c56668c987d3cfac64ea3da
|
File details
Details for the file python_paddle-0.2.14-py3-none-any.whl.
File metadata
- Download URL: python_paddle-0.2.14-py3-none-any.whl
- Upload date:
- Size: 55.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbb855a77b503e5de16136b17d997074a79686a1995ce42d1ca5a214c4cef001
|
|
| MD5 |
e4624e8aabe266ee25d48e7c6f046d16
|
|
| BLAKE2b-256 |
fcec735c5f45950f0d4872fb608e8155af32a52d62a1f332f8a3d37a5b4a25ee
|