Skip to content

This is a sample project for payment system

Notifications You must be signed in to change notification settings

fsfj/PaymentSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PaymentSystem

This is a sample project for payment system

  • I use JWTAuthentication for the authentication and to get the token.
  • I made a UseInMemoryDatabase to store the data.
  • I created CustomExceptionMiddleware class to perform try catch when running API so that i dont need to actually right try catch in every API.
  • I created an Encryptor class just to encrypt the authentication password when comparing to the database.
  • As for unit testing, I create xUnit test to test the API if its authorized\unauthorized and check the ouput of the Interface if the output is correct.

Tools Needed.

  1. get the repository here : https://github.com/errolian22/PaymentSystem.git
  2. open the repository in visual studio 2019
  3. run the project.

I made a UseInMemoryDatabase to store the data.
The sample username and password is

User 1
username : usertest1
password : password1

User 2
username : usertest2
password : password2

To test the api it should be in postman, I created a basic authentication with JWTAuthentication to return a token.

  • To authenticate paste the link https://localhost/api/account/authenticate (the localhost is base on your workstation)

  • Set the HTTP verbs to POST, then add the Headers

    • Key : Content-Type
    • Value : application/json
  • Then go to Body then input { "username": "usertest1", "password":"password1"} or { "username": "usertest2", "password":"password2" } depends on what user you wanted to use.

  • Then click Send button, in the response there should be a Token. copy the formatted text token.

  • Go to the https://localhost/api/payments/GetPayments set the HTTP verbs to GET then add the Headers
    Example.

    • Key : Authorization
    • Value : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6InVzZXJ0ZXN0MiIsIm5iZiI6MTYxMTc1NjgxOCwiZXhwIjoxNjExNzYwNDE4LCJpYXQiOjE2MTE3NTY4MTh9.h4NVUi4LuMLRrYAm2r7i-qynd0ypa5B9J6VqPcoessk
  • Then click Send there should be a JSON output in the body.

  • In terms of CI/CD, I connected it to the Azure DevOps and generate a pipeline and configure the pipeline as necessary. I also include testing in the pipeline so that we can verify that the code is stable. I included the YML file in solution.

  • check the azure pipline tag here : https://dev.azure.com/erroliantamayo/PaymentSystem/_apis/build/status/PaymentSystem-ASP.NET%20Core-CI?branchName=master

About

This is a sample project for payment system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages