- There are two services involved.
- One for receiving the booking requests, which I call the
booking-service
app and, - One for processing the payment for a booking request, which I call the
payment-service
app. - If the user has enough money in his/her account, the
payment-service
will provide an approved or rejected status in the response. This response is sent back to thebooking-service
for approving or rejecting booking reservations.
./00-build
This script will run the unit tests and build the Docker images if the tests pass.
docker-compose up
This will run the Docker containers: mongodb
, payment-service
, booking-service
The payment-service
stores information regarding the user's account balance. This service is initialized with users
for testing which can be viewed by a PostMan or curl.
[
{
"id": "a675a759-54dd-44d1-9fd1-76bd916a4239",
"email": "[email protected]",
"firstName": "Jolly",
"lastName": "Jae",
"balance": 7000.0
},
{
"id": "ba1923aa-2beb-4e2d-9b88-2700d3b0ddd2",
"email": "[email protected]",
"firstName": "Keerthi",
"lastName": "Lee",
"balance": 55.0
},
{
"id": "f5a66098-388a-4177-9670-6f4597e00388",
"email": "[email protected]",
"firstName": "Wella",
"lastName": "Sky",
"balance": 1200.0
},
{
"id": "5b5c416a-6369-41d5-afb0-81dc8a45f4df",
"email": "[email protected]",
"firstName": "Hinata",
"lastName": "Soyo",
"balance": 500.0
}
]
In addition, an /authorize_transaction
API for processing payment is also exposed.
Body:
{
"Email": "[email protected]",
"Transaction Number": "TR001",
"Amount": 45.0,
"First Name": "Keerthi",
"Last Name": "Lee"
}
Response:
{
"Transaction Number": "TR001",
"Email": "[email protected]",
"First Name": "Keerthi",
"Last Name": "Lee",
"Status": "APPROVED"
}
This response is sent back to the booking-service
for approving or rejecting booking reservations
The booking-service
receives the list of transactions. Each transaction is sent to the payment-service
to verify
if the user has enough credit to pay the transaction amount. A list of rejected transactions is returned
Body:
"Jolly,Jae,[email protected],9000,TR001",
"Wella,Sky,[email protected],50,TR002",
"Hinata,Shoyo,[email protected],1000,TR003"
Response:
{
"Rejected Transactions": [
{
"First Name": "Jolly",
"Last Name": "Jae",
"Email": "[email protected]",
"Transaction Number": "TR001"
},
{
"First Name": "Hinata",
"Last Name": "Shoyo",
"Email": "[email protected]",
"Transaction Number": "TR003"
}
]
}