Skip to main content

Price calculation with private key

You can use the systems price calculation, add the additional options and create a reservation using the price calculation

Prerequisits: Creating the API key

You have to add a private or public API key.

For PHP we build a sdk. You can download our SDK from our Git Repository: here

API references

For this tutorial you will need the folowing API references:

Price Calculation API reference

Price Calculation Add Option API reference

Create Reservation API reference

Start a price calculation

With the price calculation API you can calculate a price. There are several options to add to the basic night price like:

  • calculate the extra guest price
  • calculate the required options price
  • calculate the tax prices (like tourist tax)
  • calculate the discount

You can also request the available options for this exact calculation. The available options can be used to add extra options to the calculations. This is parameter is only nescesarry if you are building a custom booking engine.

If you want to add the options to the calculation you have to use the calculation_id and the calculation_draft_id to add the options to the calculation.

Both methods, the price calculation and the add options method will return a price_calculation object.

Properties

The required parameters for the price calculation are the:

  • arrival

  • departure

  • accommodation_id (The accommoadtion id can be found using the accommodations api.)

  • persons / age_tables / birth_tables

persons: You can choose which parameter to use. It can depend on the parameter persons: The number of persons are calculated using the default age table.

age tables: You can use the systems age tables for the calculation. You need the age table id and amount to use this. The system will check if the age tables are valid

birth_tables You can also provide birthdays for each person. The system will convert the birth_tables to age_tables. These will also be returned in the price calculaton result.

Optional parameters:

  • get_guests_price
  • get_taxes_price
  • get_discounts_price
  • get_options
  • get_deposit
  • translations

API Reference

Price Calculation API reference

Example price calculation

For this example we use the age_tables as a refference for this price calculation.

Params


{
"accommodation_id": 12345,
"arrival": "2021-08-15",
"departure": "2021-08-15",
"get_guests_price": true,
"get_taxes_price": true,
"get_discounts_price": true,
"get_options": true,
"get_deposit" : true,
"age_tables" : [
{
"id" : 12345,
"count" : 2
},
{
"id" : 12346,
"count" : 0
}
]

}



Response


{
"arrival": "2021-08-01",
"departure": "2021-08-15",
"duration": 14,
"persons": 3,
"accommodation_id": 12345,
"calculation_id": 1,
"calculation_draft_id": "kyzr8m******2hhw2",
"total_price": 560, // the part which is calculated by for example pre season price, specific arrangement etc
"total_guests": 70, // the part which is calcutated fot the extra guests
"total_taxes": 0, // the part of for example tourist tax which have to be paid
"total_options": 0, // total of option prices (this will be used when options are added with the Add Option Method
"total_required_options": 10, // the required options which are in this calculation
"total_discounts": 0, // the discount on this price
"total": 640, // the total of the price, this is a sum of the parameters: total_price, total_guests, total_taxes, total_options, total_required_options and total_discounts
"rows": [

// this is the first row and always holds the accommodation
{
"id": null,
"row_id": null,
"type": "product_id", // this could hold different types like product_id, product_price, product_guest, product_tax, product_option
"type_id": 12345,
"description": "Bungalow",
"amount": 1,
"total": 0,
"data": [],
"translations": []
},
// this is the first price row, there can be multiple price rows as the system combines multiple prices. in the data field information about the period is available
{
"id": null,
"row_id": null,
"type": "rate",
"type_id": 1156,
"description": "Pre Season Night price",
"amount": 14,
"total": 560,
"data": {
"start_date": "2021-08-01",
"end_date": "2021-08-15",
"duration": 14
},
"translations": []
},
// In this case only 2 persons are included in the price. The extra guest price is calculated.
{
"id": null,
"row_id": null,
"type": "guest",
"type_id": 1806,
"description": "Extra gast",
"amount": 1,
"total": 70,
"data": {
"price_id": 1156,
"duration": 14,
"guest_price": 70
},
"translations": []
},
// In this case there is a required option calculated there is also data available in the data field for this option
{
"id": null,
"row_id": null,
"type": "option",
"type_id": 2011,
"description": "Reservation costs",
"amount": 1,
"total": 10,
"data": {
"pay_on_location": 0,
"apply_to_payment_terms": 0,
"discard_on_discounts": 0
},
"translations": []
}
],
"option_rows": [], // this will be used to store the chosen options when the Add Option method is used.
// in ths
"available_option_rows": [
{
"id": 84,
"option_type": "addon",
"accommodation_id": 10589,
"name": "Bedwash",
"type": "price",
"type_pro": "period",
"type_amount": 12.5,
"amount": 1,
"required": 0,
"data": [],
"translations": {}
}
],

// information about the age tables which are available
"age_tables": [
{
"id": 1,
"admin_id": 12345,
"status": "active",
"name": "Adults",
"age_from": 12,
"age_to": null,
"period": "years",
"rank": 0,
"priority": 1
},
{
"id": 2,
"admin_id": 12345,
"status": "active",
"name": "Children",
"age_from": 0,
"age_to": 10,
"period": "years",
"rank": 1,
"priority": 1
}
],
// the chosen age table information
"age_table_data": [
{
"id": 1,
"count": 3
},
{
"id": 2,
"count": 0
}
],
// the deposit which have to be paid for the calculation
"deposit": 640
}


Add an option

When the price calculation provides a result there is a section 'available_option_rows' which shows the available options for the price calculation.

The option id's which are comming from the price calculation result can be used in the add options method.

There are also some advanced options:

  • Depending on the number of persons.
  • Custom dropdown list.

Depending on the number of persons If the amount is set to -1 the number of persons will be used for the amount. The amount will automatically be changed in the price calculation response options

Custom dropdown list If the amount is set to -2 the a custom dropdown can be shown. The custom dropdown values are available in the options data field. The custom dropdown list has information about the possible amounts and texts. These can be used to build the custom dropdown list.

Properties

  • option_ids: You can add multiple option ids. This can help if there are for example 2 available options of a dog. You then can combine the options in one call.

  • value: The value provided for the option ids. For exaple 1 dog.

API Reference

Price Calculation Add Option API reference

Example add option to calculation



{
"option_ids": [1],
"value": 2
}


Response


{
"arrival": "2021-08-01",
"departure": "2021-08-15",
"duration": 14,
"persons": 3,
"accommodation_id": 12345,
"calculation_id": 1,
"calculation_draft_id": "kyzr8m******2hhw2",
"total_price": 560, // the part which is calculated by for example pre season price, specific arrangement etc
"total_guests": 70, // the part which is calcutated fot the extra guests
"total_taxes": 0, // the part of for example tourist tax which have to be paid
"total_options": 0, // total of option prices (this will be used when options are added with the Add Option Method
"total_required_options": 10, // the required options which are in this calculation
"total_discounts": 0, // the discount on this price
"total": 640, // the total of the price, this is a sum of the parameters: total_price, total_guests, total_taxes, total_options, total_required_options and total_discounts
"rows": [

// this will hold the exact same rows as the Price Calculation Method (See the Price Calculation Example above)
{
"......" : "....."
}
],
"option_rows": [
{
"id": null,
"row_id": null,
"type": "product_option",
"type_id": 1,
"description": "Dog",
"amount": 2,
"total": 112,
"data": {
"pay_on_location": 0,
"apply_to_payment_terms": 0,
"discard_on_discounts": 0
},
"translations": []
}
],
"available_option_rows": [
// this will hold the exact same rows as the Price Calculation Method (See the Price Calculation Example above)
{
"......" : "....."
}
],

// information about the age tables which are available
"age_tables": [
// this will hold the exact same rows as the Price Calculation Method (See the Price Calculation Example above)
{
"......" : "....."
}
],
// the chosen age table information
"age_table_data": [
// this will hold the exact same rows as the Price Calculation Method (See the Price Calculation Example above)
{
"......" : "....."
}
],
// the deposit which have to be paid for the calculation
"deposit": 752
}


Create a reservation

If you are finished updating the options you can create the reservation. You can create the reservation using the calculation draft id, this is the same number which we already used updating the options.

Properties

None

API Reference

Create Reservation API reference

Example creating a reservation


<?php

// from the script above call from script:
//$price_calculation = $campingcare->updatePriceCalculationOption($caclulation_draft_id, $args);



{

"accommodation_id" : 12345,
"calculation_draft_id" : "{calculation_draft_id from price calculation}"
"mainTraveler" : {
"gender": "male",
"first_name": "John",
"last_name": "Doe",
"address": "Canal Street",
"address_number": "1",
"zipcode": "1234AA",
"city": 'Amsterdam',
"phone" : '0031123456789',
"email" : "john@doe.com"

},
"language" : "nl",
"meta" : [],

}


Response


{
"id": 12345678, // the camping.care internal reservation id
"reservation_id": 1, // the reservation id which is used by the campsite
"admin_id": 12345,
"contact_id": 0, // at this point the contact id is not yet available, the reservation will be processed and will be searched if there is a contact available already. This will be checked on email address.
"accommodation_id": 12345, // The accommodation which is booked
"place_id": 0, // If there is a preffered place chosen by the guest the place id will be provided here, the place id will be added in a background process (as a new contact)
"channel_id": 1, // This is the channel id the booking is made from only if you are a OTA this will be another number than 1. Camping.care bookings will always be channel 1
"status": "pending", // New reservations will start in the status pending
"payment": "unpaid", // At the moment the reservation is unpaid
"arrival": "2021-08-01 12:00:00",
"departure": "2021-08-15 11:59:59",
"create_date": "2021-07-27 09:01:13",
"draft_id": "bbd***ue2r", // each reservation gets a draft id, this will be discountinued later
"total": 794, // the reservation total value
"meta": {
"age_table_input": "[{\"id\":1,\"count\":3},{\"id\":2,\"count\":0}]", // json encoded storage of the age_table
"persons": 3, // total number of persons booking
"source": null, // this can be provided by the api call but could be online, backend etc
"pay_method": "mollie", // the payment method which should be used by the initial payment
"language": "en", // the language which the booking is made in. If this is not added to the Create reservation parameters the default language is English
"hash": "hRFa1**************89Jo", // hash generated, this is used to open the guest view page. Only the reservation id with the valid hash can be used to open the guest view page
"normal_invoice_id": 1 // this is the default invoice (first invoice) which belongs to this reservation
},

// the reservation rows, these are the same as in the price calculation only with a id and row_id, the id is the internal id for this reservation row, the row_id is a refference to the reservation. The chosen option ids from the price calculation are also now merged into the reservation rows.
"rows": [
{
"id": 1,
"row_id": 12345678,
"type": "product_id",
"type_id": 12345,
"description": "Bungalow",
"amount": 1,
"total": 0,
"data": [],
"translations": []
},
{
"id": 2,
"row_id": 12345678,
"type": "product_price",
"type_id": 1,
"description": "Nacht",
"amount": 14,
"total": 40,
"data": {
"start_date": "2021-08-01",
"end_date": "2021-08-15",
"duration": 14
},
"translations": []
},
{
"id": 3,
"row_id": 12345678,
"type": "product_guest",
"type_id": 1,
"description": "Extra gast",
"amount": 1,
"total": 70,
"data": {
"price_id": 1156,
"duration": 14,
"guest_price": 70
},
"translations": []
},
{
"id": 4,
"row_id": 12345678,
"type": "product_option",
"type_id": 3,
"description": "Reservation costs",
"amount": 1,
"total": 10,
"data": {
"pay_on_location": 0,
"apply_to_payment_terms": 0,
"discard_on_discounts": 0
},
"translations": []
},
{
"id": 5,
"row_id": 12345678,
"type": "product_option",
"type_id": 1,
"description": "Dog",
"amount": 2,
"total": 56,
"data": {
"pay_on_location": 0,
"apply_to_payment_terms": 0,
"discard_on_discounts": 0
},
"translations": []
},
{
"id": 6,
"row_id": 12345678,
"type": "product_option",
"type_id": 2,
"description": "Extra Tent",
"amount": 1,
"total": 42,
"data": {
"pay_on_location": 0,
"apply_to_payment_terms": 0,
"discard_on_discounts": 0
},
"translations": []
}
],
"contact": {
"last_name": "Doe",
"gender": "",
"first_name": "John",
"zipcode": "1234AA",
"city": "Amsterdam",
"address_number": "1",
"country": "nl",
"email": "support@camping.care",
"birthday": "1983-02-08"
},
"payment_terms": [], // the payment terms are not available in this stadium as this will be caculated in the backgrond process. To pay the deposit amount you can use the deposit from the price calculation objec
"invoices": [
{ // the initial invoice is created, in the background process the reservation will be converted to the invoice.
"id": 485,
"invoice_id": null,
"contact_id": null,
"admin_id": null,
"reservation_id": "12345678",
"status": "unpaid",
"type": "concept",
"subtotal": null,
"vat": null,
"total": null,
"currency": null,
"create_date": null,
"contact_name": null,
"meta": {
"hash": "PvaWvnTO******Bl8zGdks" // secret hash to open the inovice guest page, only with the invoice id and this hash the guest view invoice page can be opened.
},
"rows": [],
"contact": null,
"payments": [],
"reservation": null
}
],
// the price calculation which is used to create this reservation
"price_calculation": {
"......" : "....."
}
}