Wiki

Clone wiki

API-2.0 / Price_estimation_for_booking

Method: POST

Path: /booking/estimate_price

Estimate price for booking and returns detailed description.

Request Schema:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Estimate Booking Price request",
    "type": "object",

    "oneOf": [{
        "properties": {
            "service_date": {
                "$ref": "#/definitions/service_date"
            },
            "location_id": {
                "$ref": "#/definitions/location_id"
            },
            "frequency_id": {
                "$ref": "#/definitions/frequency_id"
            },
            "services": {
                "$ref": "#/definitions/services"
            },
            "discount_code": {
                "$ref": "#/definitions/discount_code"
            },
            "tip": {
                "$ref": "#/definitions/tip"
            },
            "tip_recurring": {
                "$ref": "#/definitions/tip_recurring"
            },
            "price_adjustment": {
                "$ref": "#/definitions/price_adjustment"
            },
            "price_adjustment_recurring": {
                "$ref": "#/definitions/price_adjustment_recurring"
            },
            "final_price": {
                "$ref": "#/definitions/final_price"
            }
        },
        "required": ["service_date", "frequency_id", "services"],
        "additionalProperties": false
    }, {
        "properties": {
            "email": {
                "$ref": "#/definitions/email"
            },
            "booking_uuid": {
                "$ref": "#/definitions/booking_uuid"
            },
            "original_booking_id": {
                "$ref": "#/definitions/original_booking_id"
            },
            "service_date": {
                "$ref": "#/definitions/service_date"
            },
            "location_id": {
                "$ref": "#/definitions/location_id"
            },
            "frequency_id": {
                "$ref": "#/definitions/frequency_id"
            },
            "services": {
                "$ref": "#/definitions/services"
            },
            "discount_code": {
                "$ref": "#/definitions/discount_code"
            },
            "tip": {
                "$ref": "#/definitions/tip"
            },
            "tip_recurring": {
                "$ref": "#/definitions/tip_recurring"
            },
            "price_adjustment": {
                "$ref": "#/definitions/price_adjustment"
            },
            "price_adjustment_recurring": {
                "$ref": "#/definitions/price_adjustment_recurring"
            },
            "final_price": {
                "$ref": "#/definitions/final_price"
            }
        },
        "required": ["email", "service_date", "frequency_id", "services"],
        "additionalProperties": false
    }],

    "definitions": {
        "email": {
            "type": "string",
            "format": "email",
            "minLength": 1,
            "maxLength": 255
        },
        "service_date": {
            "type": "string",
            "pattern": "\\A\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\z"
        },
        "booking_uuid": {
            "type": ["string", "null"],
            "minLength": 1,
            "maxLength": 255
        },
        "location_id": {
            "type": ["integer", "null"]
        },
        "original_booking_id": {
            "type": ["integer", "null"]
        },
        "frequency_id": {
            "type": "integer",
            "minimum": 1
        },
        "services": {
            "type": "array",
            "items": {
                "title": "Service",
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "hourly": {
                        "type": ["object", "null"],
                        "properties": {
                            "quantity": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 100
                            },
                            "minutes": {
                                "type": "integer",
                                "minimum": 30,
                                "maximum": 1440,
                                "multipleOf": 30
                            }
                        },
                        "required": ["quantity", "minutes"]
                    },
                    "extras": {
                        "type": ["array", "null"],
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "integer",
                                    "minimum": 1
                                },
                                "quantity": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 10000
                                },
                                "recurring": {
                                    "type": ["boolean", "null"]
                                }
                            },
                            "required": ["id", "quantity"]
                        }
                    },
                    "pricing_parameters": {
                        "type": ["array", "null"],
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "integer",
                                    "minimum": 1
                                },
                                "quantity": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 250000
                                }
                            },
                            "required": ["id", "quantity"]
                        }
                    }
                },
                "required": ["id"]
            },
            "minItems": 1
        },
        "discount_code": {
            "type": ["string", "null"],
            "minLength": 1,
            "maxLength": 255
        },
        "tip": {
            "type": ["number", "null"],
            "minimum": 0,
            "maximum": 100000
        },
        "tip_recurring": {
            "type": ["boolean", "null"]
        },
        "price_adjustment": {
            "type": ["number", "null"],
            "minimum": -100000,
            "maximum": 100000
        },
        "price_adjustment_recurring": {
            "type": ["boolean", "null"]
        },
        "final_price": {
            "type": ["number", "null"],
            "minimum": 0,
            "maximum": 100000
        }
    }
}

Where:

  • frequency_id, service_date, services attributes are required, descrived in Create booking as non-logged-in
  • location_id, discount_code, tip, tip_required attributes are optional, described in Create booking as non-logged-in
  • email (optional) is customer's email address, has to be provided to correctly estimate price for personalised discount (gift card discount, discount by code or referral program discount/reward)
  • booking_uuid (optional, requires authentication) is unique booking's digest, has be provided to correctly estimate price for existing booking (i.e. in edit booking mode), cannot be provided in combination with original_booking_id
  • original_booking_id (optional, requires authentication) described in Create booking for customer, cannot be provided in combination with booking_uuid
  • price_adjustment (optional, requires authentication and staff user type) is price adjustment for booking, should never be provided in combination with final_price
  • price_adjustment_recurring (optional, requires authentication and staff user type) is price adjustment recurring preferences, affects calculation of next recurring price for booking (i.e. price adjustment applied or not to next recurring booking)
  • final_price (optional, requires authentication and staff user type) is booking final price, will be used to calculate price_adjustment needed to get requested booking final price, should never be used in combination with price_adjustment

Example of requests attributes

non-logged-in customer (to be used in combination with Create booking as non-logged-in):

  • required: service_date, frequency_id, services
  • optional: email (has to be provided to get personalized discount estimation), discount_code, tip, tip_recurring, location_id (if not provided, default location will be used)

logged-in customer (create booking, to be used in combination with Create booking for customer):

  • required: email, service_date, frequency_id, services
  • optional: discount_code, tip, tip_recurring, location_id (if not provided, default location will be used)

logged-in customer (create booking as "Book Again", to be used in combination with Create booking for customer):

  • required: email, service_date, frequency_id, services, original_booking_id
  • optional: discount_code, tip, tip_recurring, location_id (if not provided, default location will be used)

logged-in customer (update booking, to be used in combination with Update booking for customer):

  • required: booking_uuid, email, service_date, frequency_id, services
  • optional: discount_code, tip, tip_recurring, location_id (if not provided, default location will be used)

logged-in staff (create booking):

  • required: service_date, frequency_id, services
  • optional: email, discount_code, tip, tip_recurring, location_id (if not provided, default location will be used), price_adjustment (if not provided, considered to be 0), price_adjustment_recurring (if not provided, considered to be true), final_price (cannot be provided in combination with price_adjustment)

logged-in staff (create booking as "book again"):

  • required: email, service_date, frequency_id, services, original_booking_id
  • optional: discount_code, tip, tip_recurring, location_id (if not provided, default location will be used), price_adjustment (if not provided, considered to be 0), price_adjustment_recurring (if not provided, considered to be true), final_price (cannot be provided in combination with price_adjustment)

logged-in staff (update booking):

  • required: booking_uuid, email, service_date, frequency_id, services
  • optional: discount_code, tip, tip_recurring, location_id (if not provided, default location will be used), price_adjustment (if not provided, considered to be 0), price_adjustment_recurring (if not provided, considered to be true), final_price (cannot be provided in combination with price_adjustment)

Example request (minimum, as non-logged-in):

For production, replace https://acme-sandbox.l27.co with https://<your subdomain>.launch27.com

curl -H "Content-Type: application/json" \
     -X POST -k \
     -d '{"service_date": "2019-08-15T10:00:00", "frequency_id": 1, "services":[{"id":1}]}' \
      https://acme-sandbox.l27.co/latest/booking/estimate_price

Example request (minimum, as logged-in):

For production, replace https://acme-sandbox.l27.co with https://<your subdomain>.launch27.com

Replace BEARER_FROM_LOGIN with bearer from Login

curl -H "Content-Type: application/json" \
     -H 'Authorization: Bearer BEARER_FROM_LOGIN' \
     -X POST -k \
     -d '{"booking_uuid": "NcUHgV93Vkf7Jxgr8P6rvOi3DMLpYvc2", "email": "user@email.com", "service_date": "2019-08-15T10:00:00", "frequency_id": 1, "services":[{"id":1}]}' \
      https://acme-sandbox.l27.co/latest/booking/estimate_price

Example of response

{
 "services": 327.36,
 "extras": 647.27,
 "discount_amount": 0,
 "discount_message": "",
 "giftcard_amount": 0,
 "price_adjustment": 0,
 "tax": {
   "before_tax": 974.63,
   "tax_percent": 0.38,
   "tax_amount": 3.7,
   "after_tax":  978.33,
 },
 "tip": 10,
 "total": 988.33,
 "next_total": 975.49,
 "duration": 1455,
 "price_for_frequency": 974.63,
 "price_for_discount_by_code": 974.63,
 "price_recurring_for_frequency": 974.63
}

Where:

  • services is estimated total price of services and pricing parameters
  • extras is estimated total extras price
  • discount_amount is estimated total discount amount except discount because of gift card
  • discount_message if not empty, contains explanation why requested discount_code cannot be used for booking
  • giftcard_amount is estimated discount due to gift card
  • price_adjustment is requested (or calculated from requested final_price) price adjustment for booking
  • tax present only if account has sales tax feature "on" (see features -> booking -> sales_tax in Get settings) and defined sales tax for booking service date; has attributes:
    • before_tax is total price before tax (before_tax=revenue)
    • tax_percent is tax % applied to the booking
    • tax_amount is calculated tax amount
    • after_tax is total price after tax applied
  • tip is amount of tip
  • total is booking total amount
  • next_total is estimated next booking total amount, can be different from total amount because of discount(s), tax % and recurring preferences
  • duration is duration in minutes, present only if price estimated for new booking (i.e. booking_uuid not used) and account has duration feature (see features -> booking -> duration in Get settings)
  • price_for_frequency is amount to which frequency discount can be applicable
  • price_for_discount_by_code is amount to which discount by code applicable
  • price_recurring_for_frequency is estimated next recurring booking amount to which frequency discount applicable (can be different from price_for_frequency)

Response

  • 401 Unauthorized on login failure.
  • 403 Forbidden if customer has no access to booking.
  • 200 OK on success.

Updated