This API allows you to manage transaction blocks for payment delivery to businesses, ensuring secure and fraud-free transactions.
payment_block.yaml
contains OpenAPI specs for payment blocking feature
database/schema.sql
contains script for database schema
Notice: it is just an OpenAPI specification made as an assignment
Acual service isn't developed yet
This API provides functionalities to:
- Block transactions for a particular client.
- Unlock transactions for a particular client.
- Check if a client is blocked.
- Distinguish fraudsters from ordinary clients.
Block transactions for a specific client due to suspicious activity.
Parameters:
clientId
(string, required): The ID of the client to block.
Responses:
200 OK
: Client transactions blocked successfully.400 Bad Request
: Invalid client ID.404 Not Found
: Client not found.
Unblock transactions for a specific client after verification.
Parameters:
clientId
(string, required): The ID of the client to unblock.
Responses:
200 OK
: Client transactions unblocked successfully.400 Bad Request
: Invalid client ID.404 Not Found
: Client not found.
Check the blocking status of a client.
Parameters:
clientId
(string, required): The ID of the client to check.
Responses:
200 OK
: Blocking status retrieved successfully.400 Bad Request
: Invalid client ID.404 Not Found
: Client not found.
Check if a client is flagged as a fraudster or an ordinary client.
Parameters:
clientId
(string, required): The ID of the client to check.
Responses:
200 OK
: Client type retrieved successfully.400 Bad Request
: Invalid client ID.404 Not Found
: Client not found.
type: object
properties:
clientId:
type: string
isBlocked:
type: boolean
reason:
type: string
clientType:
type: string
enum: [fraudster, ordinary]
Block a Client
curl -X POST "https://api.t-bank.com/v1/clients/client123/block"
Unblock a Client
curl -X POST "https://api.t-bank.com/v1/clients/client123/unblock"
Check if a Client is Blocked
curl -X GET "https://api.t-bank.com/v1/clients/client123/status"
Get Client Type
curl -X GET "https://api.t-bank.com/v1/clients/client123/type"
This schema supports the functionality required for blocking and unblocking transactions for clients based on various reasons. It consists of tables for managing clients, client types, transaction blocks, and blocking reasons.
Stores the types of clients.
Column | Type | Description |
---|---|---|
clientTypeId | INT | Primary key, auto-increment |
clientTypeName | VARCHAR(50) | Unique client type name |
Stores the reasons for blocking transactions.
Column | Type | Description |
---|---|---|
reasonId | INT | Primary key, auto-increment |
reasonDescription | VARCHAR(255) | Unique reason description |
Stores the client information.
Column | Type | Description |
---|---|---|
clientId | INT | Primary key, auto-increment |
clientTypeId | INT | Foreign key referencing ClientTypes |
Stores information about transaction blocks.
Column | Type | Description |
---|---|---|
blockId | INT | Primary key, auto-increment |
clientId | INT | Foreign key referencing Clients |
isBlocked | BOOLEAN | Indicates if the client is blocked |
reasonId | INT | Foreign key referencing BlockingReasons |
blockedAt | TIMESTAMP | Timestamp when the block was applied |
Clients.clientTypeId
→ClientTypes.clientTypeId
TransactionBlocks.clientId
→Clients.clientId
TransactionBlocks.reasonId
→BlockingReasons.reasonId
INSERT INTO transaction_blocking.TransactionBlocks (clientId, isBlocked, reasonId)
VALUES (1, TRUE, (SELECT reasonId FROM transaction_blocking.BlockingReasons WHERE reasonDescription = 'Fraudulent activity detected'));
UPDATE transaction_blocking.TransactionBlocks
SET isBlocked = FALSE
WHERE clientId = 1 AND isBlocked = TRUE;
SELECT isBlocked, (SELECT reasonDescription FROM transaction_blocking.BlockingReasons WHERE reasonId = tb.reasonId) AS reason, blockedAt
FROM transaction_blocking.TransactionBlocks tb
WHERE clientId = 1
ORDER BY blockedAt DESC
LIMIT 1;
SELECT (SELECT clientTypeName FROM transaction_blocking.ClientTypes WHERE clientTypeId = c.clientTypeId) AS clientType
FROM transaction_blocking.Clients c
WHERE clientId = 1;
Scenario 1: Transaction Blocked Due to Fraudulent Activity Transaction Attempt: Client with clientId = 1 attempts a transaction. Fraud Detection: System detects suspicious activity and flags it as potentially fraudulent.
INSERT INTO transaction_blocking.TransactionBlocks (clientId, isBlocked, reasonId)
VALUES (1, TRUE, (SELECT reasonId FROM transaction_blocking.BlockingReasons WHERE reasonDescription = 'Fraudulent activity detected'));
Scenario 2: Unblocking After Security Check Security Check: After a manual review, the client is cleared of fraudulent activity.
UPDATE transaction_blocking.TransactionBlocks
SET isBlocked = FALSE
WHERE clientId = 1 AND isBlocked = TRUE;
Scenario 3: Transaction Blocked Due to Invalid Credentials Transaction Attempt: Client with clientId = 2 attempts a transaction. Credential Check: Client provides invalid credentials, and the transaction is rejected by the bank.
INSERT INTO transaction_blocking.TransactionBlocks (clientId, isBlocked, reasonId)
VALUES (2, TRUE, (SELECT reasonId FROM transaction_blocking.BlockingReasons WHERE reasonDescription = 'Invalid credentials'));