online-billing-service.com
What are you invoicing today?

Api documentation

API (Application Programming Interface)
makes available resources of

You will find everything you need to integrate with your software.

1. Resources and URLs

online-billing-service.com API is a REST API, you can use HTTP to make appropriate calls.

API is accessible just through HTTPS.

The following calls are available for the models below:

LISTING https://online-billing-service.com/api/v1/[model-plural].xml (HTTP GET) DETAILS https://online-billing-service.com/api/v1/[model-plural]/[id].xml (HTTP GET) DELETE https://online-billing-service.com/api/v1/[model-plural]/[id].xml (HTTP DELETE) MODIFY https://online-billing-service.com/api/v1/[model-plural]/[id].xml (HTTP PUT) CREATE https://online-billing-service.com/api/v1/[model-plural].xml (HTTP POST)

Example using curl:

LISTING curl -i -u [api_key]:x https://online-billing-service.com/api/v1/clients.xml DETAILS curl -i -u [api_key]:x https://online-billing-service.com/api/v1/clients/1.xml DELETE curl -i -X DELETE -u [api_key]:x https://online-billing-service.com/api/v1/clients/1.xml MODIFY curl -i -X PUT -F "client[name]=MyCompany" -u [api_key]:x https://online-billing-service.com/api/v1/clients/1.xml CREATE curl -i -X POST -d "client[name]=MyCompany" -d "client[uid]=999999" -u [api_key]:x https://online-billing-service.com/api/v1/clients.xml

Example using php:

Listing invoices

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'invoices.xml';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>
  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'invoices.xml';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

Details of an invoice

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $invoice_id = 1065255495;  // your invoice id here
  $url = BASE_URL . 'invoices/' . $invoice_id . '.xml' ;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

Change invoice state

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $invoice_id = 1065255495;  // your invoice id here
  $url = BASE_URL . 'invoices/' . $invoice_id . '/mark_closed.xml' ;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([]));

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

Modify invoice

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $invoice_id = 1065255495;  // your invoice id here
  $changes = array("invoice" =>
    array(
      "lower_annotation" => 'New lower annotations',
      "upper_annotation" => 'New upper annotations',
      "note" => "New notes",
      "document_positions" => array (
        1 => array (
    'description' => 'potatoes',
    'unit' => 'kg',
    'unit_count' => '4',
    'input_currency_price' => '0.74',
    'vat' => 10
    ),
      2 => array (
    'description' => 'Brussels sprouts',
    'unit' => 'g',
    'unit_count' => '250',
    'input_currency_price' => '51',
    'vat' => 19
    )
      )
      )
      );
  $url = BASE_URL . 'invoices/' . $invoice_id . '.xml' ;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($changes));
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 200) {
    echo 'Updated successfully';
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }
?>

Modify client + invoice

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $client_id = 1064116484;  // your client id here
  $changes = array("client" => array("name" => 'Changed client name', "city" => "New city name"));
  $url = BASE_URL . 'clients/' . $client_id . '.xml' ;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($changes));
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);
  if ($httpCode == 200) {
    echo 'Client updated successfully<br/>';
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }


  $invoice_id = 1065255495;  // a invoice for the above client
  $changes = array("invoice" =>
    array(
      "update_client_data" => "1",
      "note" => "client data updated"
      )
    );
  $url = BASE_URL . 'invoices/' . $invoice_id . '.xml' ;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($changes));
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 200) {
    echo 'Invoice updated successfully';
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }
?>

Listing clients

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'clients.xml';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

Add client

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $attributes = array(
    "client" => array(
      "name" => 'My favorite company',
      "uid" => '3987985',
      "tax_id" => 1,
      "registration_id" => "J39/44/1990",
      "city" => "Client city name",
      "address" => "street name no. 221",
      "country_id" => "213"
      )
    );
  $url = BASE_URL . 'clients.xml';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($attributes));
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch); // returns the newly created client in xml format
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 201) {
      // transform the client data from xml to a array
          $client_data = json_decode(json_encode(simplexml_load_string($result)), TRUE);
    echo 'Client created successfully. Client id: ' . $client_data['id'];
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }
?>

Search client

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'clients/search.xml?field=uid&value=13548146';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

Details of a client

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $client_id = 1064116484;  // your client id here
  $url = BASE_URL . 'clients/' . $client_id . '.xml' ;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

Modify client

  <?php
    //set BASE_URL to https://online-billing-service.com/api/v1/ for production
    define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
    //replace with the api key provided in the backend
    define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

    $client_id = 1064116484;  // your client id here
    $changes = array("client" => array("name" => 'New client name', "city" => "New city name"));
    $url = BASE_URL . 'clients/' . $client_id . '.xml' ;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
    curl_setopt($ch, CURLOPT_URL, $url );
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($changes));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $result = curl_exec($ch);
    $header = curl_getinfo($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($httpCode == 200) {
        echo 'Updated successfully';
    } else {
                echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
    }
?>

Delete product

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $product_id = 741342701; // your product id here
  $url = BASE_URL . 'products/' . $product_id . '.xml' ;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 200) {
    echo 'Deleted successfully';
  } else {
    echo  '<pre> Error occured: ' . $httpCode . '</pre>';
  }
?>

Invoices, proformas, notices and receipts can be downloaded directly in PDF format, you have to specify in URL needed format:

DOWNLOAD PDF https://online-billing-service.com/api/v1/[model-plural]/[id].pdf (HTTP GET)

2. Testing API sandbox system

To test online-billing-service.com API we made a system sandbox.

3. Authentication

API key is defined by user and you can generate it from your online-billing-service.com account, at “User Profile“ -> “API Key“

There are available two methods of authentication:

  • HTTP Authentication (you will use API key as a username, password will be ignored)
  • Api key parameter added on each request.

4. Results and errors

Resources are returned in xml format. Result of a request has returning a HTTP status:

  • 200 Success (after a successful GET, PUT, or DELETE request)
  • 201 Created (after a successful POST request)
  • 400 Resource Invalid (wrong formatted request)
  • 401 Unauthorized
  • 404 Resource Not Found
  • 405 Method Not Allowed (HTTP verb used is not accepted for this resource)
  • 422 Unprocessable Entity (Request has a good syntax, but modifies requested are wrong)
  • 500 Application Error (System error)

For correct syntax calls, but which do not meet the system validation criteria, the errors will be returned in the response body as:

  <errors>
  <error>Error message</error>
  <error>Another error message</error>
  ...
</errors>

After adding a record, the URL at which the new record is available will be returned in the response header `Location '.

5. Fields and data types

All models contain the following fields:

  • id - unique identifier of the record
  • created_at - hour and date of record creation
  • updated_at - hour and date of record update

Fields marked with (R) are read-only; computed by our sistem using other data.

Data types:

  • Date format is AAAA-LL-ZZ
  • boolean values represented with true / false
  • using identifiers (id) numbers

6. Writing operations

Fields marked with * are mandatory

Models aggregate The aggregate models will be specified by identifier. Example: currency_id will be specified for the currency.

The data can be sent as xml or sent as the parameters in the HTTP request. In both cases, the model name will always be specified.

When using update operations (POST), it is only necessary to send the updated fields.

6.1. Writing examples

Modify client name (xml):

  curl -H 'Content-Type: application/xml'
  -X PUT https://online-billing-service.com/api/v1/clients/1.xml -u [api_key]:x \
  -d '<?xml version="1.0" encoding="UTF-8"?>
  <client>
    <name>Client Name</name>
    <uid>999999</uid>
  </client>'

Modify client name (application/x-www-form-urlencoded):

  curl -X PUT https://online-billing-service.com/api/v1/clients/1.xml -u [api_key]:x \
  -d 'client[name]=ClientName&client[uid]=999999'

Add product (xml):

  curl -H 'Content-Type: application/xml'
  -X POST https://online-billing-service.com/api/v1/products.xml -u [api_key]:x \
  -d '<?xml version="1.0" encoding="UTF-8"?>
  <product>
    <description>online-billing-service.com subscription</description>
    <price>12</price>
    <currency_id>1</currency_id>
  </product>'

After adding a record, the URL at which the new record is available is returned in the response header `Location ', and the entire record will be returned in the body

  HTTP/1.1 201 Created
...
Location: https://online-billing-service.com/api/v1/products/741342701
...

<?xml version="1.0" encoding="UTF-8"?>
<product>
  <code></code>
  <created_at type="datetime">2011-05-19T14:53:41+03:00</created_at>
  <description>online-billing-service.com standard subscription</description>
  <id type="integer">741342701</id>
  <price type="decimal">12.0</price>
  ...
</product>

7. Models

7.1. Invoice

Model name: Invoice

Invoice listing (php fragment):

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'invoices.xml';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

Can be downloaded directly in PDF format:

DOWNLOAD PDF https://online-billing-service.com/api/v1/invoices/[id].pdf (HTTP GET)

7.1.1. Issuer data

account_banks (R) Bank accounts of invoice issuer:

  <account_banks>
  <bank>
    <name>Bank Name</name>
    <bic>1000000</bic>
    <accounts>
      <account>
        <iban>GBKKBBBBSSSSSSCCCCCCCC</iban>
        <currency>EUR</currency>
      </account>
      ... more accounts ...
    </accounts>
  </bank>
  ... more banks ...
</account_banks>

account_xxx (R) - issuer data; look at account data ; on writing they are automatically taken from account data

branch_office_id - branch office identifier

branch_office_data (R) - branch office data (see branch offices )

7.1.2. Client data

client_id * (RW) - Client identifier

client_xxx (R) - all data of a client; (see clients ); on writing they are automatically taken from client

7.1.3. Invoice currency

currency_id * - currency displayed on invoice

input_currency_id - moneda în care se introduc sumele de pe factură - currency used to enter the amounts on invoices

exchange_rate - exchange rate, mandatory for documents with amounts entered in other currencies (ex: 4.6 on EUR / RON)

Documents online-billing-service.com can be issued in every currency. There are three cases:

  • Amounts entered and displayed in EUR
    • you will specify just currency_id
  • Amounts entered in a foreign currency and displayed in foreign currency and in EUR
    • you will specify just at currency_id being foreign currency
  • Amounts entered in a currency and displayed just in EUR
    • you will specify EUR currency_id and foreign currency as input_currency_id

7.1.4. Document data

total (R) - invoice total

total_due (R) - amount due

document_date * - document issued date

document_series_id * - numbering scheme used for this document

document_series_counter * - numbering scheme counter for this document (number)

vat_type * - VAT type applied:

  1. Without VAT
  2. VAT (standard)
  3. included VAT
  4. VAT exempt with deduction right
  5. VAT exempt without deduction right
  6. VAT reverse charge
  7. VAT not included in the tax base

due_days - days left until invoice becomes due

due_date (R) - due date (computed of due_days)

document_state - document state; possible values: “draft”, “open”, “closed”, “cancelled”

source_document_id - document from which the present document resulted from the copy or generation operation from another document

reversed_document_id - in the case of reversal invoices: the document (invoice) reversed

input_currency_reversing - in the case of reversing invoices: the amount that is reversed from the reversed invoice. Useful when an invoice includes both reversal and other positions

Example of creating a partial reversal invoice

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');
  /* adapt there variables to your needs*/
  $client_id = 1064116484;
  $currency_id = 5;
  $invoice_series_id = 1061104636; // series ID, not prefix !!!!!
  $document_series_counter = rand(1000,10000);
  $url = BASE_URL . 'invoices.xml';
  $ch = curl_init();
  $data = array("invoice" =>
    array(
      "client_id" => $client_id,
      "currency_id" => $currency_id,
      "document_date" => '2014-10-20',
      "document_series_id" => $invoice_series_id,
      "document_series_counter" => $document_series_counter,
      "vat_type" => 1,
      "delegate_id" => 525664463,
      "display_transport_data" => 1,
      "source_document_id" => 1065253810,
      "reversed_document_id" => 1065253810,
      'input_currency_reversing' => 100,
      "document_positions" => array (
        1 => array (
    'description' => 'Partial reversing of another invoice',
    'unit' => 'months',
    'unit_count' => '12',
    'price' => '-12',
    'product_code' => '66XXH663496H',
    'vat' => 19
    ),
      )
      )
    );


  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 201) {
          // transform the invoice data from xml to a array
    $invoice_data = json_decode(json_encode(simplexml_load_string($result)), TRUE);
    echo 'Invoice created successfully. Invoice id: ' . $invoice_data['id'];
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }
  ?>

7.1.5. Data about shipping

display_transport_data - includes data about shipping

delegate_id

delegate_cnp (R)

delegate_first_name (R)

delegate_identity_document (R)

delegate_identity_document_issue_date (R)

delegate_identity_document_issued_by (R)

delegate_identity_document_number (R)

delegate_identity_document_series (R)

delegate_last_name (R)

expedition_time - hour and date of shipping

7.1.6. Other fields

late_fees_cycle - the cycle of calculation of penalties; possible values: [d,m] daily/monthly

late_fees_percentage - the percentage of penalty applicable per cycle

locale - document language (ISO code), implicit ‘en’

hide_domestic_translations - does not include English translations for invoices in foreign languages

lower_annotation - lower annotations, observations etc.

upper_annotation - upper annotations, shown above document positions

delivery_date - Delivery date

advance_date - Date of advance payment

means_of_transport - means of transport

means_of_transport_number - registration information of the means of transport

notice_date - notice date

notice_number - notice number

user_id (R) - issued user identifier

hashcode (R) - code that can be used for read-only share of the document at the URL https://online-billing-service.com/view/%5Bhashcode%5D

note - Notes

account_company_pays_vat_on_payment - Pays VAT on payment

update_account_data - Take over the changes of your company in the invoice (if they have changed since the date of the invoice issue)

update_client_data - Take over the changes of the customer in the invoice (if they have changed since the date of the invoice issue)

update_user_data - Take over the changes of the user / issuer in the invoice (if they have changed since the date of issuing the invoice)

7.1.7. Flags

flag_downloaded_pdf - document was downloaded as PDF

flag_filed - document was recorded in the accounting

flag_sent_by_email - document was sent by email

flag_sent_by_fax - document was sent by fax

flag_sent_by_postal_mail - the document was sent by post

7.1.8. Invoice positions

The invoice will contain one or more invoiced items with the following fields:

description* - description of product/service

unit * - unit of measure

unit_count * - unit count

product_code - intern product code

vat - VAT value in percentage

position - position in document

input_currency_price** - unit price without VAT in the secondary currency

input_currency_total** - total price with VAT in the secondary currency

price** - unit price without VAT in the first currency

total** - total price with VAT in the first currency

** specify either unit price or total price for only one currency. Look at details about invoice currency.

Discount positions

discount_rate * - discount in percentage

type - specify value “DiscountPosition”

For discount positions, fields price, total, unit, unit_count are not specified!

Example:

  <document_position>
  <type>DiscountPosition</type>
  <description>Discount conform contract (20.0%)</description>
  <discount_rate>20.0</discount_rate>
</document_position>

7.1.9. Invoice state

The invoice states cannot be changed directly, but by request PUT at:

https://online-billing-service.com/api/v1/[model-plural]/[id]/mark_draft.xml - for state draft

https://online-billing-service.com/api/v1/[model-plural]/[id]/mark_open.xml - for state open

https://online-billing-service.com/api/v1/[model-plural]/[id]/mark_closed.xml - for state closed

https://online-billing-service.com/api/v1/[model-plural]/[id]/mark_cancelled.xml - for state cancelled

7.1.10. Send invoice through email

Send invoice through email is made by request PUT at URL, specify parameters: to, bcc, cc (you can specify only one parameter for bcc or cc with the list of emails, the email will be sent by the specified method), body:

https://online-billing-service.com/api/v1/[model-plural]/[id]/email.xml

Send invoice through email (php fragment):

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $invoice_id = 1065255495;  // your invoice id here
  $url = BASE_URL . 'invoices/' . $invoice_id . '/email.xml' ;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $body = "Dear client \n\nPlease pay the attached bill.\n\nThank you!\nTeam";
  $email_params = array('to'=>['[email protected]', '[email protected]'],
    'bcc'=>['[email protected]', '[email protected]'] // it can be your email
    'body'=> $body);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($email_params));
  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

7.1.11. Editing invoices example

Add invoice(xml)

  curl -i -H 'Content-Type: application/xml' \
  -X POST https://online-billing-service.com/api/v1/invoices.xml -u [api_key]:x \
  -d '<?xml version="1.0" encoding="UTF-8"?>
  <invoice>
    <client_id>100</client_id>
    <currency_id>200</currency_id>
    <document_date>2011-05-20</document_date>
    <document_series_id>300</document_series_id>
    <document_series_counter>10</document_series_counter>
    <vat_type>1</vat_type>
    <document_positions>
      <document_position>
        <description>BASIC SUBSCRIPTION</description>
        <unit>months</unit>
        <unit_count>12</unit_count>
        <price>12</price>
        <vat>24</vat>
      </document_position>
      <document_position>
        <type>DiscountPosition</type>
        <description>Discount for advanced payment</description>
        <discount_rate>10</discount_rate>
      </document_position>
    </document_positions>
  </invoice>'

Add invoice (php fragment):

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  /* adapt there variables to your needs*/
  $client_id = 1064116484;
  $currency_id = 5;
  $invoice_series_id = 1061104636; // Series ID - NOT PREFIX !!!!!
  $document_series_counter = rand(1000,10000);

  $url = BASE_URL . 'invoices.xml';
  $ch = curl_init();

  $data = array("invoice" =>
    array(
      "client_id" => $client_id,
      "currency_id" => $currency_id,
      "document_date" => '2014-05-20',
      "document_series_id" => $invoice_series_id,
      "document_series_counter" => $document_series_counter,
      "vat_type" => 1,
      "delegate_id" => 525664463,
      "display_transport_data" => 1,
      "document_positions" => array (
        1 => array (
    'description' => 'BASIC SUBSCRIPTION',
    'unit' => 'months',
    'unit_count' => '12',
    'price' => '12',
    'product_code' => '66XXH663496H',
    'vat' => 19
    ),
      2 => array (
    'type' => 'DiscountPosition',
    'description' => 'Discount for advanced payment',
    'discount_rate' => '12'
    )
      )
      )
      );


  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 201) {
          // transform the invoice data from xml to a array
    $invoice_data = json_decode(json_encode(simplexml_load_string($result)), TRUE);
    echo 'Invoice created successfully. Invoice id: ' . $invoice_data['id'];
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }

  ?>

  //alternative for XML-lovers:

  <?php
  //set BASE_URL to https://online-billing-service.com/api/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  /* adapt there variables to your needs*/
  $client_id = 1064116484;
  $currency_id = 5;
  $invoice_series_id = 1061104636; // Series ID - NOT PREFIX !!!!!
  $document_series_counter = rand(1000,10000);

  $url = BASE_URL . 'invoices.xml';
  $ch = curl_init();
  $postdata = '<?xml version="1.0" encoding="UTF-8"?>
    <invoice>
      <client_id>' . $client_id . '</client_id>
      <currency_id>' . $currency_id . '</currency_id>
      <document_date>2014-05-20</document_date>
      <document_series_id>' . $invoice_series_id . '</document_series_id>
      <document_series_counter>' . $document_series_counter . '</document_series_counter>
      <vat_type>1</vat_type>
      <delegate_id>525664463</delegate_id>
      <display_transport_data>1</display_transport_data>
      <document_positions>
        <document_position>
          <description>BASIC SUBSCRIPTION</description>
          <unit>months</unit>
          <unit_count>12</unit_count>
          <price>12</price>
          <product_code>66XXH663496H</product_code>
          <vat>24</vat>
        </document_position>
        <document_position>
          <type>DiscountPosition</type>
          <description>Discount for advanced payment</description>
          <discount_rate>10</discount_rate>
        </document_position>
      </document_positions>
    </invoice>';

  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));

  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 201) {
          // transform the invoice data from xml to a array
    $invoice_data = json_decode(json_encode(simplexml_load_string($result)), TRUE);
    echo 'Invoice created successfully. Invoice id: ' . $invoice_data['id'];
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }

  ?>

Modify invoice (xml)

  curl -i -H 'Content-Type: application/xml' \
  -X PUT https://online-billing-service.com/api/v1/invoices/1065253716.xml -u 123:x \
  -d '<?xml version="1.0" encoding="UTF-8"?>
  <invoice>
    <due_days>10</due_days>
  </invoice>'

Modify positions (xml) all positions should be specified, not just the updated ones.

  curl -i -H 'Content-Type: application/xml' \
  -X PUT https://online-billing-service.com/api/v1/invoices/100.xml -u [api_key]:x \
  -d '<?xml version="1.0" encoding="UTF-8"?>
  <invoice>
    <document_positions>
      <document_position>
        <description>STANDARD SUBSCRIPTION</description>
        <unit>months</unit>
        <unit_count>12</unit_count>
        <price>35</price>
        <vat>24</vat>
      </document_position>
      <document_position>
        <type>DiscountPosition</type>
        <description>Discount for advanced payment</description>
        <discount_rate>10</discount_rate>
      </document_position>
    </document_positions>
  </invoice>'

7.1.12. Search invoices

Accesible at link /api/v1/invoices/search.xml?field=[key]&value=[val] (HTTP GET).

Parameters meaning:

  • key: represents one of the fields: document_state client_id document_series_id document_date document_series_counter created_at updated_at vat_type cached_total
  • val: search keyword

Example of invoice search by creation date php code:

  <?php
  //set BASE_URL to https://online-billing-service.com/api/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'invoices/search.xml?field=created_at&value=2014.06.06';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

7.2. Proforma invoice

Model name: proforma_invoice

Can be downloaded directly in PDF format:

DOWNLOAD PDF https://online-billing-service.com/api/v1/proforma_invoices/[id].pdf (HTTP GET)

(look at invoice )

7.3. Notice

Model name: notice

Can be downloaded directly in PDF format:

DOWNLOAD PDF https://online-billing-service.com/api/v1/notices/[id].pdf (HTTP GET)

(look at invoice )

7.4. Receipt

Model name: receipt

Can be downloaded directly in PDF format:

DOWNLOAD PDF https://online-billing-service.com/api/v1/receipts/[id].pdf (HTTP GET)

look at invoice , and additional fields like:

receipt_amount* - amount receipt in EUR

amount (R) - the amount collected calculated in the currency of the related invoice;

  • ex: for 100 EUR received on a bill in EUR will return 100
  • ex: for 100 RON received for an invoice in EUR will return the amount in EUR (about 25)

invoice_id - identifier of the invoice for this receipt

invoice_date - date of the invoice for this receipt

invoice_number - invoice number for this receipt

Issuer data

user_cnp user_first_name user_id user_identity_document user_identity_document_issue_date user_identity_document_issued_by user_identity_document_number user_identity_document_series user_last_name

7.5. Payment

Model name: payment

amount * - payed amount

currency_id - currency identifier

currency (aggregate, R) - payment currency

payment_date * - payment date

description - description

invoice_id ** - invoice identifier

proforma_invoice_id ** - proforma invoice identifier

** At least on fields from: invoice_id and proforma_invoice_id

Add payment to an invoice (php fragment):

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $currency_id = 5;
  $invoice_id = 1065255495; // your invoice id here

  $attributes = array(
    "payment" => array(
      "amount" => '1001.11',
      "currency_id" => $currency_id,
      "payment_date" => '2015-02-20',
      "description" => 'by payment order - Bank',
      "invoice_id" => $invoice_id
      )
    );
  $url = BASE_URL . 'payments.xml';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($attributes));
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 201) {
    echo 'Created successfully';
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }
?>

7.5.1. Payment search

Link /api/v1/payments/search.xml?field=[key]&value=[val] (HTTP GET).

Parameters meaning:

  • key : represented by one of the following fields: payment_date proforma_invoice_id invoice_id description created_at updated_at
  • val: search keyword

PHP example for search payment by date:

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'payments/search.xml?field=payment_date&value=2014.06.06';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

7.6. Document numbering scheme

Model name: polymorphic, namely:

  • invoices, accessible at /api/v1/invoice_series
  • proformas, accessible at /api/v1/proforma_invoice_series
  • notices, accessible at /api/v1/notice_series
  • receipts, accessible at /api/v1/receipt_series

Fields:

  • counter_current - number of last generated document on this numbering scheme
  • prefix - prefix of generated numbers
  • suffix - suffix of generated numbers
  • sepparator - sepparator used on number generation
  • year - year of numbering scheme validity

Proforma invoices numbering scheme creation - php fragment:

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'proforma_invoice_series.xml';
  $ch = curl_init();
  $postdata_with_suffix = '<?xml version="1.0"?>
    <proforma_invoice_series>
      <counter_start>100</counter_start>
      <counter_current>100</counter_current>
      <prefix>PREFIXUSS</prefix>
      <sepparator>-</sepparator>
      <suffix>SUPREFIXUS</suffix>
      <year>2021</year>
    </proforma_invoice_series>';

  $postdata_without_suffix = '<?xml version="1.0"?>
    <proforma_invoice_series>
      <counter_start>100</counter_start>
      <counter_current>100</counter_current>
      <prefix>PREFIXUSS</prefix>
      <sepparator>-</sepparator>
      <year>2021</year>
    </proforma_invoice_series>';


  # a little bit of randomness :)
  $postdata = (mt_rand(0, 10) > 4) ? $postdata_without_suffix : $postdata_with_suffix;

  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
  $result = curl_exec($ch);
  $header = curl_getinfo($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode == 201) {
          // transform the invoice data from xml to a array
    $invoice_data = json_decode(json_encode(simplexml_load_string($result)), TRUE);
    echo 'Proforma Invoice Series created successfully. Series id: ' . $invoice_data['id'];
  } else {
    echo  '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>';
  }
  ?>

7.7. Client

Model name: client; allow writing (add, modify, delete). Look at writing instructions.

name * - Client name

is_company - Indicates whether the client is a company

Fiscal data

registration_id - registragion id

tax_id - VAT identifier

uid ** - fiscal identifier

Address

address * - client address

address_2 - client address 2

city * - city

zip - postal code

state - administrative action (state, land etc.)

country_id * - country identifier

country (aggregate, R) - country

Bank data

bank_iban - bank iban of client account

bank_name - bank name

Contact data

email fax homepage telephone

** Mandatory if client is company

7.7.1. Search clients

Link /api/v1/clients/search.xml?field=[key]&value=[val] (HTTP GET)

Parameters meaning:

  • key: represented by one of the fields: name uid email created_at updated_at
  • val: search keyword

PHP code example for searching client by UID:

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'clients/search.xml?field=uid&value=1X370113689';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

7.7.2. Client sheet

Link /api/v1/clients/[id]/sheet.xml.

Contains:

  • list of invoices with the corresponding payments
  • outstanding amounts broken down by currency
  • subscriptions (recurring invoices) to which this client has passed only subscriptions that are still active for this customer will be displayed

Example outstanding amounts:

  <dues>
  <due currency="EUR" amount="100"/>
  <due currency="RON" amount="200"/>
  ...
</dues>

Recurrent (recurring invoices)

All fields are read-only.

payment_start_at (R) - date from which the recurrent for this recurrent job began

payment_end_at (R) - date by which the recurrent is active

covered_until (R) - the date by which the invoices for this recurrent job were issued

schedule_unit (R) - the unit of a recurrent cycle (d - day, w - week, m - month, y - year)

schedule_unit_count (R) - the number of units of a cycle

price (R) - price pre cycle of recurrent

currency (R) - currency

recurrent_name (R) - recurrent name

Attention: The price is for an entire billing cycle. Thus, if the billing is done quarterly (schedule_unit = m and schedule_unit_count = 3) and the price is 100, then the price per month is 100/3 = 33

Example list of recurrents (recurring invoices):

  <recurrent_jobs>
  <recurrent_job schedule_unit_count="1" payment_end_at="" schedule_unit="m" price="1.19" payment_start_at="2011-01-01"
  recurrent_name="standard" currency="EUR" covered_until="" id="1"/>
  ...
</recurrent_jobs>

7.8. Product

Model name: product; allow writing (add, edit, delete). Look at writing instructions.

code - intern code used by a user for this product

description* - product description

quantity - quantity

unit - unit number

price - price

vat - VAT

currency_id * - currency identifier

currency (aggregate, R) - currency

7.8.1. Search products

At link /api/v1/products/search.xml?field=[key]&value=[val] (HTTP GET).

Parameters meaning:

  • key: represented by one of the fields: code description price created_at updated_at
  • val: search keyword

PHP code example for search product by price:

  <?php
  //set BASE_URL to https://online-billing-service.com/api/v1/ for production
  define('BASE_URL', 'https://sandbox.online-billing-service.com/api/v1/');
  //replace with the api key provided in the backend
  define('API_KEY', '91b4e03e6d4a07c088921a07ab8e844c7508092cf1645b32657d6c4b5829');

  $url = BASE_URL . 'products/search.xml?field=price&value=100';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x");
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  $result = curl_exec($ch);
  curl_close($ch);
  echo  '<pre>' . htmlentities($result) . '</pre>';
?>

7.9. Currency

Model name: currency

iso_name - ISO code of currency

7.10. Country

Model name: country

name - country name

iso - ISO code of country

7.11. Account data

Model name: account (singular!)

At link /api/v1/account.xml , just for reading.

name - account name

disabled - active / inactive

disabling_reason - disabling reason

total_open - total payment

total_overdue - total overdue

branch_offices - list of branch offices

company_vat_id - VAT code (for intra-Community operations)

company_euid - European Unique identifier (EUID)

Identical fields like a client :

company_name company_uid company_registration_id company_tax_id company_address_1 company_address_2 company_state company_city company_country_id company_zip company_web company_phone company_fax company_email

7.12. Branch office

Model name: branch_office

name address_1 address_2 state city zip phone fax

8. Callback when registering an online payment

After registering an online payment, a data structure with the details of the invoice and the payment is sent on it address via HTTP POST to the address specified in the Callback URL field of the online payment function parameter edit form.


PHP example code for processing HTTP POST request:

  <?php
  // write post parameters to file - sample code for processing the callback after successfull payment
  $file_name_json = 'online-billing-service.com_callback_post_content.json';
  $document_as_json = file_get_contents('php://input');

  $fp_json = fopen($file_name_json, 'wt') or die('Could not open file! Make sure you have permission to create the file ' . $file_name_json);
  fwrite($fp_json, $document_as_json) or die('Could not write to file! Make sure you have write permission for the file ' . $file_name_json);
  fclose($fp_json);
?>