Skip to content

Python SDK

gryphem_pay has no third-party dependencies (it uses urllib, hmac and json).

Terminal window
pip install gryphem-pay # once published; in the monorepo use sdk/python directly
import os
from gryphem_pay import Gryphem, GryphemError, NotFoundError
gp = Gryphem(api_key=os.environ["GRYPHEM_API_KEY"], base_url="https://api.feitpay.com", timeout=30, max_retries=2)
intent = gp.payment_intents.create(
store_id="store_YOUR_STORE_ID", amount="59.90", currency="EUR",
merchant_order_id="order-123", idempotency_key="order-123",
)
for pi in gp.payment_intents.list_all(status=["confirmed", "overpaid"]):
print(pi["id"], pi["fulfillable"])
try:
gp.invoices.retrieve("inv_missing")
except NotFoundError as exc:
print(exc.code, exc.request_id)

Resources: payment_intents, checkout_sessions, invoices, payment_links, transactions, wallets, stores, webhook_endpoints, webhook_deliveries, events, reports, billing, platform. Responses are plain dicts mirroring the API; amounts stay strings. format_base_units("99834", 8) formats exactly.

Retries follow the same rules as the other SDKs (GET and keyed POST; network errors, 429, 5xx; jittered exponential backoff honouring Retry-After).

from gryphem_pay import webhooks
from gryphem_pay.webhooks import WebhookVerificationError
try:
event = webhooks.verify(raw_body, headers["Gryphem-Signature"], [new_secret, old_secret])
except WebhookVerificationError as exc:
respond(400, {"error": exc.reason})

Run the tests from sdk/python: python -I -m unittest discover -s tests -t .