Cancellation conditions

In this section we will see how to manage data about the cancellation conditions of your properties.

Understanding the conditions

In the BookingBnb system, Cancellation conditions are not linked to Payment conditions and don't have any limits. This means that you are free to create your own conditions and apply them to each unit, during your preferred periods.

The following table shows you some examples to better understand how to create your custom conditions.

Condition description Restrictions String
Guests can cancel for free from the moment of booking till 30 days before the arrival date, then the host charges 100% of the accommodation price (any additional services are not included). d30,%100
Guests can cancel for free from the moment of booking till 60 days before the arrival date, then the host charges 50% of the accommodation price. If guests cancel within 7 days before the arrival date, the host charges the entire amount. d60,%50;d7,%100
The host charges 30% of the accommodation price at the moment of booking. Then, he charges 50% (so another 20%) within 30 days before the arrival date. If guests cancel within 14 days before the arrival date, the host charges the entire amount. da,%30;d30,%50;d14,%100

Get the conditions

URL: https://api.bookingbnb.com/xrws/GetCancellationConditions/

To get the cancellation conditions, use the following function:

GetCancellationConditions(user, password, token, propertyID)

The arguments user and password are the credentials that a partner uses to enter the BookingBnb Control Panel. The argument token is the one our partners acquire when they register to our system. The argument propertyID is the identification number of the current property. To retrieve this ID, use the BookingBnb function GetProperties.

Here is an example of how your code should be:


/** java /*	
public String GetCancellationConditions(String username, String password, String token, Int propertyID) throws Exception {
  Vector params = new Vector();
  params.addElement(username);
  params.addElement(password);
  params.addElement(token);
  params.addElement(propertyID);
  Object[] objects = (Object[]) xmlRpcClient.execute(config, "GetCancellationConditions", params);
  return (String) objects[1];
}

/* php */
<?php
include("xmlrpc.inc");
$server = new xmlrpc_client($url);
$args = array(
	new xmlrpcval($user, 'string'), 
	new xmlrpcval($pass, 'string'), 
	new xmlrpcval($token, 'string'), 
	new xmlrpcval($propertyID, 'int')
);
$message = new xmlrpcmsg('xrws.GetCancellationConditions', $args);
$result = $server->send($message);
$struct = $result->value();
?>

This function returns the list of conditions identified by a ID. The conditions are represented by a <tag>value</tag> structure. This is an example:


<condCancel>
  	<id>342</id>
  	<propertyID>23712</propertyID>
  	<label>Strict Policy</label>
  	<restrictions>da,%30;d14,%50;d3,%100</restrictions>
  </condCancel>
Please, note that each condition can have more restrictions and they are grouped under the same parameter restrictions.

Create new conditions

URL: https://api.bookingbnb.com/xrws/CreateCancellationConditions/

To create new conditions, use the following function:

CreateCancellationConditions(user, password, token, propertyID, conditions)

Here is an example of how your code should be:


/** java /*	
public String CreateCancellationConditions(String username, String password, String token, Int propertyID, String conditions) throws Exception {
  Vector params = new Vector();
  params.addElement(username);
  params.addElement(password);
  params.addElement(token);
  params.addElement(propertyID);
  params.addElement(conditions);
  Object[] objects = (Object[]) xmlRpcClient.execute(config, "CreateCancellationConditions", params);
  return (String) objects[1];
}

/* php */
<?php
include("xmlrpc.inc");
$server = new xmlrpc_client($url);
$args = array(
	new xmlrpcval($user, 'string'), 
	new xmlrpcval($pass, 'string'), 
	new xmlrpcval($token, 'string'), 
	new xmlrpcval($propertyID, 'int'),
	new xmlrpcval($conditions, 'string')
);
$message = new xmlrpcmsg('xrws.CreateCancellationConditions', $args);
$result = $server->send($message);
$struct = $result->value();
?>

How to correctly encode the conditions

Given a multi-dimensional array of conditions, that your system will produce, you must include the following parameters:

  • label is the name of the current cancellation condition
  • restrictions is the set of restrictions of the current cancellation condition


  $conditions[0][label]="30 Days";
  $conditions[0][restrictions]="d30,%100";
  $conditions[1][label]="60 Days";
  $conditions[1][restrictions]="d60,%100";
  $conditions[2][label]="Non-refundable";
  $conditions[2][restrictions]="not";

Your conditions string must look like this:


[condCancel]
	[label]30 Days[/label]
	[restrictions]d30,%100[/restrictions]
[/condCancel]
[condCancel]
	[label]60 Days[/label]
	[restrictions]d60,%100[/restrictions]
[/condCancel]
[condCancel]
	[label]Non-refundable[/label]
	[restrictions]not[/restrictions]
[/condCancel]

The function returns a status code, it can be ok or ko.

Update conditions

URL: https://api.bookingbnb.com/xrws/UpdateCancellationConditions/

To update conditions, use the following function:

UpdateCancellationConditions(user, password, token, propertyID, conditions)

Here is an example of how your code should be:


/** java /*	
public String UpdateCancellationConditions(String username, String password, String token, Int propertyID, String conditions) throws Exception {
  Vector params = new Vector();
  params.addElement(username);
  params.addElement(password);
  params.addElement(token);
  params.addElement(propertyID);
  params.addElement(conditions);
  Object[] objects = (Object[]) xmlRpcClient.execute(config, "UpdateCancellationConditions", params);
  return (String) objects[1];
}

/* php */
<?php
include("xmlrpc.inc");
$server = new xmlrpc_client($url);
$args = array(
	new xmlrpcval($user, 'string'), 
	new xmlrpcval($pass, 'string'), 
	new xmlrpcval($token, 'string'), 
	new xmlrpcval($propertyID, 'int'),
	new xmlrpcval($conditions, 'string')
);
$message = new xmlrpcmsg('xrws.UpdateCancellationConditions', $args);
$result = $server->send($message);
$struct = $result->value();
?>

How to correctly encode the conditions

Given a multi-dimensional array of conditions that your system can produce, you must include the following parameters:

  • id is the identifier of the current condition
  • newLabel is the new label of the current condition
  • newRestrictions is the new set of restrictions for the current condition

Here is an example of array in php:


  $conditions[0][id]=342;
  $conditions[0][newLabel]="40 Days";
  $conditions[0][newRestrictions]="d40,%100";
  $conditions[1][id]=343;
  $conditions[1][newLabel]="30% on Booking and 100% in 60 Days";
  $conditions[1][newRestrictions]="da,%30;d60,%100";

Your conditions string must look like this:


[condCancel]
	[id]342[/id]
  	[newLabel]40 Days[/newLabel]
  	[newRestrictions]d40,%100[/newRestrictions]
[/condCancel]
[condCancel]
  	[id]343[/id]
  	[newLabel]30% on Booking and 100% in 60 Days[/newLabel]
  	[newRestrictions]da,%30;d60,%100[/newRestrictions]
[/condCancel]

The function returns a status code, it can be ok or ko.