Skip to content

kamran-pervaiz/Checkout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Payment Gateway API

The Payment Gateway API provides merchant to process payment on customer. API accepts credit card data such as credit number, Cvv, expiry month and year. There are 4 endpoints

1. Authorize
2. Capture
3. Refund
4. Void

Assumptions

  • Only In-Memory data store has been used. For production purpose that can be replaced by using SQL Server. This can be achieved by updating connection string in appsettings.json. This is already setup in Startup.cs
  • Implemented minimum validation to avoid complexity
  • Authorization Edge case is implemented by using hard coded BlackListCard list
  • For Capture Edge Case seed method is used to save customer and transactionId bc97198e-7ff2-45d1-96b8-408781ffb878 will be used
  • For Refund Edge case seed method is used to save customer and transactionId e96e72cf-2cc3-4b8c-9dec-b056979dccaa will be used

Improvements

  • Authentication for Merchant can be added.
  • Validation can be improved e.g if Month/Year is expired and many more.

Dev - Dependencies

Tools

  • Visual Studio Code or 2019
  • Docker
  • Powershell

Libraries

Build using Powershell

Run the below command to build the solution locally;

Execute build.ps1 to compile application and package release artifacts. Outputs to /dist/ folder.

Below are some examples;

  • Full Build: PS> .\build.ps1
  • Debug Build: PS> .\build.ps1 -Config "Debug"
  • Skip Tests: PS> .\build.ps1 -SkipTests

The build script also outputs the code coverage result. The coverage report files can be found under dist\Coverage folder. After the build process is executed you can open the coverage report using dist\Coverage\index.html

running full build

Build using Docker

To Build, (re)create container image for service(s), run the below command:

docker-compose build

To start, and attach to container for service(s), run:

docker-compose up

Build using dotnet CLI

dotnet build PaymentGatewayAPI.sln
dotnet test PaymentGatewayAPI.sln

Run the Payment Gateway API using dotnet

Run below command;

cd "src\PaymentGatewayAPI\"
dotnet run WebApi.csproj

Sample payload for API

  • sample payload for POST /api/authorize/ API
{
    "cardNumber": "4000 0000 0000 0119",
    "expiryMonth":"03",
    "expiryYear":"2021",
    "Cvv": 123,
    "Amount": 10,
    "currency": "gbp"
}
  • sample payload for POST /api/capture/, POST /api/refund/ API
{
    "transactionId": "79bf18b4-63fb-4c6d-aa4b-380d15a41b56",
    "amount": 6
}
  • sample payload for POST /api/void/ API
{
    "transactionId": "79bf18b4-63fb-4c6d-aa4b-380d15a41b56"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published