This assessment contains 2 main parts:
- Payment Gateway System Allow Merchants to create payments, submit payments and get payments list.
- Mocked Bank Payment Processor The moked Bank Payment Processor is simulating credit card payment to the bank.
- There is no cache mechanism for GetPayments & PaymentDetails methods. It would be nice to have MemoryCache, Distributed Cache etc.
- Repositories & Services could be separated (read/write repo and service) so that these are also connected to different Databases. For instance, queries could read from Db like nosql, and we can keep Sql to write our data.
- A queue or background processing jobs for future-payment api method to trigger payment for non-realtime use could be useful.
- Constants could be used instead of hard coded error messages.
Project and database have been developed with Entity Framework Code first approach, therefore, once you run the project, it will automatically create the Database & test api users.
If you prefer to run project from Linux container on Docker, run this code on the root directory folder of docker-compose file :
docker-compose up
Sql instance will be up from port number : 1433
Api port number : 5001 (localhost:5001/api)
If you prefer to run the project via Visual Studio without any Docker containers :
First, you should set your Sql connection string in Checkout.PaymentGateway.Api project appsettings.json :
"ConnectionStrings": {
"DefaultConnection": "Server=ms-sql-server, 1433;Initial Catalog=CheckoutPaymentGatewayDB;User ID=SA;Password=SqlPassword2021;"
},
To improve readbility Swagger UI has been integrated to project. All request could have been done through Swagger UI ( api/index.html )
To be authorized ;
- First you should make a request to the /api/authentication endpoint with your merchantID and apiKey.
- If your merchantID and apiKey are correct, api will return an encyrpted "secret" key.
- For all other api calls you should put this "Secret" key on the "Authorization" header.
Test Users :
{
"merchantID" = "HB123H7123G712",
"apiKey" = "314179fa-7de9-4c9d-8d52-fb6f62ab3815",
},
{
"merchantID": "HB123H7123G712",
"apiKey": "14ec3398-45aa-4149-82c7-d9c6fa594bcf"
},
{
"merchantID": "K12312N21M123",
"apiKey": "b93b78f9-fb2f-4a00-9c55-95bb4ae2fc6a"
},
{
"merchantID": "1231MN11H2781",
"apiKey": "352015a8-7553-40d1-8870-8f382a1256ae"
},
- .NET Core 3.1
- Entity Framework Core
- Mssql
- XUnit
- Docker
EntityFrameworkCore: It has been used as ORM framework.
Documentation: https://docs.microsoft.com/en-us/ef/core/
MediatR: It has been used for reduce dependencies between objects.
Documentation: https://github.com/jbogard/MediatR/wiki
System.IdentityModel.Tokens.Jwt(JWT): It has been used for authentication.
Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.tokens.jwt
FluentValidation: It has been used for validation of commands and queries.
Documentation: https://github.com/FluentValidation/FluentValidation
AutoMapper: It has been used for object-to-object mapping from entity to Dto or ViewModels.
Documentation: https://docs.automapper.org/en/stable/
Newtonsoft: It has been used for json convert from enum.
Documentation: https://www.newtonsoft.com/json/help/html/Introduction.htm
Swagger: It has been used for api documentation and structure.
Documentation: https://swagger.io/docs/
FluentValidation: It has been used for improve testing readability.
Documentation: https://fluentassertions.com/introduction**
xUnit: It has been used for unit tests.
Documentation: https://xunit.net/docs/getting-started/netcore/cmdline**
EntityFrameworkCore.InMemory: It has been used to create mock database.
Documentation: https://docs.microsoft.com/en-us/ef/core/providers/in-memory
Moq: It has been used to create mock objects.
Documentation: https://documentation.help/Moq/