Exemplo n.º 1
0
 public function hookPaymentReturn($params)
 {
     global $cookie, $smarty;
     include dirname(__FILE__) . '/includes/Shop.php';
     // dados do cliente
     $customer = new Customer(intval($cookie->id_customer));
     $ArrayCliente = $customer->getFields();
     // dados do pedido
     $DadosOrder = new Order($params['objOrder']->id);
     $ArrayListaProdutos = $DadosOrder->getProducts();
     // gera descri�?o
     foreach ($ArrayListaProdutos as $info) {
         $item = array($zb[] = $info['product_name'] . ' * ' . $info['product_quantity']);
     }
     $descricao = implode(" + ", $zb);
     $currency = new Currency($DadosOrder->id_currency);
     $dados = array("external_reference" => $params['objOrder']->id, "currency" => $currency->iso_code, "title" => $descricao, "description" => $descricao, 'quantity' => 1, 'image' => '', 'amount' => $params['total_to_pay'], 'payment_firstname' => $ArrayCliente['firstname'], 'payment_lastname' => $ArrayCliente['lastname'], 'email' => $ArrayCliente['email'], 'pending' => Configuration::get('mercadopago_URLPROCESS'), 'approved' => Configuration::get('mercadopago_URLSUCCESFULL'));
     $client = Configuration::get('mercadopago_CLIENT_ID');
     $secret = Configuration::get('mercadopago_CLIENT_SECRET');
     $exclude = Configuration::get('mercadopago_METHODS');
     $pagamento = new MPShop($client, $secret);
     $botton = $pagamento->GetCheckout($dados, $exclude);
     $country = Configuration::get('mercadopago_COUNTRY');
     switch ($country) {
         case 'MLA':
             $banner = 'modules/mercadopago/imagens/mercadopagoar.jpg';
             break;
         case 'MLB':
             $banner = 'modules/mercadopago/imagens/mercadopagobr.jpg';
             break;
         case 'MLM':
             $banner = 'modules/mercadopago/imagens/mercadopagomx.jpg';
             break;
         case 'MLV':
             $banner = 'modules/mercadopago/imagens/mercadopagov.jpg';
             break;
         default:
             $banner = 'modules/mercadopago/imagens/mercadopagobr.jpg';
     }
     $smarty->assign(array('totalApagar' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false, false), 'status' => 'ok', 'seller_op_id' => $params['objOrder']->id, 'secure_key' => $params['objOrder']->secure_key, 'id_module' => $this->id, 'formmercadopago' => $botton, 'imgBnr' => $banner));
     return $this->display(__FILE__, 'payment_return.tpl');
 }
Exemplo n.º 2
0
 public function GetMethods($country_id = null)
 {
     $mp = new MPShop();
     $url = "https://api.mercadolibre.com/sites/" . $country_id . "/payment_methods";
     $header = array('Accept: application/json');
     $methods = $mp->DoPost(null, $url, $header, '200', 'none', 'get');
     return $methods;
 }
Exemplo n.º 3
0
 /**
  * Gets the default currency id for the asigned country
  */
 function get_default_currency($country_id = null)
 {
     $mp = new MPShop();
     $url = "https://api.mercadolibre.com/sites/" . $country_id;
     $header = array('Accept: application/json');
     $mp_site = $mp->DoPost(null, $url, $header, '200', 'none', 'get');
     return $mp_site["default_currency_id"];
 }
Exemplo n.º 4
0
<?php

include_once '../../../config/config.inc.php';
include_once 'Shop.php';
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
    $client_id = Db::getInstance()->getRow("SELECT value FROM " . _DB_PREFIX_ . "configuration WHERE name = 'mercadopago_CLIENT_ID'");
    $client_secret = Db::getInstance()->getRow("SELECT value FROM " . _DB_PREFIX_ . "configuration WHERE name = 'mercadopago_CLIENT_SECRET'");
    $checkdata = new MPShop($client_id['value'], $client_secret['value']);
    $dados = $checkdata->GetStatus($id);
    $order_id = $dados['collection']['external_reference'];
    $order_status = $dados["collection"]["status"];
    switch ($order_status) {
        case 'approved':
            $nomestatus = "mercadopago_STATUS_1";
            break;
        case 'pending':
            $nomestatus = "mercadopago_STATUS_0";
            break;
        case 'in_process':
            $nomestatus = "mercadopago_STATUS_0";
            break;
        case 'rejected':
            $nomestatus = "mercadopago_STATUS_2";
            break;
        case 'refunded':
            $nomestatus = "mercadopago_STATUS_2";
            break;
        case 'cancelled':
            $nomestatus = "mercadopago_STATUS_2";
            break;