Skip to content

Price calculation with private key

You can use our price calculation, add extra options and then create a reservation from that price calculation. This tutorial walks you through each step.

You need a private or public API key. To create one, see Authentication.

For PHP we’ve built an SDK. You can download it from our Git repository: campingcare-php-sdk

For this tutorial you need the following API references:

The price calculation API calculates a price. On top of the basic night price, it can:

  • calculate the extra guest price
  • calculate the price of required options
  • calculate taxes (such as tourist tax)
  • calculate discounts

You can also request the options available for this exact calculation, and use them to add extra options to it. You only need this if you’re building a custom Booking Engine.

To add options to the calculation, use the calculation_id and the calculation_draft_id.

Both the price calculation and the add option method return a price_calculation object.

The required parameters for the price calculation are:

  • arrival
  • departure
  • accommodation_id: you can find the accommodation ID with the accommodations API.
  • persons / age_tables / birth_tables: choose which one to use.
    • persons: the number of persons, calculated using the default age table.
    • age_tables: use the age tables from your system for the calculation. You need the age table ID and the amount. We check whether the age tables are valid.
    • birth_tables: provide a birth date for each person. We convert the birth_tables to age_tables, and these are also returned in the price calculation result.

Optional parameters:

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

Price Calculation API reference

In this example we use age_tables for the price calculation.

Parameters

{
"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
}
]
}
{
"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 calculated for the extra guests
"total_taxes": 0, // the part of for example tourist tax which has 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.
"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 has to be paid for the calculation
"deposit": 640
}

The price calculation result includes an available_option_rows section, which lists the options available for that price calculation. Use the option IDs from this result in the add option method.

There are also some advanced options:

  • Depending on the number of persons: if the amount is set to -1, the number of persons is used as the amount. The amount is changed automatically in the options of the price calculation response.
  • Custom dropdown list: if the amount is set to -2, a custom dropdown can be shown. The dropdown values are in the option’s data field, with the possible amounts and texts you need to build the dropdown.
  • option_ids: you can add multiple option IDs. This helps if there are, for example, two available options for a dog: you can combine them in one call.
  • value: the value for the option IDs, for example 1 dog.

Price Calculation Add Option API reference

{
"option_ids": [1],
"value": 2
}
{
"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 calculated for the extra guests
"total_taxes": 0, // the part of for example tourist tax which has 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 has to be paid for the calculation
"deposit": 752
}

When you’ve finished updating the options, you can create the reservation. Use the calculation draft ID for this: the same calculation_draft_id you used to update the options.

No extra properties.

Create Reservation API reference

<?php
// from the script above call from script:
//$price_calculation = $campingcare->updatePriceCalculationOption($calculation_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" : [],
}
{
"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 preferred 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 discontinued 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 reference 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 at this stage as they will be calculated in the background process. To pay the deposit amount you can use the deposit from the price calculation object
"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 invoice 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": {
"......" : "....."
}
}