public function get_status() { $order_id = $_GET['order_id']; $this->load->model('todopago/transaccion_admin'); $transaction = $this->model_todopago_transaccion_admin; $this->logger->debug('todopago - step: ' . $transaction->getStep($order_id)); // if($transaction->getStep($order_id) == $transaction->getTransactionFinished()){ $authorizationHTTP = $this->get_authorizationHTTP(); $this->logger->debug("get_status():authorizationHTTP: " . json_encode($authorizationHTTP)); $mode = $this->get_mode(); try { $connector = new TodoPago\Sdk($authorizationHTTP, $mode); $optionsGS = array('MERCHANT' => $this->get_id_site(), 'OPERATIONID' => $order_id); $status = $connector->getStatus($optionsGS); $status_json = json_encode($status); $rta = ''; if (!empty($status['Operations'])) { foreach ($status['Operations'] as $key => $value) { if (!is_array($value)) { $rta .= "{$key}: {$value} \n"; } } } else { $rta = 'No se ecuentra la operación. Esto puede deberse a que la operación no se haya finalizado o a una configuración erronea.'; } } catch (Exception $e) { $this->logger->fatal("Ha surgido un error al consultar el estado de la orden: ", $e); $rta = 'ERROR AL CONSULTAR LA ORDEN'; } // } // else{ // $rta = "NO HAY INFORMACIÓN DE PAGO"; // } echo $rta; }
require_once DIR_FS_CATALOG . '/includes/modules/payment/todopagoplugin/includes/Logger/loggerFactory.php'; $orderId = $_REQUEST["order_id"]; $sql = "select * from todo_pago_configuracion"; $res = tep_db_query($sql); if ($row = tep_db_fetch_array($res)) { $modo = $row["ambiente"] . "_"; $logger = loggerFactory::createLogger(true, substr($modo, 0, 4), 0, $orderId); $logger->info("get Status"); $wsdl = json_decode($row[$modo . "wsdl"], 1); $http_header = json_decode($row["authorization"], 1); $http_header["user_agent"] = 'PHPSoapClient'; define('END_POINT', $row[$modo . "endpoint"]); $connector = new TodoPago\Sdk($http_header, substr($modo, 0, 4)); $optionsGS = array('MERCHANT' => $row[$modo . "merchant"], 'OPERATIONID' => $orderId); $logger->info("params getStatus: " . json_encode($optionsGS)); $status = $connector->getStatus($optionsGS); $rta = ''; $refunds = $status['Operations']['REFUNDS']; $refounds = $status['Operations']['refounds']; $auxArray = array("refound" => $refounds, "REFUND" => $refunds); if ($refunds != null) { $aux = 'REFUND'; $auxColection = 'REFUNDS'; } else { $aux = 'refound'; $auxColection = 'refounds'; } if (isset($status['Operations']) && is_array($status['Operations'])) { foreach ($status['Operations'] as $key => $value) { if (is_array($value) && $key == $auxColection) { $rta .= " {$key}: \n";
/** * Se ejecuta cuando se quiere acceder a la orden desde el backoffice * @param $params un array con los siguientes objetos: order, products y customer */ public function hookDisplayAdminOrderContentOrder($params) { $order_id = $params['order']->id_cart; if (!TPTransaccion::existe($order_id)) { return; } $prefijo = $this->getPrefijoModo(); $mode = $this->getModo() ? "prod" : "test"; $connector = new TodoPago\Sdk($this->getAuthorization(), $mode); $opciones = array('MERCHANT' => Configuration::get($prefijo . '_ID_SITE'), 'OPERATIONID' => $order_id); $status = $connector->getStatus($opciones); $this->log->info('DisplayAdminOrderContentOrder - $status:' . json_encode($status)); $rta = ''; if (count($status) > 0) { foreach ($status['Operations'] as $key => $value) { $rta .= "{$key}: {$value} <br>"; } } else { $rta = "No hay datos para esta orden"; } $this->smarty->assign(array('status' => $rta)); return $this->display(__FILE__, 'views/templates/admin/order-content.tpl'); //indico la template a utilizar }
/** * Se ejecuta cuando se quiere acceder a la orden desde el backoffice * @param $params un array con los siguientes objetos: order, products y customer */ public function hookDisplayAdminOrderContentOrder($params) { $order_id = $params['order']->id_cart; if (!TPTransaccion::existe($order_id)) { return; } $prefijo = $this->getPrefijoModo(); $mode = $this->getModo() ? "prod" : "test"; $connector = new TodoPago\Sdk($this->getAuthorization(), $mode); $opciones = array('MERCHANT' => Configuration::get($prefijo . '_ID_SITE'), 'OPERATIONID' => $order_id); $this->log->info('DisplayAdminOrderContentOrder - GetStatus - Params:' . json_encode($opciones)); $status = $connector->getStatus($opciones); $this->log->info('DisplayAdminOrderContentOrder - GetStatus - Response:' . json_encode($status)); $rta = ''; //si hay un status para esta orden if (isset($status['Operations']) && is_array($status['Operations'])) { foreach ($status['Operations'] as $key => $value) { if ($key == "REFUNDS") { $rta .= $key . ": <br>"; if (is_array($value)) { $rta .= "  Order Id - Amount - Date.<br>"; foreach ($value as $key => $refundsList) { if (isset($refundsList["ID"])) { $rta .= "  " . $refundsList['ID'] . " - " . $refundsList['AMOUNT'] . " - " . $refundsList['DATETIME'] . "<br>"; } else { foreach ($refundsList as $key => $value) { $rta .= "  " . $value['ID'] . " - " . $value['AMOUNT'] . " - " . $value['DATETIME'] . "<br>"; } } } } else { $rta .= "No tiene devoluciones<br>"; } } else { if (is_array($value)) { $value = implode("-", $value); } $rta .= $key . ": " . $value . "<br>"; } } } else { $rta = "No hay datos para esta orden"; } //aca hago el codigo de la devolucion $id_order_cart = Tools::getValue('id_order'); $res = Db::getInstance()->executeS("SELECT total_products_wt, total_shipping, total_paid FROM " . _DB_PREFIX_ . "orders WHERE id_order=" . $id_order_cart); $this->smarty->assign(array('status' => $rta, 'precio' => number_format($res[0]['total_products_wt'], 2), 'envio' => number_format($res[0]['total_shipping'], 2), 'total' => number_format($res[0]['total_paid'], 2), 'url_base_ajax' => "//" . Tools::getHttpHost(false) . __PS_BASE_URI__, 'url_refund' => $this->context->link->getModuleLink('todopago', 'payment', array('paso' => '3'), true), 'order_id' => $id_order_cart)); return $this->display(__FILE__, 'views/templates/admin/order-content.tpl'); //indico la template a utilizar }
function getStatus() { global $wpdb; $row = $wpdb->get_row("SELECT option_value FROM wp_options WHERE option_name = 'woocommerce_todopago_settings'"); $arrayOptions = unserialize($row->option_value); $esProductivo = $arrayOptions['ambiente'] == "prod"; $http_header = $esProductivo ? $arrayOptions['http_header_prod'] : $arrayOptions['http_header_test']; $header_decoded = json_decode(html_entity_decode($http_header, TRUE)); $http_header = !empty($header_decoded) ? $header_decoded : array("authorization" => $http_header); $connector = new \TodoPago\Sdk($http_header, $arrayOptions['ambiente']); //opciones para el método getStatus $optionsGS = array('MERCHANT' => $_GET['merchant'], 'OPERATIONID' => $_GET['order_id']); $status = $connector->getStatus($optionsGS); $rta = ''; $refunds = $status['Operations']['REFUNDS']; $refounds = $status['Operations']['refounds']; $auxArray = array("refound" => $refounds, "REFUND" => $refunds); if ($refunds != null) { $aux = 'REFUND'; $auxColection = 'REFUNDS'; } else { $aux = 'refound'; $auxColection = 'refounds'; } if (isset($status['Operations']) && is_array($status['Operations'])) { foreach ($status['Operations'] as $key => $value) { if (is_array($value) && $key == $auxColection) { $rta .= "{$key}: \n"; foreach ($auxArray[$aux] as $key2 => $value2) { $rta .= $aux . " \n"; if (is_array($value2)) { foreach ($value2 as $key3 => $value3) { if (is_array($value3)) { foreach ($value3 as $key4 => $value4) { $rta .= " - {$key4}: {$value4} \n"; } } } } } } else { if (is_array($value)) { $rta .= "{$key}: \n"; } else { $rta .= "{$key}: {$value} \n"; } } } } else { $rta = 'No hay operaciones para esta orden.'; } echo $rta; exit; }