Provides functionality to save payment
The following is a sample JSON request:
{
"referenceNumber": <<reference number>>,
"bsb": <<bsb>>,
"accountNumber": <<account number>>,
"amount": <<amount>>
}
Status : 201 Created
{
"message": "success"
}
Error object representing error response sent to the API call
{
"code": <<error code>>,
"message": <<error message>>,
"timestamp": <<timestamp>>
}
400 Bad Request: Invalid BSB
{
"code": "102",
"message": "BSB number is invalid! ",
"timestamp": "2022-02-07T14:33:30.110527"
}
400 Bad Request: Invalid reference number
{
"code": "102",
"message": "Reference number format is invalid!",
"timestamp": "2022-02-07T14:39:07.894066"
}
400 Bad Request: Invalid account number
{
"code": "102",
"message": "Account number is invalid!",
"timestamp": "2022-02-07T14:39:40.086030"
}
400 Bad Request: amount < $00.01
{
"code": "102",
"message": "Amount value cannot be less than $0.01! ",
"timestamp": "2022-02-07T14:40:31.634341"
}
400 Bad Request: amount > $2000.00
{
"code": "102",
"message": "Amount cannot be more than $2000.00!",
"timestamp": "2022-02-07T14:41:11.862112"
}
403 Forbidden: accessing outside of allowed time
{
"code": "104",
"message": "Payments are only allowed between 09:00 and 17:00, Monday to Thursday, or between 08:00 and 18:00 on Fridays.",
"timestamp": "2022-02-07T14:44:46.298106"
}
500 Internal Server Error: any other exception
{
"code": "103",
"message": null,
"timestamp": "2022-02-07T15:12:29.841901"
}
- maven
- Java 11
Run the following command:
mvn clean install
Run the following command to start the application
mvn spring-boot:run
Using Postman and access the application using the url http://localhost:8080/payment.
Select the method as POST
Select body as raw and JSON
Following is a valid request:
{
"referenceNumber": "12345",
"bsb": 123457,
"accountNumber": 123456,
"amount": "1900.01"
}
๐ค Peppa Pig
- Github: @r-peppa-pig
This project is MIT licensed.