A Python package for verifying Paddle webhook signature
Project description
Paddle webhook signature verifier for Python
A Python package for verifying Paddle webhook signatures. Official Paddle SDKs are only available for PHP and Node.js. This packagage helps server side verification of Paddle webhook signatures if you are using a Python based backend framework like Django, Flask, FastAPI, etc.
Installation
pip install paddle-webhook-verification
Usage
FastAPI example
from fastapi import FastAPI, Request, Header, HTTPException
from paddle_webhook_signature_verifier import WebhookHandler
app = FastAPI()
handler = WebhookHandler(secret_key=b'your_secret_key')
@app.post("/webhook")
async def webhook(request: Request, paddle_signature: str = Header(None)):
try:
body_bytes = await request.body()
handler.verify_paddle_signature(paddle_signature, body_bytes)
return {"status": "ok"}
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
Flask example
from flask import Flask, request, abort
from paddle_webhook_signature_verifier import WebhookHandler
app = Flask(__name__)
handler = WebhookHandler(secret_key=b'your_secret_key')
@app.route("/webhook", methods=["POST"])
def webhook():
try:
paddle_signature = request.headers.get("Paddle-Signature")
body_bytes = request.get_data()
handler.verify_paddle_signature(paddle_signature, body_bytes)
return {"status": "ok"}, 200
except ValueError as e:
abort(400, description=str(e))
Django example
from django.http import JsonResponse
from paddle_webhook_signature_verifier import WebhookHandler
handler = WebhookHandler(secret_key=b'your_secret_key')
def webhook(request):
try:
paddle_signature = request.headers.get("Paddle-Signature")
body_bytes = request.body
handler.verify_paddle_signature(paddle_signature, body_bytes)
return JsonResponse({"status": "ok"})
except ValueError as e:
return JsonResponse({"error": str(e)}, status=400)
Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your improvements.
License
This project is licensed under the MIT License. See the LICENSE file for more details
Contact
For any questions or suggestions, feel free to open an issue or contact the maintainer at aneesh.arora.aa@gmail.com
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
File details
Details for the file paddle_webhook_signature_verifier-1.0.1.tar.gz
.
File metadata
- Download URL: paddle_webhook_signature_verifier-1.0.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d27d1eb9f4dae329aaf8f97bc5752dae6e961f8a3837b5a8b6520b80833b623 |
|
MD5 | 8f8a561f6bb07945a63de89ffcd285f3 |
|
BLAKE2b-256 | 542b7be9d5fb8b78720b9bb71423bd59e3a8603fa8aea52caf5c009b922dbfd9 |
File details
Details for the file paddle_webhook_signature_verifier-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: paddle_webhook_signature_verifier-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33a45c7ab25ee582244931b9c6251bbf5a75ce76655ca9d6d898e8caccd734a0 |
|
MD5 | c11266d2038a36c52b235bc0b8593303 |
|
BLAKE2b-256 | f99fcc340801322555b4a9349b577a361bb1dc53b4ee4a6cba149a62927fd0a1 |