/** * The first method to be called by the notification PagSeguro treatment. */ public function index($_POST) { $this->load(); $this->validatePost($_POST); $this->createArrayOrderStatus(); $this->createCredentials(); $this->createNotificationType(); if ($this->obj_notification_type->getValue() == $this->notification_type) { $this->createTransaction(); $this->updateCms(); } }
/** * The first method to be called by the notification PagSeguro treatment. */ public function index() { $this->_load(); $this->_addPagSeguroLibrary(); $this->_validatePost(); $this->_createArrayOrderStatus(); $this->_codeLanguage(); $this->_createCredentials(); $this->_createNotificationType(); if ($this->obj_notification_type->getValue() == $this->notification_type) { $this->_createTransaction(); $this->_updateCms(); } }
function onPaymentNotification(&$statuses) { // adding PagSeguro API require_once 'PagSeguroLibrary/PagSeguroLibrary.php'; // retrieving configurated default log info $filename = JPATH_BASE . '/logs/log_pagseguro.log'; $this->_verifyFile($filename); PagSeguroConfig::activeLog($filename); $order_id = (int) $_REQUEST['invoice']; $dbOrder = $this->getOrder($order_id); $this->loadPaymentParams($dbOrder); if (empty($this->payment_params)) { return false; } $post = $_POST; if (!PagSeguroHelper::isNotificationEmpty($post)) { $notificationType = new PagSeguroNotificationType($post['notificationType']); $strType = $notificationType->getTypeFromValue(); switch ($strType) { case 'TRANSACTION': $this->_doUpdateByNotification($statuses, $post['notificationCode']); break; default: LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]"); } } else { LogPagSeguro::error("Invalid notification parameters."); } return true; }
public static function main() { $code = isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ? trim($_POST['notificationCode']) : null; $type = isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ? trim($_POST['notificationType']) : null; if ($code && $type) { $notificationType = new PagSeguroNotificationType($type); $strType = $notificationType->getTypeFromValue(); switch ($strType) { case 'TRANSACTION': self::transactionNotification($code); break; case 'APPLICATION_AUTHORIZATION': self::authorizationNotification($code); break; case 'PRE_APPROVAL': self::preApprovalNotification($code); break; default: LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]"); } self::printLog($strType); } else { LogPagSeguro::error("Invalid notification parameters."); self::printLog(); } }
public static function getRetorno($code, $type) { $this->ci->log_message('error', $code . '|' . $type); if ($code && $type) { $notificationType = new PagSeguroNotificationType($type); $strType = $notificationType->getTypeFromValue(); switch ($strType) { case 'TRANSACTION': return self::transactionNotification($code); break; default: LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]"); show_error('PagSeguroLibrary: Unknown notification type [' . $notificationType->getValue() . ']'); break; } } else { LogPagSeguro::error("Invalid notification parameters."); show_error('PagSeguroLibrary: Invalid notification parameters.'); } }
/** * NotificationListener * * Recebe as notificações do pagseguro sobre atualização de pagamento. * @access public * @return bool */ public function NotificationListener() { $code = isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ? trim($_POST['notificationCode']) : null; $type = isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ? trim($_POST['notificationType']) : null; $transaction = false; if ($code && $type) { $notificationType = new PagSeguroNotificationType($type); $strType = $notificationType->getTypeFromValue(); switch ($strType) { case 'TRANSACTION': $transaction = self::TransactionNotification($code); break; default: LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]"); } } else { LogPagSeguro::error("Invalid notification parameters."); self::printLog(); } if (is_object($transaction)) { self::setTransacaoPagseguro($transaction); } return TRUE; }
function validateIPN($data, $vars) { if (is_array($data)) { $code = $data['notificationCode']; $type = $data['notificationType']; } else { if (is_object($data)) { $code = $data->get('notificationCode'); $type = $data->get('notificationType'); } } if ($code && $type) { $notificationType = new PagSeguroNotificationType($type); $strType = $notificationType->getTypeFromValue(); switch ($strType) { case 'TRANSACTION': $credentials = new PagSeguroAccountCredentials($vars->sellar_email, $vars->token); try { $transaction = PagSeguroNotificationService::checkTransaction($credentials, $code); $returndata['transaction_id'] = $transaction->getCode(); $returndata['payment_status'] = $transaction->getStatus()->getTypeFromValue(); $returndata['payment_statuscode'] = $transaction->getStatus()->getValue(); $returndata['order_id'] = $transaction->getReference(); $returndata['buyer_email'] = $transaction->getSender()->getEmail(); $returndata['payment_method'] = $transaction->getpaymentMethod()->gettype()->getTypeFromValue(); $returndata['total_paid_amt'] = $transaction->getgrossAmount(); $returndata['raw_data'] = json_encode($returndata); return $returndata; } catch (PagSeguroServiceException $e) { $error = array(); $error['code'] = ''; //@TODO change these $data indexes afterwards $error['desc'] = $e->getMessage(); return $error; } break; default: $error = array(); $error['code'] = ''; //@TODO change these $data indexes afterwards $error['desc'] = "Unknown notification type [" . $notificationType->getValue() . "]"; return $error; break; } } else { $error = array(); $error['code'] = ''; //@TODO change these $data indexes afterwards $error['desc'] = 'Unknown notification type'; return $error; } }
function plgVmOnPaymentNotification() { $post = $_POST; if (!PagSeguroHelper::isNotificationEmpty($post)) { $notificationType = new PagSeguroNotificationType($post['notificationType']); $strType = $notificationType->getTypeFromValue(); switch ($strType) { case 'TRANSACTION': $this->_doUpdateByNotification($post['notificationCode']); break; default: LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]"); } } else { LogPagSeguro::error("Invalid notification parameters."); } }
public function callback() { require_once DIR_SYSTEM . 'library/PagSeguroLibrary/PagSeguroLibrary.php'; $code = isset($_POST['notificationCode']) && trim($_POST['notificationCode']) != "" ? trim($_POST['notificationCode']) : null; $type = isset($_POST['notificationType']) && trim($_POST['notificationType']) != "" ? trim($_POST['notificationType']) : null; if ($code && $type) { $notificationType = new PagSeguroNotificationType($type); $strType = $notificationType->getTypeFromValue(); switch ($strType) { case 'TRANSACTION': $credentials = new PagSeguroAccountCredentials($this->config->get('pagseguro_email'), $this->config->get('pagseguro_token')); try { $transaction = PagSeguroNotificationService::checkTransaction($credentials, $code); $transactionStatus = $transaction->getStatus(); $id_pedido = explode('_', $transaction->getReference()); $paymentMethod = $transaction->getPaymentMethod(); $parcelas = $transaction->getInstallmentCount(); $pagSeguroShipping = $transaction->getShipping(); $codigo_transacao = $transaction->getCode(); $this->load->model('checkout/order'); $order = $this->model_checkout_order->getOrder($id_pedido[0]); // Obtendo o tipo de pagamento escolhido $payment_code = $paymentMethod->getCode(); $comment = "Código da transação: " . $codigo_transacao . "\nTipo de pagamento: " . $payment_code->getTypeFromValue() . "\nParcelas: " . $parcelas . "\n"; // Obtendo o tipo e o valor do frete $pagSeguroShippingType = $pagSeguroShipping->getType(); $valor_frete = $pagSeguroShipping->getCost(); // Valor 1: Pac, valor 2: Sedex, valor 3: não especificado ou cálculo não realizado pelo PagSeguro if ($pagSeguroShippingType->getValue() != 3) { $comment .= "\nTipo de frete escolhido no PagSeguro: " . $pagSeguroShippingType->getTypeFromValue() . "\nValor do frete: " . $this->currency->format($valor_frete, $order['currency_code'], false, false); } $update_status_alert = false; if ($this->config->get('pagseguro_update_status_alert')) { $update_status_alert = true; } switch ($transactionStatus->getTypeFromValue()) { case 'WAITING_PAYMENT': if ($order['order_status_id'] == '0') { $this->model_checkout_order->confirm($id_pedido[0], $this->config->get('pagseguro_order_aguardando_pagamento'), $comment); } else { if ($order['order_status_id'] != $this->config->get('pagseguro_order_aguardando_pagamento')) { $this->model_checkout_order->update($id_pedido[0], $this->config->get('pagseguro_order_aguardando_pagamento'), $comment, $update_status_alert); } } break; case 'IN_ANALYSIS': if ($order['order_status_id'] != $this->config->get('pagseguro_order_analise')) { $this->model_checkout_order->update($id_pedido[0], $this->config->get('pagseguro_order_analise'), '', $update_status_alert); } break; case 'PAID': if ($order['order_status_id'] != $this->config->get('pagseguro_order_paga')) { $this->model_checkout_order->update($id_pedido[0], $this->config->get('pagseguro_order_paga'), $comment, $update_status_alert); } break; case 'AVAILABLE': //if($order['order_status_id'] != $this->config->get('pagseguro_order_disponivel')){ // $this->model_checkout_order->update($id_pedido[0], $this->config->get('pagseguro_order_disponivel'), '', false); //} break; case 'IN_DISPUTE': if ($order['order_status_id'] != $this->config->get('pagseguro_order_disputa')) { $this->model_checkout_order->update($id_pedido[0], $this->config->get('pagseguro_order_disputa'), $comment, $update_status_alert); } break; case 'REFUNDED': if ($order['order_status_id'] != $this->config->get('pagseguro_order_devolvida')) { $this->model_checkout_order->update($id_pedido[0], $this->config->get('pagseguro_order_devolvida'), $comment, $update_status_alert); } break; case 'CANCELLED': if ($order['order_status_id'] != $this->config->get('pagseguro_order_cancelada')) { $this->model_checkout_order->update($id_pedido[0], $this->config->get('pagseguro_order_cancelada'), $comment, $update_status_alert); } break; } } catch (PagSeguroServiceException $e) { $this->log->write('PagSeguro: ' . $e->getOneLineMessage()); } break; default: $this->log->write('PagSeguro: tipo de notificação desconhecido [' . $notificationType->getValue() . ']'); } } else { $this->log->write('PagSeguro: Parâmetros de notificação retornado pelo PagSeguro são inválidos.'); } }