Create User Order
Create Order data customer
Endpoint
Base URL
http://localhost:8080
Method and Endpoint
POST /api/users/current/order
Headers
Authorization: Bearer access_token
Responses
You will get example responses like this:
200 (success)
Response Body
{
"message": "Successfully Fetch the Order",
"result": {
"id": "60c72b2f9b1e8b3d4c8d2c6e",
"order_id": "ORD123456789",
"email": "customer@example.com",
"order_date": "2024-05-25T15:45:12.370Z",
"updated_at": "2024-05-30T10:20:30.370Z",
"total_price": 199.98,
"address_shipping": {
"street": "123 Elm Street",
"city": "San Francisco",
"state": "CA",
"postal_code": "94101",
"country": "USA"
},
"payment": {
"status": "Paid",
"transaction_id": "TX123456789",
"payment_method": "Credit Card"
},
"items": [
{
"product_id": "WH123456",
"product_name": "Wireless Headphones",
"product_image": [
"https://example.com/images/product1.jpg",
"https://example.com/images/product2.jpg"
],
"store_id": "ST123456",
"order_status": "Shipped",
"quantity": 1,
"price": 99.99
},
{
"product_id": "SW789012",
"product_name": "Smartwatch",
"product_image": [
"https://example.com/images/product3.jpg",
"https://example.com/images/product4.jpg"
],
"store_id": "ST123456",
"order_status": "Processing",
"quantity": 1,
"price": 99.99
}
]
}
}
400 (bad request)
Response Body
{
"error": "no items selected in the cart"
}
401 (unauthorized)
Response Body
{
"error": "Invalid authorization header"
}
401 (unauthorized - expire token)
Response Body
{
"error": "token is expired: token is expired by 2m19s"
}
500 (server error)
Response Body
{
"error": "Internal server error"
}
500 (server error - failed)
If query to database
get troble while get the user
data
Response Body
{
"error": "failed to find user"
}
500 (server error - failed)
If query to database
get troble while insert order
data
Response Body
{
"error": "failed to create an order"
}
500 (server error - failed)
If query to database
get troble while insert seller-order
data
Response Body
{
"error": "failed to create a seller order"
}