public function validationws()
 {
     require_once _PS_MODULE_DIR_ . 'payulatam/config.php';
     $conf = new ConfPayu();
     $keysPayu = $conf->keys();
     $currency_iso_code = '';
     if ($conf->isTest()) {
         $currency_iso_code = 'USD';
     } else {
         $currency_iso_code = $params[9]['currency'];
     }
     if (!isset($_POST['sign']) && !isset($_POST['signature'])) {
         Logger::AddLog('[Payulatam] the signature is missing.', 2, null, null, null, true);
     } else {
         $token = isset($_POST['sign']) ? $_POST['sign'] : $_POST['signature'];
     }
     if (!isset($_POST['reference_sale']) && !isset($_POST['referenceCode'])) {
         Logger::AddLog('[Payulatam] the reference is missing.', 2, null, null, null, true);
     } else {
         $ref = isset($_POST['reference_sale']) ? $_POST['reference_sale'] : $_POST['referenceCode'];
     }
     if (!isset($_POST['value']) && !isset($_POST['amount'])) {
         Logger::AddLog('[Payulatam] the amount is missing.', 2, null, null, null, true);
     } else {
         $amount = isset($_POST['value']) ? $_POST['value'] : $_POST['amount'];
     }
     if (!isset($_POST['merchant_id']) && !isset($_POST['merchantId'])) {
         Logger::AddLog('[Payulatam] the merchantId is missing.', 2, null, null, null, true);
     } else {
         $merchantId = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : $_POST['merchantId'];
     }
     if (!isset($_POST['lap_state']) && !isset($_POST['state_pol'])) {
         Logger::AddLog('[Payulatam] the lap_state is missing.', 2, null, null, null, true);
     } else {
         $statePol = isset($_POST['lap_state']) ? $_POST['lap_state'] : $_POST['state_pol'];
     }
     $idCart = explode('_', $ref)[2];
     $this->context->cart = new Cart((int) $idCart);
     $total_order = $this->context->cart->getOrderTotal();
     if (!$this->context->cart->OrderExists()) {
         Logger::AddLog('[Payulatam] The shopping card ' . (int) $idCart . ' doesn\'t have any order created', 2, null, null, null, true);
         return false;
     }
     if (Validate::isLoadedObject($this->context->cart)) {
         $id_orders = Db::getInstance()->ExecuteS('SELECT `id_order` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int) $this->context->cart->id . '');
         foreach ($id_orders as $val) {
             $order = new Order((int) $val['id_order']);
             if ($this->context->cart->getOrderTotal() != $amount) {
                 Logger::AddLog('[Payulatam] The shopping card ' . (int) $idCart . ' doesn\'t have the correct amount expected during payment validation.' . $keysPayu['apiKey'] . '~' . Tools::safeOutput($keysPayu['merchantId']) . '~payU_' . Configuration::get('PS_SHOP_NAME') . '_' . (int) $this->context->cart->id . '~' . number_format((double) $this->context->cart->getOrderTotal(), 2, '.', '') . '~' . $currency->iso_code . '~' . $statePol . "---" . $amount, 2, null, null, null, true);
             } else {
                 $currency = new Currency((int) $this->context->cart->id_currency);
                 if ($token == md5($keysPayu['apiKey'] . '~' . Tools::safeOutput($keysPayu['merchantId']) . '~payU_' . Configuration::get('PS_SHOP_NAME') . '_' . (int) $this->context->cart->id . '_' . $conf->get_intentos($this->context->cart->id) . '~' . number_format((double) $total_order, 2, '.', '') . '~' . $currency_iso_code . '~' . $statePol) || $token == md5($keysPayu['apiKey'] . '~' . Tools::safeOutput($keysPayu['merchantId']) . '~payU_' . Configuration::get('PS_SHOP_NAME') . '_' . (int) $this->context->cart->id . '_' . $conf->get_intentos($this->context->cart->id) . '~' . number_format((double) $total_order, 1, '.', '') . '~' . $currency_iso_code . '~' . $statePol) || $token == md5($keysPayu['apiKey'] . '~' . Tools::safeOutput($keysPayu['merchantId']) . '~payU_' . Configuration::get('PS_SHOP_NAME') . '_' . (int) $this->context->cart->id . '_' . $conf->get_intentos($this->context->cart->id) . '~' . number_format((double) $total_order, 0, '.', '') . '~' . $currency_iso_code . '~' . $statePol)) {
                     // CUANDO SE ENVIAN # ENTEROS EN EL PAGO A PAYU, ESTE RETORNA 1 DECIMAL, CUANDO SE ENVIAN DECIMALES, PAYU RETORNA 2 DECIMALES. SE VALIDA TAMBIEN SIN DECIMALES EVG GPB
                     if ($statePol == 7) {
                         if ($order->getCurrentState() != (int) Configuration::get('PAYU_WAITING_PAYMENT')) {
                             $order->setCurrentState((int) Configuration::get('PAYU_WAITING_PAYMENT'));
                         }
                     } else {
                         if ($statePol == 4) {
                             if ($order->getCurrentState() != (int) Configuration::get('PS_OS_PAYMENT')) {
                                 $order->setCurrentState((int) Configuration::get('PS_OS_PAYMENT'));
                             }
                         } else {
                             if ($order->getCurrentState() != (int) Configuration::get('PS_OS_ERROR')) {
                                 $order->setCurrentState((int) Configuration::get('PS_OS_ERROR'));
                             }
                             Logger::AddLog('[PayU] (payulatam) The shopping card ' . (int) $idCart . ' has been rejected by PayU state pol=' . (int) $statePol, 2, null, null, null, true);
                         }
                     }
                 } else {
                     Logger::AddLog('[PayU] The shopping card ' . (int) $idCart . ' has an incorrect token given from payU during payment validation.' . $keysPayu['apiKey'] . '~' . Tools::safeOutput($keysPayu['merchantId']) . '~payU_' . Configuration::get('PS_SHOP_NAME') . '_' . (int) $this->context->cart->id . '~' . number_format((double) $total_order, 2, '.', '') . '~' . $currency->iso_code . '~' . $statePol . "--" . number_format((double) $total_order, 1, '.', '') . "--" . $token, 2, null, null, null, true);
                 }
             }
             if (_PS_VERSION_ >= 1.5) {
                 $payment = $order->getOrderPaymentCollection();
                 if (isset($payment[0])) {
                     $payment[0]->transaction_id = pSQL("payU_" . md5(Configuration::get('PS_SHOP_NAME')) . "_" . $idCart);
                     $payment[0]->save();
                 }
             }
         }
     } else {
         Logger::AddLog('[PayU] The shopping card ' . (int) $idCart . ' was not found during the payment validation step', 2, null, null, null, true);
     }
 }