Multi-tenant payment processing microservice built with .NET 10. Handles payment gateways, transactions, and billing operations.
- π³ Multi-Gateway Support - ZarinPal, Stripe, PayPal integration ready
- π’ Multi-Tenant - Complete tenant isolation for payments
- π Transaction Management - Track and manage all transactions
- π Webhook Handling - Process payment provider callbacks
- π Audit Trail - Complete payment history logging
- π OAuth2 Authentication - Secure service-to-service auth
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Payment Service (:4005) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ββββββββββββββββββ ββββββββββββββββββ β
β β Application β β Domain β β
β β Services β β Entities β β
β βββββββββ¬βββββββββ βββββββββ¬βββββββββ β
β β β β
β βββββββββΌββββββββββββββββββββΌβββββββββ β
β β Infrastructure β β
β β βββββββββββ βββββββββββββββββββ β β
β β β Payment β β Database β β β
β β β Gateway β β Repository β β β
β β βββββββββββ βββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- .NET 10 SDK
- PostgreSQL 15+
- Docker & Docker Compose (optional)
# Clone repository
git clone https://github.com/minisource/payment.git
cd payment
# Copy environment file
cp .env.example .env
# Restore dependencies
dotnet restore
# Run migrations
dotnet ef database update --project Infrastructure
# Run the service
dotnet run --project payment# Build and run with Docker Compose
docker-compose -f docker-compose.dev.yml up --build
# Or use the scripts
./docker.sh up # Linux/Mac
docker.bat up # Windows| Variable | Description | Default |
|---|---|---|
PORT |
Service port | 4005 |
DATABASE_URL |
PostgreSQL connection | Required |
AUTH_SERVICE_URL |
Auth service URL | http://auth:9001 |
CLIENT_ID |
OAuth client ID | Required |
CLIENT_SECRET |
OAuth client secret | Required |
ZARINPAL_MERCHANT_ID |
ZarinPal merchant | Optional |
STRIPE_SECRET_KEY |
Stripe API key | Optional |
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/payments |
Create payment |
| GET | /api/v1/payments/{id} |
Get payment |
| GET | /api/v1/payments |
List payments |
| POST | /api/v1/payments/{id}/verify |
Verify payment |
| POST | /api/v1/payments/{id}/refund |
Refund payment |
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/webhooks/zarinpal |
ZarinPal callback |
| POST | /api/v1/webhooks/stripe |
Stripe webhook |
| Method | Path | Description |
|---|---|---|
| GET | /api/v1/admin/transactions |
List all transactions |
| GET | /api/v1/admin/stats |
Payment statistics |
payment/
βββ Application/
β βββ DTOs/ # Data transfer objects
β βββ Options/ # Configuration options
β βββ Services/ # Business logic
βββ Domain/
β βββ Entities/ # Domain entities
β βββ Enums/ # Enumerations
β βββ Interfaces/ # Contracts
βββ Infrastructure/
β βββ Data/ # EF Core context
β βββ Repositories/ # Data access
β βββ Services/ # External integrations
βββ payment/
β βββ Controllers/ # API controllers
β βββ Program.cs # Entry point
βββ docker-compose.yml
βββ docker-compose.dev.yml
βββ Dockerfile
1. Client creates payment request
β
βΌ
2. Payment service generates gateway URL
β
βΌ
3. User redirected to payment gateway
β
βΌ
4. Gateway processes payment
β
βΌ
5. Gateway calls webhook with result
β
βΌ
6. Payment service verifies and updates status
β
βΌ
7. Client receives confirmation
- Create gateway service in
Infrastructure/Services/ - Implement
IPaymentGatewayinterface - Register in dependency injection
- Add configuration options
# Build
dotnet build
# Test
dotnet test
# Publish
dotnet publish -c Release -o ./publish
# Docker build
docker build -t minisource/payment ..env.example- Template configuration.env- Local development (git ignored)
- ASP.NET Core 10 - Web framework
- Entity Framework Core - ORM
- Minisource.Common - Shared utilities
- Minisource.Sdk - Service clients
MIT