Validate cart for a customer

POST cart/validate

Utilize this endpoint to obtain a detailed validation of the cart associated with a specific customer within your organization.

Header

                    
                        Authorization
                        Example: Bearer {YOUR_AUTH_KEY}
                        Content-Type
                        Example: application/json
                        Accept
                        Example: application/json
                    
                

Query Parameters

Parameter Datatype Description
customer_id Integer(required) The customer's unique identifier.

Response Parameters

Parameter Datatype Description
message string This message show you the cart is validate or not.

Sample Request

                    
                        curl --location --request POST 'https://testwebservices.sourcehub.in/api/carts/validate?customer_id=9' \
--header 'Authorization: Bearer ***********'
                    
                

Sample Success Response

                    
                        {
                            "message": "cart is validated."
                        }
                    
                

Sample 401 Faliure Response

                    
                        {
                            "error": {
                                "code": "AUTHENTICATION_ERROR",
                                "description": "Invalid credential or token.",
                                "source": "https://webservices.sourcehub.in/api/items.product",
                                "status_code": 401
                            }
                        }
                    
                

Sample 422 Faliure Response

                    
                        {
                            "error": {
                                "code": "VALIDATION_ERROR",
                                "description": "The customer id field is required.",
                                "source": "http://testwebservices.sourcehub.in/api/carts/add-item",
                                "status_code": 422
                            }
                        }
                    
                

Sample 201 Faliure Response

                    
                        {
                            "data": {
                                "unavailable_items_count": 1,
                                "unavailable_items": [
                                    {
                                        "id": 79532,
                                        "required_qty": 2,
                                        "available_qty": 1,
                                        "product": {
                                            "id": 4,
                                            "name": "3 Roses Mrp 10 (408pc)",
                                            "image": "https://sourcehub.in/public/images/product/1605342130.jpg",
                                            "sku": "CP 2425 0046",
                                            "hsn_code": "0902",
                                            "description": "",
                                            "price_per_unit": 10,
                                            "maximum_retail_price": 4080,
                                            "weight": 3000,
                                            "vol": 0,
                                            "gst_percent": 5,
                                            "measurementtype": {
                                                "id": 5,
                                                "name": "bags"
                                            },
                                            "productcategory": {
                                                "id": 3,
                                                "name": "Tea ,Coffee and Beverages",
                                                "image": "https://sourcehub.in/public/images/productcategory/1617180572.jpg"
                                            },
                                            "productpricing": {
                                                "id": 1058,
                                                "product_id": 4,
                                                "buying_qty": 1,
                                                "price": 200
                                            }
                                        }
                                    }
                                ],
                                "message": "1 item unavailable"
                            }
                        }
                    
                

Errors

1.The API key/secret provided is invalid. Error Status: 401

The API credentials passed in the API call differ from the ones generated on the Dashboard. Possible reasons are:

  • Different keys for test mode and live modes.
  • Expired API key.

Solution :
The API keys must be active and entered correctly with no whitespace before or after the keys.

2.VALIDATION_ERROR. Error Status: 422

Possible reasons are:

  • Maybe you didn't provide customer ID.
  • Maybe you Prodive incorrect customer ID.

Solution :
Provide a correct customer ID.

2.UNAVAILABLE. Error Status: 201

Possible reasons are:

  • Cart item required quantity is unavailable or low stock.

Solution :
Ordered available quantity or wait for availability.

CONTENTS