Create
aClient
.Get
allAccounts
byClient id
.Create
aPayment
between twoAccounts
.Add
a group ofPayments
for processing between twoAccounts
.Get
a list ofPayments
by different input parameters.
- Download the source code
- Download and install Maven
- Download and install PostgreSQL
- Download and install any API testing tool. E.g PostMan
- Create database in
PostgreSQL
, keep yourusername
andpassword
- you would need it later. - Open your IDE and
create new project
from thesource code
. - In
src/main/resources/application.properties
uncomment the contents
of the file and changeusername
,password
anddatabase
url to your own credentials which you got after creating thedatabase
inPostgreSQL
. - Once you opened the project - run
PaymentSystemApplication.java
in order to start the application - Go to Postman and test the
endpoints
described below.
/accounts
Post
aClient
and return newClient
Id
andHttpStatus.CREATED
- Example -
{ "first_name": "First Name", "last_name": "Last Name", "accounts": [ { "account_number": "1234", "account_type": "CARD", "balance": 1000.0 } ] }
/accounts/{id}
Get
a list of allClient
Accounts
by givenId
- If
Client
is found in the database - application will return list ofAccounts
which belong to theClient
andHttpStatus.OK
. - If
Client
is not found application will returnHttpStatus.NOT_FOUND
.
/payments/one
Post
aPayment
with supplied input.- Example -
{ "source_acc_id": 1, "dest_acc_id": 2, "amount": 10.00, "reason": "Payment reason" }
. - If the
source Account
does not have enough balance -Payment
will be saved withstatus
ERROR
and returned by the application. - If the
source Account
balance is sufficient to perform the payment - thanPayment
will be saved and returned withstatus
OK
.
/payments/many
Post
a list ofPayments
with supplied input.- Example -
[{ "source_acc_id": 1, "dest_acc_id": 2, "amount": 10.00, "reason": "10 unit payment" }, { "source_acc_id": 1, "dest_acc_id": 2, "amount": 1000.00, "reason": "1000 unit payment" }]
- Same validation rules apply to this method,
payments are processed in order as they are received. In the
second
if thesource Account
does not have enough balance -Payment
will be saved with statusERROR
.
/payments/parameters
Get
a list of allPayments
which are performed betweenAccounts
or/andClients
parameters supplied.- Example
{ "payer_id": 1, "recipient_id": 2, "source_acc_id": 1, "dest_acc_id": 3 }
- Method will retrieve all
Payments
regardless of order of parameters or their amount and possible combinations. Simply put - the user will get allPayment
which include supplied parameters.