Skip to main content

Python client for the eDahab payment API

Project description

eDahab logo

edahab (Python SDK)

Python client for the official eDahab API.

PyPIn8n Node PackageStatus Codes


Product Separation

This repository contains two separate libraries:

  • Python SDK (this package): edahab
  • n8n community node package: n8n-nodes-edahab/

They are versioned and published independently.


Quick Start

pip install edahab
from edahab import configure, pay, is_invoice_paid

configure("your-api-key", "your-api-secret")

result = pay(
    customer="65",
    amount=1,
    agent="5555",
    currency="USD",  # required
)

print(result.invoice_id, is_invoice_paid(result.invoice_status))

currency is required on all payment methods and must be USD or SLSH.


Core API

Configuration

  • configure(api_key, api_secret, ...)
  • configure_from_env(...)
  • get_client()
  • clear_configuration()

Payment helpers

  • pay(...)Issueinvoice
  • verify_invoice(...)CheckInvoiceStatus
  • send_credit(...)agentPayment

Utilities

  • normalize_currency("usd") -> "USD"
  • is_invoice_paid(status)
  • generate_request_hash(serialized_body, api_secret)
  • serialize_body(payload)
  • describe_status_code(code)

Interactive Reference

configure / configure_from_env examples
from edahab import configure, configure_from_env, get_client

# Explicit:
configure("your-api-key", "your-api-secret")

# Or environment-based:
# export EDAHAB_API_KEY=...
# export EDAHAB_API_SECRET=...
configure_from_env()

client = get_client()
pay() and verify_invoice() examples
from edahab import configure, pay, verify_invoice

configure("your-api-key", "your-api-secret")

invoice = pay(customer="65", amount=1, agent="5555", currency="USD")

if invoice.invoice_id:
    verified = verify_invoice(invoice_id=invoice.invoice_id)
    print(verified.invoice_status)
send_credit() example
from edahab import configure, send_credit

configure("your-api-key", "your-api-secret")

credit = send_credit(
    to="252612345678",
    amount=100,
    reference="order-999",
    currency="SLSH",
)
print(credit.transaction_status, credit.transaction_message)
Low-level EdahabClient methods
from edahab import EdahabClient

client = EdahabClient("your-api-key", "your-api-secret")

client.issue_invoice("65", 1, "5555", currency="USD")
client.agent_payment("252612345678", 100, "order-999", currency="SLSH")
client.check_invoice_status("INV123456789")
Error handling pattern
from edahab import (
    EdahabClient,
    EdahabCredentialError,
    EdahabValidationError,
    EdahabAPIStatusError,
    EdahabHTTPError,
)

client = EdahabClient("your-api-key", "your-api-secret")

try:
    client.issue_invoice("65", 1, "5555", currency="USD")
except EdahabCredentialError:
    print("Invalid API key/secret/hash")
except EdahabValidationError as e:
    print(e.validation_errors)
except EdahabAPIStatusError as e:
    print(e.status_code, e.raw_response)
except EdahabHTTPError as e:
    print(e.status_code, e.body)

Official Docs


Exports

configure, configure_from_env, get_client, clear_configuration, pay, verify_invoice, send_credit, is_invoice_paid, normalize_currency, generate_request_hash, serialize_body, describe_status_code, EdahabClient, DEFAULT_BASE_URL, StatusCode, STATUS_DESCRIPTIONS, IssueInvoiceResult, CheckInvoiceStatusResult, AgentPaymentResult, EdahabError, EdahabHTTPError, EdahabDecodeError, EdahabCredentialError, EdahabValidationError, EdahabAPIStatusError.

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

edahab-2.0.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edahab-2.0.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file edahab-2.0.0.tar.gz.

File metadata

  • Download URL: edahab-2.0.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for edahab-2.0.0.tar.gz
Algorithm Hash digest
SHA256 3f0077ead66d0ea6ef2dc98913853f11bdebda270167ca18ff7ef286bc2977c3
MD5 105f9584287464aa64ec3ec414d887db
BLAKE2b-256 77f2896888d2bbfdcd1b5301bfecd9c3a263d4c7e819ad6894a34778de6f8064

See more details on using hashes here.

File details

Details for the file edahab-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: edahab-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for edahab-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dade77d4d17dd995857eebe402297b0968b0384b57ce8a7d9b6ce0e0fa82c52f
MD5 e4058fd81ad5d1e30a9bbd09ce1eefba
BLAKE2b-256 939f817b6482a8d1a2f046b31d599f5f747390b034ecb39dceada779a1528d3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page