Pular para o conteúdo

SDK Python

feitpay não tem dependências de terceiros (usa urllib, hmac e json).

Janela do terminal
pip install feitpay # quando for publicado; no monorepo, use sdk/python diretamente
import os
from feitpay import FeitPay, FeitPayError, NotFoundError
gp = FeitPay(api_key=os.environ["FEITPAY_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)

Recursos: payment_intents, checkout_sessions, invoices, payment_links, transactions, wallets, stores, webhook_endpoints, webhook_deliveries, events, reports, billing, platform. As respostas são dicts simples que espelham a API; os valores continuam strings. format_base_units("99834", 8) formata com exatidão.

As novas tentativas seguem as mesmas regras dos outros SDKs (GET e POST com chave; erros de rede, 429, 5xx; backoff exponencial com jitter respeitando Retry-After).

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

Execute os testes a partir de sdk/python: python -I -m unittest discover -s tests -t .