Multi-provider payment processing microservice for the xshopai e-commerce platform
Getting Started β’ Documentation β’ API Reference β’ Contributing
The Payment Service handles payment transactions, refunds, and payment method management across multiple providers (Stripe, PayPal, Square). Built with a provider abstraction layer, it supports multi-currency operations, PCI compliance considerations, and idempotent payment processing with full audit trails.
|
|
|
|
- .NET 8 SDK
- SQL Server 2019+
- Docker & Docker Compose (optional)
- Dapr CLI (for production-like setup)
# Clone the repository
git clone https://github.com/xshopai/payment-service.git
cd payment-service
# Start SQL Server + service
docker-compose up -d
# Verify the service is healthy
curl http://localhost:8009/healthπ§ Without Dapr (Simple Setup)
# Restore dependencies
dotnet restore
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# Start SQL Server (Docker)
docker-compose -f docker-compose.db.yml up -d
# Apply migrations
dotnet ef database update --project PaymentService
# Run the service
dotnet run --project PaymentServiceπ See Local Development Guide for detailed instructions.
β‘ With Dapr (Production-like)
# Ensure Dapr is initialized
dapr init
# Start with Dapr sidecar
./run.sh # Linux/Mac
.\run.ps1 # Windows
# Or manually
dapr run \
--app-id payment-service \
--app-port 8009 \
--dapr-http-port 3500 \
--dapr-grpc-port 50001 \
--resources-path .dapr/components \
--config .dapr/config.yaml \
-- dotnet run --project PaymentServiceNote: All services now use the standard Dapr ports (3500 for HTTP, 50001 for gRPC).
| Document | Description |
|---|---|
| π Local Development | Step-by-step local setup and development workflows |
| π Technical Reference | Architecture, security, monitoring |
| βοΈ Azure Container Apps | Deploy to serverless containers with built-in Dapr |
API Documentation: Swagger UI available at /swagger endpoint.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/payments |
Process a payment |
GET |
/api/payments |
Get payments (filtered) |
GET |
/api/payments/{id} |
Get specific payment |
POST |
/api/payments/{id}/refund |
Process refund |
GET |
/api/payments/order/{orderId} |
Get payment by order |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/paymentmethods |
Save payment method |
GET |
/api/paymentmethods/customer/{customerId} |
Customer's methods |
DELETE |
/api/paymentmethods/{id} |
Delete payment method |
GET |
/api/paymentmethods/supported-methods |
Supported methods |
GET |
/api/paymentmethods/providers |
Available providers |
GET |
/api/paymentmethods/providers/{name}/status |
Provider status |
# Run all tests
dotnet test
# Build without tests
dotnet build
# Run with specific configuration
dotnet test --configuration Release
# Apply migration
dotnet ef database update --project PaymentService| Provider | Test Mode |
|---|---|
| Stripe | Test card: 4242424242424242 |
| PayPal | Sandbox environment |
| Square | Sandbox environment |
payment-service/
βββ π PaymentService/ # Main application project
β βββ π Controllers/ # REST API endpoints
β βββ π Services/ # Business logic + provider adapters
β βββ π Models/
β β βββ π Entities/ # Domain entities (Payment, Refund)
β β βββ π DTOs/ # Data transfer objects
β βββ π Data/ # EF Core context + migrations
β βββ π Configuration/ # Settings classes
β βββ π Program.cs # Application entry point
βββ π PaymentService.Tests/ # Unit tests
βββ π docs/ # Documentation
βββ π .dapr/ # Dapr configuration
β βββ π components/ # Pub/sub, state stores
β βββ π config.yaml # Dapr runtime configuration
βββ π docker-compose.yml # Full service stack
βββ π docker-compose.db.yml # SQL Server only
βββ π Dockerfile # Production container image
βββ π PaymentService.sln # Solution file
| Category | Technology |
|---|---|
| π£ Runtime | .NET 8 / C# 12 |
| π Framework | ASP.NET Core 8 |
| ποΈ Database | SQL Server 2022 with Entity Framework Core |
| π³ Providers | Stripe, PayPal, Square (pluggable) |
| π¨ Messaging | Dapr Pub/Sub (RabbitMQ backend) |
| π Authentication | JWT Bearer Tokens |
| π API Docs | Swagger / OpenAPI (Swashbuckle) |
| π§ͺ Testing | xUnit |
| π Observability | Structured logging + correlation IDs |
# π³ Docker Compose
docker-compose up -d # Start all services
docker-compose down # Stop all services
docker-compose -f docker-compose.db.yml up -d # SQL Server only
# π£ Local Development
dotnet run --project PaymentService # Run service
dotnet watch --project PaymentService # Hot reload
# β‘ Dapr Development
./run.sh # Linux/Mac
.\run.ps1 # Windows
# π§ͺ Testing
dotnet test # Run all tests
dotnet build # Build solution
# π Health Check
curl http://localhost:8009/health
curl http://localhost:8009/swaggerWe welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Write tests for your changes
- Run the test suite
dotnet test - Commit your changes
git commit -m 'feat: add amazing feature' - Push to your branch
git push origin feature/amazing-feature
- Open a Pull Request
Please ensure your PR:
- β Passes all existing tests
- β Includes tests for new functionality
- β Follows PCI compliance considerations
- β Updates documentation as needed
| Resource | Link |
|---|---|
| π Bug Reports | GitHub Issues |
| π Documentation | docs/ |
| π¬ Discussions | GitHub Discussions |
This project is part of the xshopai e-commerce platform. Licensed under the MIT License - see LICENSE for details.
Made with β€οΈ by the xshopai team