Anti-Fraud System. Stage 1/6

Simple transaction validation

Report a typo

Description

To begin with, let's define the concepts and find out what makes a good anti-fraud system. Consider the procedure of online payment (a transaction):

transaction

Frauds carry significant financial costs and risks for all stakeholders. So, the presence of an anti-fraud system is a necessity for any serious e-commerce platform.

Let's implement a simple anti-fraud system consisting of one rule — heuristics. In the beginning, there's one simple measure that prevents fraudsters from illegally transferring money from an account. Suppose some scammers acquired access to confidential financial information through phishing or pharming. They immediately try to transfer as much as possible. Most of the time, the account holder is not aware of the attack. The anti-fraud system should prevent it before it is too late.

In the first stage, you need to create a simple rest endpoint that calculates whether a transaction is ALLOWED, PROHIBITED, or requires MANUAL_PROCESSING by evaluating the amount of the transaction.

Objectives

  • Create and run a SpringBoot application on the 28852 port;

  • Create the POST /api/antifraud/transaction endpoint that accepts data in the JSON format:
{
  "amount": <Long>
}
  • Implement the following rules:
  1. Transactions with a sum of lower or equal to 200 are ALLOWED;
  2. Transactions with a sum of greater than 200 but lower or equal than 1500 require MANUAL_PROCESSING;
  3. Transactions with a sum of greater than 1500 are PROHIBITED.

    Transaction processing rules

  • The transaction amount must be greater than 0.
  • If the validation process was successful, the endpoint should respond with the status HTTP OK (200) and return the following JSON:
{
  "result": "<String>"
}
  • In case of wrong data in the request, the endpoint should respond with the status HTTP Bad Request (400).

Examples

Example 1: a POST request for /api/antifraud/transaction

Request body:

{
   "amount": 150
}

Response: 200 OK

Response body:

{
   "result": "ALLOWED"
}

Example 2: a POST request for /api/antifraud/transaction

Request body:

{
   "amount": 870
}

Response: 200 OK

Response body:

{
   "result": "MANUAL_PROCESSING"
}

Example 3: a POST request for /api/antifraud/transaction

Request body:

{
   "amount": 1700
}

Response: 200 OK

Response body:

{
   "result": "PROHIBITED"
}

Example 4: a POST request for /api/antifraud/transaction

Request body:

{
   "amount": -1
}

Response: 400 BAD REQUEST

Write a program
IDE integration
Checking the IDE status
___

Create a free account to access the full topic