ServicesCrelio AppArchitectureApp Modules payments
Payment gateway integrations and transaction processing
- Payment gateway clients - Stripe, Razorpay, PhonePe, etc.
- Transaction management - Payment recording and status
- Customer profiles - Saved payment methods
- Gateway configuration - API keys and settings
core/ - BaseModel, utilities
admin/ - Labs, settings
finance/ - Billing for payment context
- Bill management (belongs in
finance/)
- Invoice generation (belongs in
finance/)
- B2B transactions (evaluated per case)
| Model | Responsibility | Key Fields |
|---|
Payments | Payment record | amount, status, gateway, transaction_id |
PaymentGatewayTransactions | Gateway responses | gateway_response, status |
PaymentGatewayKeys | Credentials | gateway, api_key, secret_key |
CustomerPaymentProfiles | Saved methods | customer_id, card_token |
OnlinePayment | Online payment link | link, amount, expiry |
Each gateway has a dedicated client:
payments/clients/
├── stripe/
│ ├── client.py
│ └── views.py
├── razorpay/
│ ├── client.py
│ └── views.py
├── phonepe/
│ ├── client.py
│ └── views.py
├── phonepev1/
├── paytabs/
├── pesopay/
└── square/
# payments/clients/stripe/client.py
class StripeClient:
def __init__(self, api_key):
self.client = stripe
self.client.api_key = api_key
def create_payment_intent(self, amount, currency, metadata):
return self.client.PaymentIntent.create(
amount=amount,
currency=currency,
metadata=metadata
)
def process_webhook(self, payload, signature):
event = stripe.Webhook.construct_event(
payload, signature, self.webhook_secret
)
return self.handle_event(event)
| Endpoint | View | Purpose |
|---|
POST /payments/initiate | InitiatePaymentView | Start payment |
POST /payments/webhook/{gateway} | WebhookView | Gateway callbacks |
GET /payments/status/{id} | StatusView | Check status |
POST /payments/refund | RefundView | Process refund |
| Gateway | Region | Features |
|---|
| Stripe | Global | Cards, Apple/Google Pay |
| Razorpay | India | UPI, Cards, Netbanking |
| PhonePe | India | UPI |
| Paytabs | MENA | Cards |
| Square | US | POS, Cards |
| Pesopay | Philippines | Cards |
- Create directory:
payments/clients/{gateway}/
- Add files:
payments/clients/gateway/
├── __init__.py
├── client.py # API client
└── views.py # Webhook handler
- Register in URL routing
- Add gateway to
PaymentGatewayKeys
- Store credentials encrypted
- Validate webhook signatures
- Idempotent transaction handling