This microservice is built as part of Scalable-Services-Assignment. It is built using Java Spring Boot & MongoDB.
-
Download & Install Java by following steps here
-
Download & Install MongoDB by following steps here
-
Clone this project
-
Run
.\gradlew build
(only for 1st time) -
Run
.\gradlew bootRun
to run the application -
Application will now be running on
http://localhost:8082
-
You can interact with the available endpoints either using Postman or by visiting Swagger -
http://localhost:8082/swagger-ui/index.html
-
Get All Orders
- URL: /orders
- Method: GET
- Description: Retrieve a list of all orders.
- Responses:
- 200 OK: Successfully retrieved list of orders.
- 500 Internal Server Error: Error occurred while processing the request.
-
Place an Order
- URL: /orders
- Method: POST
- Description: Place a new order.
- Request Body:
{ "userId": "1", "price": 100, "orderItems": [ { "orderItemId": 1, "quantity": 4, "price": 25 } ], "paymentDetail": { "cardNumber": "123456789", "cardExpiry": "2024-10-12", "cvv": 123 } }
{ "userId": "1", "price": 100, "orderItems": [ { "orderItemId": 1, "quantity": 4, "price": 25 } ], "paymentDetail": { "upiNumber": "123456789" } }
- Responses:
- 201 Created: Order successfully placed.
- 500 Internal Server Error: Error occurred while processing the request.
-
Get All Orders
- User requests to get all orders.
- All orders are fetched from the database and returned to the user.
- If there is any error, an error message is returned.
-
Place an Order
- User places an order by providing the required details.
- Order Id is Generated
- Payment is processed by calling the PaymentService, which is another microservice.
- If no exceptions, order status is updated to 'PLACED' and success message is returned.
- if payment fails or there is any other failure, order status is updated to 'FAILED_TO_PROCESS' and failure message is returned.
- Order is saved in - ( Database Orders / Collection order_details )
- Inventory is updated by sending the order information onto InventoryService's Kafka Topic
inventory-input-topic
. - Notification about either Order Success or Order Failure is sent to user, by calling NotificationService, which is another microservice.
When Payment is successful using card:
When Payment is successful using UPI:
When Payment Service is down:
When Payment fails due to insufficient parameters: