Exemplo n.º 1
0
function TransactionNotification($notificationCode)
{
    ob_clean();
    global $cookie;
    $credentials = new PagSeguroAccountCredentials(Configuration::get("PAGSEGURO_BUSINESS"), Configuration::get("PAGSEGURO_TOKEN"));
    try {
        $transaction = PagSeguroNotificationService::checkTransaction($credentials, $notificationCode);
        $id_transaction = $transaction->getCode();
        $id_status = $transaction->getStatus()->getValue();
        $order_state = Configuration::get("PAGSEGURO_STATUS_{$id_status}");
        $orderState = new OrderState($order_state);
        $status = $orderState->name[$cookie->id_lang];
        $id_order = Db::getInstance()->getValue("SELECT id_order FROM " . _DB_PREFIX_ . "pagseguro_order WHERE id_transaction = '{$id_transaction}'");
        $order = new Order(intval($id_order));
        /** ENVIO DO EMAIL * */
        $pagseguro = new pagseguro();
        $idCustomer = $order->id_customer;
        $idLang = $order->id_lang;
        $customer = new Customer(intval($idCustomer));
        $mailVars = array('{email}' => Configuration::get('PS_SHOP_EMAIL'), '{firstname}' => stripslashes($customer->firstname), '{lastname}' => stripslashes($customer->lastname), '{terceiro}' => stripslashes($pagseguro->displayName), '{id_order}' => stripslashes($pagseguro->currentOrder), '{status}' => stripslashes($status));
        $pagseguro->enviar($mailVars, 'pagseguro', $status, $pagseguro->displayName, $idCustomer, $idLang, $customer->email, 'modules/pagseguro/mails/');
        /** /ENVIO DO EMAIL * */
        $extraVars = array();
        $history = new OrderHistory();
        $history->id_order = intval($id_order);
        $history->changeIdOrderState(intval($order_state), intval($id_order));
        $history->addWithemail(true, $extraVars);
        die("Sucesso!");
    } catch (PagSeguroServiceException $e) {
        file_put_contents(dirname(__FILE__) . "/error.log", var_export($e, true));
        die("Error!");
    }
}
Exemplo n.º 2
0
 public function index()
 {
     /* Página de Retorno */
     extract($_POST);
     $urlCallback = $this->urlCallback;
     /* Dados Compra */
     $items = array();
     $items[] = array('description' => 'Produto 1', 'amount' => '1400.00', 'quantity' => 1);
     $customerTest = pagseguro::getPurchaserTest();
     /* Dados Cliente */
     $customer = array();
     $customer['client_name'] = $customerTest['name'];
     $customer['client_email'] = $customerTest['email'];
     $customer['client_ddd'] = $customerTest['ddd'];
     $customer['client_phone'] = $customerTest['phone'];
     /* Dados Frete */
     $shipping = array();
     $shipping['frete'] = 3;
     $shipping['cep'] = '78280-000';
     $shipping['rua'] = 'Av. Getúlio Vargas';
     $shipping['numero'] = '123';
     $shipping['complemento'] = '';
     $shipping['bairro'] = 'Centro';
     $shipping['cidade'] = 'Cuiabá';
     $shipping['estado'] = 'Mato Grosso';
     $shipping['pais'] = 'Brasil';
     /* Referência (ID da Compra)*/
     $reference = 1;
     /* Gera URL da Pagamento */
     $paymentURL = $this->pagseguro->requestPayment($items, false, $reference, false, $urlCallback);
     //pre($paymentURL,1);
     /* Redireciona para o PagSeguro */
     if ($paymentURL) {
         redirect($paymentURL);
     }
 }
Exemplo n.º 3
0
        $oFrete = $frete->gerar($cep, $peso, $preco, $zipcode);
        if ($meio['Sedex'] == '0') {
            unset($oFrete['Sedex']);
        }
        if ($meio['PAC'] == '0') {
            unset($oFrete['PAC']);
        }
        return $oFrete;
    }
    public function converteValor($weight, $unit)
    {
        switch ($unit) {
            case "kilogram":
                $weight = $weight * 0.45359237;
                break;
            case "gram":
                $weight = $weight * 453.59237;
                break;
            case "once":
            case "ounces":
                $weight = $weight * 16;
                break;
            default:
                $weight = $weight;
                break;
        }
        return $weight;
    }
}
$pagseguro = new pagseguro();
$wpsc_shipping_modules[$pagseguro->getInternalName()] = $pagseguro;
Exemplo n.º 4
0
<?php

include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../header.php';
include dirname(__FILE__) . '/pagseguro.php';
$currency = new Currency(intval(isset($_POST['currency_payement']) ? $_POST['currency_payement'] : $cookie->id_currency));
//$transaction_id = $_GET['transaction_id'];
$total = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', ''));
$pagseguro = new pagseguro();
$mailVarsValidate = array('{bankwire_owner}' => $pagseguro->textshowemail, '{bankwire_details}' => '', '{bankwire_address}' => '');
$pagseguro->validateOrder($cart->id, Configuration::get('PAGSEGURO_STATUS_6'), $total, $pagseguro->displayName, NULL, $mailVarsValidate, $currency->id);
$order = new Order($pagseguro->currentOrder);
$idCustomer = $order->id_customer;
$idLang = $order->id_lang;
$customer = new Customer(intval($idCustomer));
$mailVars = array('{email}' => Configuration::get('PS_SHOP_EMAIL'), '{firstname}' => stripslashes($customer->firstname), '{lastname}' => stripslashes($customer->lastname), '{terceiro}' => stripslashes($pagseguro->displayName), '{id_order}' => stripslashes($pagseguro->currentOrder), '{status}' => stripslashes($pagseguro->getStatus(Configuration::get('PAGSEGURO_STATUS_6'))), '{link}' => $pagseguro->getUrlByMyOrder($order));
$assunto = $pagseguro->getStatus(Configuration::get('PAGSEGURO_STATUS_6'));
$pagseguro->enviar($mailVars, 'pagseguro_first', $assunto, $pagseguro->displayName, $idCustomer, $idLang, $customer->email, 'mails/');
//$urlRetorno = __PS_BASE_URI__.'order-confirmation.php?id_cart='.$cart->id.'&id_module='.$pagseguro->id.'&id_order='.$pagseguro->currentOrder.'&key='.$order->secure_key;
$urlRetorno = $pagseguro->getUrlByMyOrder($order);
$urlDePagamento = $pagseguro->inicializaPagamento($cart, $urlRetorno);
Tools::redirectLink($urlDePagamento);
//Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."pagseguro_order` VALUES (NULL, {$pagseguro->currentOrder}, '{$transaction_id}');");
//Tools::redirectLink(__PS_BASE_URI__.'order-confirmation.php?id_cart='.$cart->id.'&id_module='.$pagseguro->id.'&id_order='.$pagseguro->currentOrder.'&key='.$order->secure_key);
Exemplo n.º 5
0
<?php

/* SSL Management */
$useSSL = true;
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../header.php';
include dirname(__FILE__) . '/pagseguro.php';
if (!$cookie->isLogged(true)) {
    Tools::redirect('authentication.php?back=order.php');
} elseif (!Customer::getAddressesTotalById((int) $cookie->id_customer)) {
    Tools::redirect('address.php?back=order.php?step=1');
}
$pagseguro = new pagseguro();
echo $pagseguro->execPayment($cart);
include_once dirname(__FILE__) . '/../../footer.php';