esaalat (Python)
Server-side Esaalat client. It does the three things a merchant backend always writes by hand — the 1-hour token, the idempotency key, and the webhook HMAC — so an integration is three calls instead of forty lines.
- Locked checkout sessions — create the session on your server, give the browser only the token.
- Payment intents — create one server-side for platform orders, attach the buyer's reference, read status.
- Signed webhooks — verify
X-Esaalat-Signatureover the raw body, with a replay window. - No dependencies — standard library only (
urllib,hmac,json).
Install
pip install esaalat
Quick start
from esaalat import EsaalatClient
# Reads ESAALAT_CLIENT_ID, ESAALAT_CLIENT_SECRET and ESAALAT_WEBHOOK_SECRET.
esaalat = EsaalatClient.from_env()
# 1. Your server decides the amount; the browser gets only the token.
session = esaalat.create_session(order_id="order-123", amount=5000)
session["session_token"] # → checkout.open({ sessionToken }) in the browser
session["portal_url"] # → or send the buyer straight to this page
# 2. Fulfil on the signed webhook, never on the buyer's page.
@app.post("/esaalat/webhooks")
def webhook():
try:
event = esaalat.verify_webhook(
request.data, # the RAW body
request.headers["X-Esaalat-Signature"],
)
except EsaalatWebhookError:
return "", 400
if event["event"] == "payment.verified":
mark_order_paid(event["order_id"]) # idempotent on intent_id
return "", 200
Also available: create_intent(wallet=..., amount=..., order_id=...),
retrieve_intent(intent_id), attach_reference(intent_id, reference) and
format_amount(value).
What it handles for you
| Token | Issued once per client, cached, refreshed a minute before the JWT's own exp. |
| Idempotency | A UUID per create call, reused on every retry — a 429 or a timeout can never double-book an order. |
| Retries | 429, 5xx and network failures, honouring Retry-After. |
| Errors | EsaalatError with code, status, detail, attr and the API's per-field errors. |
| Webhooks | hmac.compare_digest, optional ±5 min window, 400-shaped EsaalatWebhookError. |
Configuration
| Argument | Environment | Default |
|---|---|---|
client_id |
ESAALAT_CLIENT_ID |
— (required) |
client_secret |
ESAALAT_CLIENT_SECRET |
— (required) |
webhook_secret |
ESAALAT_WEBHOOK_SECRET |
— (needed by verify_webhook) |
base_url |
ESAALAT_BASE_URL |
https://api.esaalat.com/api/v1 |
timeout |
— | 20 seconds |
max_retries |
— | 2 |
Every endpoint takes a secret= override in verify_webhook, because each
webhook endpoint on the dashboard has its own signing secret.
Notes
- The client secret is a server secret. Never call this from a browser or ship it in a mobile app; the browser only ever needs the session token.
- Amounts are whole Yemeni riyals.
format_amount(5000.5)refuses before the request leaves your process. - The webhook body must be the raw bytes:
json.dumps(request.get_json())will not match the signature.
Development
python -m unittest discover -s tests -t .
License
MIT © Esaalat
Metadata
Release files for esaalat 0.1.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 |
|---|---|---|---|---|
| esaalat-0.1.0.tar.gz | 11.8 kB | With provenance | Details for esaalat-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| esaalat-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for esaalat-0.1.0-py3-none-any.whl |
Total release size: 21.9 kB
Release files / esaalat-0.1.0.tar.gz
| Download URL | esaalat-0.1.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee364f0190eb32597e6e4a7f22dc0595fbafe396208a021caed174002ba8f220
|
|
BLAKE2b-256 checksum How to use checksums |
c2a6bb2e187adde5592103e17f2d08d50eb0756e450c573d93ccf91770762e33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / esaalat-0.1.0-py3-none-any.whl
| Download URL | esaalat-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4df23ef67e751e47edf04d39d0231e37bed477d6d778a1ce7edd9627ce8d2914
|
|
BLAKE2b-256 checksum How to use checksums |
2b0133f6ece1d05a913046b7aab171030ec3e1fbd8a3df11a82ac96ada6872af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for esaalat 0.1.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for esaalat-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA 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.