* @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once(dirname(__FILE__).'/../../config/config.inc.php'); include_once(dirname(__FILE__).'/mondialrelay.php'); include_once(dirname(__FILE__).'/errorCode.php'); try{ if (!Tools::getValue('token')) die('{"error":"Security error"}'); if (sha1('mr'._COOKIE_KEY_.'Back') != Tools::getValue('token')) die('{"error":"Security error"}'); $webservice = MondialRelay::MR_URL.'webservice/Web_Services.asmx?WSDL'; $client = new SoapClient($webservice); $params = array(); $params['Enseigne'] = Tools::getValue('enseigne'); $params['Poids'] = ''; $params['Taille'] = ''; $params['CP'] = (Configuration::get('PS_SHOP_CODE')) ? Configuration::get('PS_SHOP_CODE') : '75000'; $params['Ville'] = ''; $id_country = (Configuration::get('PS_SHOP_COUNTRY_ID')) ? Configuration::get('PS_SHOP_COUNTRY_ID') : Configuration::get('PS_COUNTRY_DEFAULT'); $params['Pays'] = Country::getIsoById($id_country); $params['Action'] = ''; $concat = $params['Enseigne'].$params['Pays'].$params['Ville'].$params['CP'].$params['Poids'].Tools::getValue('key'); $params['Security'] = Tools::strtoupper(md5($concat)); $result_mr = $client->WSI2_RecherchePointRelais($params); if (($errorNumber = $result_mr->WSI2_RecherchePointRelaisResult->STAT) != 0) { echo '{"error":"'.str_replace('"', '', $statCode[$errorNumber]).'"}'; die(); } echo '{"success":1}'; } catch(Exception $e) { echo '{"error":"'.str_replace('"', '', $statCode[99]).'"}'; die(); }