Repository navigation
v0.1.0
First public release of FastAPI Payment Gateway.
Highlights
- Provider adapter pattern:
BkashAdapter,SSLCommerzAdapter,StripeAdapter(sandbox) and aMockProviderfor tests, all behind onePaymentProviderprotocol - Payment lifecycle state machine (
CREATED → AUTHORIZED → CAPTURED → PARTIALLY_REFUNDED/REFUNDED, plusFAILED/CANCELLED); illegal transitions are rejected with HTTP 409 and never persisted Idempotency-Keyheader on create/capture/refund: stored responses are replayed byte-for-byte, reuse with a different body is rejected- Merchant API keys stored as SHA-256 hashes with a lookup prefix; per-merchant data isolation
- Outgoing merchant webhooks signed with HMAC-SHA256 (
X-Gateway-Signature: t=…,v1=…), bounded retries, delivery log queryable via the API - Inbound provider webhook verification (bare HMAC for bKash/SSLCommerz, timestamped Stripe-style signature with replay window) with idempotent event application
- Fee-aware routing: cheapest provider for a currency/method pair, overridable per request; fees computed in basis points with half-up integer rounding, no floats anywhere near money
- Full and partial refunds with refundable-balance enforcement; partial captures re-quote the fee
- Daily settlement batches per provider and currency, CSV export, reconciliation that diffs the provider report against the ledger (mismatches, missing, unexpected) and a
PAIDclose-out - Health endpoint, request-id middleware, structured error envelope, OpenAPI docs at
/docs
Getting started
- Quick start (Docker and local): see the README.
- Live demo / API reference: https://akibullah.github.io/fastapi-payment-gateway/
- Run it in your browser: Open in GitHub Codespaces
Quality
- Full test suite, lint and build run in CI on every push and pull request.
- MIT licensed.