コード例 #1
1
 protected function getMultipleProductsInfo()
 {
     $order_lines = field_get_items('commerce_order', $this->datasources["order"], 'commerce_line_items');
     $line_item_ids = array();
     foreach ($order_lines as $order_line) {
         $line_item_ids[] = $order_line['line_item_id'];
     }
     $line_items = commerce_line_item_load_multiple($line_item_ids);
     $product_ids = array();
     $cant_prod = array();
     foreach ($line_items as $line_item) {
         $tmp = field_get_items('commerce_line_item', $line_item, 'commerce_product');
         $cant_prod[$tmp[0]['product_id']] = round($line_item->quantity);
         $product_ids[] = $tmp[0]['product_id'];
     }
     $products = commerce_product_load_multiple($product_ids);
     $code = array();
     $description = array();
     $name = array();
     $sku = array();
     $total = array();
     $quantity = array();
     $unit = array();
     foreach ($products as $item) {
         $code[] = $this->getCategoryArray($item);
         if (!empty($item->description)) {
             $desc = $item->description;
         } else {
             $desc = $item->title;
         }
         $desc = strip_tags($desc);
         $desc = TodoPago\Sdk::sanitizeValue($desc);
         $desc = substr($desc, 0, 50);
         $description[] = $desc;
         $name[] = substr($item->title, 0, 250);
         $sku[] = substr(empty($item->sku) ? $item->product_id : $item->sku, 0, 250);
         $total[] = number_format(commerce_currency_amount_to_decimal($item->commerce_price[LANGUAGE_NONE][0]["amount"], $item->commerce_price[LANGUAGE_NONE][0]["currency_code"]) * $cant_prod[$item->product_id], 2, ".", "");
         $quantity[] = $cant_prod[$item->product_id];
         $unit[] = number_format(commerce_currency_amount_to_decimal($item->commerce_price[LANGUAGE_NONE][0]["amount"], $item->commerce_price[LANGUAGE_NONE][0]["currency_code"]), 2, ".", "");
     }
     $productsData = array('CSITPRODUCTCODE' => join("#", $code), 'CSITPRODUCTDESCRIPTION' => join("#", $description), 'CSITPRODUCTNAME' => join("#", $name), 'CSITPRODUCTSKU' => join("#", $sku), 'CSITTOTALAMOUNT' => join("#", $total), 'CSITQUANTITY' => join("#", $quantity), 'CSITUNITPRICE' => join("#", $unit));
     return $productsData;
 }
コード例 #2
0
ファイル: Connector.php プロジェクト: TodoPago/Plugin-Magento
 public function getConnector($modo = null)
 {
     require_once Mage::getBaseDir('lib') . '/metododepago2/vendor/autoload.php';
     $http_header = $this->getHeader($modo);
     $mode = $this->getModo($modo);
     $todopago_connector = new TodoPago\Sdk($http_header, $mode);
     $proxyhost = Mage::getStoreConfig('payment/modulodepago2/proxyhost');
     if (empty($proxyhost)) {
         $proxyhost = Mage::getStoreConfig('payment/todopago_servicio/proxyhost');
     }
     $proxyport = Mage::getStoreConfig('payment/modulodepago2/proxyport');
     if (empty($proxyport)) {
         $proxyport = Mage::getStoreConfig('payment/todopago_servicio/proxyport');
     }
     $proxypass = Mage::getStoreConfig('payment/modulodepago2/proxypassword');
     if (empty($proxypass)) {
         $proxypass = Mage::getStoreConfig('payment/todopago_servicio/proxypassword');
     }
     $proxyuser = Mage::getStoreConfig('payment/modulodepago2/proxyuser');
     if (empty($proxyuser)) {
         $proxyuser = Mage::getStoreConfig('payment/todopago_servicio/proxyuser');
     }
     if (!empty($proxyhost) && !empty($proxyport)) {
         $todopago_connector->setProxyParameters($proxyhost, $proxyport, $proxyuser, $proxypass);
     }
     return $todopago_connector;
 }
コード例 #3
0
function callGAA($order_id)
{
    $dataGAA = _recollect_data($order_id);
    if ($dataGAA) {
        $logger = $dataGAA['logger'];
        $connector = new TodoPago\Sdk($dataGAA['authorization'], $dataGAA['mode']);
        $logger->info("params GAA: " . json_encode($dataGAA['params']));
        $rta2 = $connector->getAuthorizeAnswer($dataGAA['params']);
        $logger->info("response GAA: " . json_encode($rta2));
        return array('rta' => $rta2, 'logger' => $logger, 'optionsGAA' => $dataGAA['params']);
    }
    return false;
}
コード例 #4
0
 protected function getMultipleProductsInfo()
 {
     $productos = $this->datasources["cart"]->getProducts();
     $code = array();
     $description = array();
     $name = array();
     $sku = array();
     $total = array();
     $quantity = array();
     $unit = array();
     foreach ($productos as $item) {
         $prodDescription = "";
         $code[] = $this->getCategoryArray($item['id_product']);
         //obtengo el string para CSITPRODUCTDESCRIPTION
         $prodDescription = TodoPago\Sdk::sanitizeValue($this->getProdDescription($item['id_product']));
         $prodDescription = trim($prodDescription);
         if ($prodDescription == null || $prodDescription == "") {
             if ($item['description_short'] == null || $item['description_short'] == "") {
                 $prodDescription = TodoPago\Sdk::sanitizeValue($item['name']);
                 $prodDescription = trim($prodDescription);
             } else {
                 $prodDescription = TodoPago\Sdk::sanitizeValue($item['description_short']);
                 $prodDescription = trim($prodDescription);
             }
         }
         if (empty($prodDescription)) {
             $prodDescription = "product";
         }
         $prodDescription = str_replace("#", "", $prodDescription);
         $prodDescription = strip_tags($prodDescription);
         $desc = $prodDescription;
         $desc = substr($desc, 0, 50);
         $description[] = $desc;
         $name[] = substr($item['name'], 0, 250);
         $sku[] = substr(empty($item['reference']) ? $item['id_product'] : $item['reference'], 0, 250);
         $total[] = number_format($item['total_wt'], 2, ".", "");
         $quantity[] = number_format($item['cart_quantity'], 0, ".", "");
         $unit[] = number_format($item['price_wt'], 2, ".", "");
     }
     $productsData = array('CSITPRODUCTCODE' => join("#", $code), 'CSITPRODUCTDESCRIPTION' => join("#", $description), 'CSITPRODUCTNAME' => join("#", $name), 'CSITPRODUCTSKU' => join("#", $sku), 'CSITTOTALAMOUNT' => join("#", $total), 'CSITQUANTITY' => join("#", $quantity), 'CSITUNITPRICE' => join("#", $unit));
     return $productsData;
 }
コード例 #5
0
ファイル: todopago.php プロジェクト: gustavoghioldi/deci_repo
 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;
 }
コード例 #6
0
chdir('../../../../');
require 'includes/application_top.php';
require_once DIR_FS_CATALOG . "/includes/modules/payment/todopagoplugin/includes/TodoPago/lib/Sdk.php";
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'])) {
コード例 #7
0
    echo $value;
    ?>
</option>    
<?php 
}
?>

</select>
</div>
<input  onclick="submitDataTodoPago()" type="submit" name="submit" value="Guardar Datos"/>
</div>
<div id="mediosdepago">
    <?php 
$authorizationHTTP = $row["authorization"] ? json_decode($row["authorization"], true) : array();
try {
    $connector = new TodoPago\Sdk($authorizationHTTP, $ambiente);
    //$connector->setProxyParameters('192.168.0.17', 8080); //CAMBIAR!!!!
    $paymentMethods = $connector->discoverPaymentMethods();
} catch (Exception $e) {
    error_log("Ha surgido un error al consultar los medios de pago: " . $e);
}
?>
    <div class="input-todopago">
    <label class="subtitulo-todopago">Medios de Pago</label><label class="subtitulo-todopago">Habilitado</label>
    </div>
    <?php 
if (empty($paymentMethods)) {
    ?>
        <p style="color:red; text-align:center;" class="input-todopago">Debe elegir un modo en la configuracion para ver los medios de pago disponibles.</p>
    <?php 
} else {
コード例 #8
0
 /**
  * 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 .= "&ensp;&ensp;Order Id   -   Amount   -  Date.<br>";
                     foreach ($value as $key => $refundsList) {
                         if (isset($refundsList["ID"])) {
                             $rta .= "&ensp;&ensp;" . $refundsList['ID'] . " - " . $refundsList['AMOUNT'] . " - " . $refundsList['DATETIME'] . "<br>";
                         } else {
                             foreach ($refundsList as $key => $value) {
                                 $rta .= "&ensp;&ensp;" . $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
 }
コード例 #9
0
 private function callGAA($authorizationHTTP, $mode, $optionsAnswer)
 {
     $connector = new TodoPago\Sdk($authorizationHTTP, $mode);
     $rta_second_step = $connector->getAuthorizeAnswer($optionsAnswer);
     $this->logger->info("response GAA: " . json_encode($rta_second_step));
     $query = $this->model_todopago_transaccion->recordSecondStep($this->order_id, $optionsAnswer, $rta_second_step);
     $this->logger->debug("query recordSecondStep(): " . $query);
     if (strlen($rta_second_step['Payload']['Answer']["BARCODE"]) > 0) {
         $this->showCoupon($rta_second_step);
     }
     if ($rta_second_step['StatusCode'] == -1) {
         $this->logger->debug('status code: ' . $rta_second_step['StatusCode']);
         $this->model_checkout_order->addOrderHistory($this->order_id, $this->config->get('todopago_order_status_id_aprov'), "TODO PAGO: " . $rta_second_step['StatusMessage']);
         $this->response->redirect($this->url->link('checkout/success'));
     } else {
         $this->logger->warn('fail: ' . $rta_second_step['StatusCode']);
         $this->model_checkout_order->addOrderHistory($this->order_id, $this->config->get('todopago_order_status_id_rech'), "TODO PAGO: " . $rta_second_step['StatusMessage']);
         $this->response->redirect($this->config->get('config_url') . "index.php?route=payment/todopago/url_error&Order=" . $this->order_id);
     }
 }
コード例 #10
0
 public function getField($datasources)
 {
     $return = "";
     try {
         $this->logger->debug('entró: ' . $datasources);
         $return = TodoPago\Sdk::sanitizeValue($datasources);
         $return = str_replace('#', '', $return);
         $this->logger->info("devolvio: " . $return);
     } catch (Exception $e) {
         $this->logger->error("No se pudo agregar el campo", $e);
     }
     return $return;
 }
コード例 #11
0
 /**
  * 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
 }
コード例 #12
0
ファイル: index.php プロジェクト: TodoPago/Plugin-WooCommerce
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;
}