The Price API allows portal owners to perform price calculations.
The details of each API call can be found in the Leaps API section.
You communicate with the price calculator by sending request in JSON format to https://portal.ff.geodis.com/ (other Leaps systems use other URLs).
Before you can perform a price calculation you must first read a list of the package types, country names etc. that are available, and use the information in the price calculation.
Example
Example of how to retrieve information about countries, packagetypes etc.
<?php $json = array("portal" => "DKWWFCOPEN", "username" => "MYUSERNAME", "password" => "MYPASSWORD", "apikey" => "", // empty for now "commands" => array(array("command" => "GetCountriesAndLocations"), array("command" => "GetPackageTypes"), array("command" => "GetCurrencies"), array("command" => "GetUnits") ) ); $d = file_get_contents("https://portal.ff.geodis.com/api/endpoint.php?json=".json_encode($json)); $d = json_decode($d, true); if ($d['status'] != 1) exit('failed: '.$d['msg']); // check if countries were retrieved $r = $d['results'][0]; if ($r['status'] != 1) exit('GetCountriesAndLocations failed: '.$r['msg']); $fromcountries = $r['from_countries']; $tocountries = $r['to_countries']; // $fromcountries and $tocountries both hold a list of arrays, each array defines a country // $c = array('id' => 21, 'name' => 'Denmark', 'locations' => array(0 => '-- no location'', 1 => 'Copenhagen', 2 => 'Vejle')); // check if package types were retrieved $r = $d['results'][1]; if ($r['status'] != 1) exit('GetPackageTypes failed: '.$r['msg']); $packtypes = $r['packtypes']; // $packtypes is an array of package type names indexed by package type numbers, eg. 'Package' is 23, '20' generel purpose container' is 3 // check if currencies types were retrieved $r = $d['results'][2]; if ($r['status'] != 1) exit('GetCurrencies failed: '.$r['msg']); $currencies = $r['currencies']; // $currencies is an array of currencies, eg 'EUR','USD','DKK' etc // check if units were retrieved $r = $d['results'][3]; if ($r['status'] != 1) exit('GetUnits failed: '.$r['msg']); $weightunits = $r['units']['weight']; // either 'kg' or 'lb' $volumeunits = $r['units']['volume']; // either 'm3' or 'ft3' ?>
Example of how to perform a price calculation:
<?php $json = array("portal" => "DKWWFCOPEN", "username" => "MYUSERNAME", "password" => "MYPASSWORD", "apikey" => "", // empty for now "commands" => array(array("command" => "GetPriceCalculation", "from_country" => 23, "from_location" => 1, "to_country" => 23, "to_location" => 2, "pcs1" => 1, "packtype1" => 23, "weight1" => 100, "volume1" => 1,
"width1" => 50, // width/height/length is optional
"height1" => 50,
"length" => 10, ) ) ); $d = file_get_contents("https://portal.ff.geodis.com/api/endpoint.php?json=".json_encode($json)); $d = json_decode($d, true); if ($d['status'] != 1) exit('failed: '.$d['msg']); $c = $d['results'][0]; if ($c['status'] != 1) exit('GetPriceCalculation failed: '.$c['msg']); $sheets = $c['sheets']; // the result for each price sheet foreach ($sheets as $sheet) { // the result for a price sheet includes title,currency,total cost,addon,transittime,note and lines // each line describes a fee or other cost echo "\n"; echo "Title: ".$sheet['title']."\n"; echo "Currency: ".$sheet['currency']."\n"; echo "Total cost: ".$sheet['total_excl']."\n"; } ?>