Example #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!");
    }
}
Example #2
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);