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),
list_notes_forms(search=...), retrieve_notes_form(form_id),
list_payees(), create_payee(), retrieve_payee(), update_payee(),
delete_payee() and format_amount(value).
Checkout questions (notes forms)
A notes form is a reusable set of questions built in the dashboard (Payments → Notes Forms). Pass its id and the hosted checkout asks them; the buyer's answers come back on the intent.
form = esaalat.list_notes_forms()["results"][0]
intent = esaalat.create_intent(wallet=wallet_id, amount=5000, notes_form=form["id"])
current = esaalat.retrieve_intent(intent["id"])
current["notes_form"] # {"id", "name", "description"} or None
current["notes_answers"] # [{"id", "label", "type", "value"}] — empty until answered
Payees and payout wallets
A payee is the person inside your account who earns from a payment. Create
them with your own id and their payout wallets; then pass that id as
payee when creating the payment. The external id is immutable after
creation, and wallets are payee metadata — not Esaalat receiving wallets.
payee = esaalat.create_payee(
external_id="user-42",
name="Ahmed Ali",
wallets=[
{"provider": "KURAIMI", "accountNumber": "771234567", "name": "Main"}
],
)
intent = esaalat.create_intent(
wallet="<receiving-wallet-uuid>",
amount=5000,
payee=payee["external_id"],
)
create_payee() is an upsert: posting the same external id updates that
payee and returns it, so a platform can safely sync its people. The rest of
the surface is ordinary CRUD:
page = esaalat.list_payees(search="Ahmed", page_size=50)
one = esaalat.retrieve_payee("user-42")
updated = esaalat.update_payee(
"user-42",
wallets=[{"provider": "JAIB", "accountNumber": "770000000"}],
)
removed = esaalat.delete_payee("user-42")
# {"deleted": False, "deactivated": True, "id": ...} when payments or
# withdrawals reference the payee; {"deleted": True} when it had no history.
Providers are the enum Esaalat supports (for example KURAIMI, JAIB,
ONE_CASH); TEST is not a payout destination. Duplicate
provider/account-number pairs are rejected.
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.3.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.3.0.tar.gz | 15.6 kB | With provenance | Details for esaalat-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| esaalat-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for esaalat-0.3.0-py3-none-any.whl |
Total release size: 27.9 kB
Release files / esaalat-0.3.0.tar.gz
| Download URL | esaalat-0.3.0.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc1ed8cfd1d790cfd313c80d8c317f004636e3a1ac596d4bc701ae52d0dc7443
|
|
BLAKE2b-256 checksum How to use checksums |
7d7d61c5c350d873dd372203bb6ae517564be968cb687f5a290cd808e65cd0fa
|
| 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 14, 2026.
Transparency logRelease files / esaalat-0.3.0-py3-none-any.whl
| Download URL | esaalat-0.3.0-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2341d6c26d5bde0fca7a055eb30eb0254d4753af384c6934cdd9edcfeda316c9
|
|
BLAKE2b-256 checksum How to use checksums |
2e593301079980a152fdfda3c0f9e03fc2aee46a65929f2099f365df928644de
|
| 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 14, 2026.
Transparency logSecurity for esaalat 0.3.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.3.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 14, 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.