A .NET payment API that chooses a provider, handles declines and avoids charging twice when a request is repeated. The providers are simulated and no real money moves.
.NET 10 · ASP.NET Core · EF Core · SQLite · xUnit
Run it · Try a payment · How it works
- A provider temporarily declines: try the next eligible provider.
- A provider gives a hard decline: stop.
- A provider stops answering: check what happened before attempting another charge.
- A completed request is sent again with the same key and payload: return its stored result.
Install the .NET 10 SDK, then:
git clone https://github.com/DeVFirmino/PayMaestro.git
cd PayMaestro
dotnet run --project src/PayMaestro.APIOpen Swagger. The default Development profile creates the local SQLite database and supplies the development configuration.
With the API running, paste this into another terminal:
curl -i http://localhost:5225/api/payments \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: 93747c29-68d8-4d3c-b0bb-0ddab07ac1e5' \
-d '{
"merchantReference": "ORDER-001",
"customerId": "customer-42",
"amount": 50,
"currency": "EUR",
"cardNumber": "4111111111111111",
"customerIp": "185.89.10.20"
}'On a fresh database with the default configuration, expect HTTP 200 and status Captured: AlphaPay declines this card temporarily, then BetaPay approves it.
Run the same command again. It returns the same payment without another charge. Keep the key but change the amount to 60, and the API returns 422 because the request no longer matches.
From the repository root:
dotnet testThe tests cover concurrent requests, provider failures, recovery after a restart and the HTTP contract. See the test scenarios.
This is a study project. It has no authentication, uses service-wide idempotency keys and requires an API call to trigger reconciliation or recovery. Refunds are not implemented.
