Checking Availability via the Yoplanning API

Endpoint: /api/v3.1/teams/[teamId]/order-validation

This API method allows you to check if the contents of the cart are still available before finalizing the order. It is particularly useful to avoid overbooking situations in cases where many customers make reservations simultaneously.


Example of use with CURL

Endpoint:

/api/v3.1/teams/[teamId]/order-validation

Description :

You must send the same JSON used to place an order, the only difference being the URL.

Example :

curl -H "Content-Type: application/json" -X POST -d '{
    "external_reference" : "956",
    "items" : [{
        "session_group" : "53071a97-0c2d-4973-89f5-cafd10665b3b",
        "price" : {"amount" : 51.25},
        "client" : {
            "id" : "71ea849f-226c-4302-a433-528179634aa7",
            "first_name" : "John",
            "last_name" : "Doe",
            "email" : "john.doe@gmail.com"
        }
    }],
    "payments" : [{
        "amount" : 51.25,
        "client" : {
            "first_name" : "Framold",
            "last_name" : "Doe",
            "email" : "john.doe@gmail.com"
        }
    }]
}' https://yoplanning.pro/api/v3.1/teams/5a90332e-568f-4980-9859-88a984844a4d/order-validation -H 'Authorization: Token 4504c2cb0d87a93106d4de029f407c86149f2ada'

Response in case of availability:

{
    "success": true
}

Response in case of unavailability:

{
    "success": false, 
    "unavailable_items": {
        "group_ids": ["2265cac0-cba5-46eb-8095-b89f93e7473f"], 
        "dry_resource_ids": [], 
        "voucher_ids": [], 
        "resources": []
    }
}

Tips for use and best practices

  1. Check before each order finalization: Use this method before finalizing an order to ensure that all necessary resources are still available.

  2. Error management: In the event of unavailability, provide appropriate error management to inform the customer and offer alternatives.

  3. Automation: Integrate this verification into an automated process for real-time transactions, especially during periods of high activity.


Common errors and solutions

  1. Error 404 (Not Found):

    • Cause: Bad endpoint or incorrect teamId.

    • Solution: Check the URL and the teamId used.

  2. Error 401 (Unauthorized):

    • Cause: Authentication problem.

    • Solution: Check the authentication token and ensure that it is valid and active.

  3. Error 400 (Bad Request):

    • Cause: Incorrect JSON format or missing data.

    • Solution: Verify that the JSON sent is correctly formatted and that all necessary information is included.

Last updated