How gaurav8299/payment-gateway-backend works
This is a Django REST payment-gateway backend for merchants and customers. Its principal flow is a merchant request to create a payment: the API delegates payment processing to a gateway adapter, records the result and ledger, and updates the associated order; asynchronous webhook delivery is a separate follow-on capability. The README also documents authentication and RBAC, refunds, wallets, analytics, audit, and notifications. The sampled source confirms adapter dispatch, repository writes, refund processing, and webhook delivery; some API routing and cross-domain wiring are represented only at the documented subsystem level.
Main entry points: payment_service.py Payment Service · tasks.py Refund Tasks · auth_service.py Auth Service · views.py Analytics API
Components 29
Identity and Tenancy
- Accounts API
apps/accounts/views.py - Auth Service
apps/accounts/services/auth_service.py
Commerce Lifecycle
- Payment API
apps/payments/views.py - Payment Service
apps/payments/services/payment_service.py - Gateway Factory
apps/payments/factories.py - Gateway Adapters
apps/payments/adapters - Payment Repository
apps/payments/repositories/payment_repository.py - Payment Records
apps/payments/models.py - Order Service
apps/orders/services/order_service.py - Orders
apps/orders/models.py - Refund Service
apps/refunds/services/refund_service.py - Refund Repository
apps/refunds/repositories/refund_repository.py - Refund Records
apps/refunds/models.py - Wallet Service
apps/wallet/services/wallet_service.py
Async Operations
- Refund Tasks
apps/refunds/tasks.py - Account Email Tasks
apps/accounts/tasks.py - Analytics API
apps/analytics/views.py - Analytics Service
apps/analytics/services - Invoice Service
apps/analytics/services/invoice_service.py - Webhook Tasks
apps/webhooks/tasks.py - Notification Tasks
apps/notifications/tasks.py
Shared Platform
- Redis
- Audit Middleware
apps/audit_logs/middleware.py - Audit Service
apps/audit_logs/services/audit_service.py - Audit Records
apps/audit_logs/models.py
Other components
- Merchant
- Customer
- External Gateways
- Merchant Webhook
Connections 28
- Merchant → Payment API: submits payment
- Payment API → Payment Service: delegates
- Payment Service → Gateway Factory: selects adapter
- Gateway Factory → Gateway Adapters: returns adapter
- Gateway Adapters → External Gateways: processes charge
- Payment Service → Payment Repository: records payment
- Payment Repository → Payment Records: writes ledger
- Payment Service → Orders: reads order
- Payment Service → Order Service: updates order
- Order Service → Orders: writes status
- Payment Service → Refund Service
- Payment Service → Webhook Tasks: publishes outbox event
- Webhook Tasks → Merchant Webhook: delivers signed event
- Customer → Accounts API: manages account
- Accounts API → Auth Service: delegates
- Auth Service → Redis: stores OTP tokens
- Auth Service → Account Email Tasks: dispatches email
- Refund Service → Refund Repository: persists refund
- Refund Repository → Refund Records: writes ledger
- Refund Tasks → Refund Repository: updates refund
- Refund Tasks → Gateway Factory: selects adapter
- Refund Tasks → Wallet Service: credits wallet
- Merchant → Analytics API: requests reports
- Analytics API → Analytics Service: delegates
- Analytics API → Invoice Service: generates invoices
- Audit Middleware → Audit Service: records activity
- Audit Service → Audit Records: writes audit log
- Notification Tasks → Merchant Webhook