Payment Gateway is written in ASP.NET Core 3.1. It was created as a coding assignment submission.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
At a minimum, you will need ASP.NET Core 3.1 and Postgres 9 to run the backend application. If you would like to use the API Client, you will need npm and Vue.js.
Download and install the following in order to run this project:
Project | Location |
---|---|
ASP.NET Core | https://dotnet.microsoft.com/download |
Postgres | https://www.postgresql.org |
npm | https://www.npmjs.com/get-npm |
Once Postgres is installed, you will have to create a database and a role in order for the Payment Gateway to function properly. If Postgres was installed with default settings (localhost, 5432), all you have to do is run the following commands:
CREATE DATABASE PaymentsGateway;
CREATE ROLE paymentsuser WITH PASSWORD 'paymentspass' SUPERUSER LOGIN;
The default database settings can be found in PaymentsGateway/appsettings.json
.
The test suite is located in the PaymentGatewayTests
folder. You can run the test suite by running the following command at the root of this project:
$ dotnet test
The test suite will execute, and the output will follow.
You can run either the backend by itself, and use a HTTP client (Postman, etc) to test the PaymentGateway APIs, or you can run the API Client in this repository to spin up a nice GUI to test the APIs.
Navigate to the PaymentGateway
folder and run:
$ dotnet build
$ dotnet run
The application will start and is accessible via https://localhost:5001
If you run the backend application, and receive a server certificate error, you will need to generate a certificate for localhost. Run these commands first, and then re-run the dotnet run
command:
$ dotnet dev-certs https --clean
$ dotnet dev-certs https -t
Navigate to api-client
and run the following commands:
$ npm install
$ npm run serve
The API Client will be accessible via http://localhost:8080
Payment Gateway supports two features: processing payments and retrieving payment details.
You can process a payment by submitting a POST
request:
POST /api/payments
The request structure should be:
{
"MerchantId": integer,
"Currency": string,
"Amount": double,
"Card" : {
"CardNumber": string,
"CardHolderName": string,
"ExpiryDate": string,
"CVV": integer
}
}
All fields are mandatory. This endpoint will return a HTTP 200
if the request was successful, along with a payment identifier and status, or a HTTP 400
if the request did not pass validation.
You can retrieve the details of a payment by submitting a GET
request:
GET /api/payments/[id]
Where [id]
is the payment identifier (returned by the POST
endpoint).
- Write more tests
- Add containerization
- Add authentication