/** * Process the payment request and redirect to PagSeguro Gateway */ public function requestAction() { $Order = $this->getOrder(); //Order Data $PagSeguroPaymentModel = $this->getPagSeguroPaymentModel(); $enabledOSC = false; $fileOSC = scandir(getcwd() . '/app/code/community/DeivisonArthur'); if ($fileOSC) { $enabledOSC = Mage::helper('onepagecheckout')->isOnepageCheckoutEnabled(); } $feedback = $enabledOSC == false ? 'checkout/onepage' : 'onepagecheckout'; if ($Order->getState() == Mage_Sales_Model_Order::STATE_NEW and $Order->getPayment()->getMethod() == $PagSeguroPaymentModel->getCode() and $Order->getId()) { $orderId = $Order->getEntityId(); include_once Mage::getBaseDir('lib') . '/PagSeguroLibrary/PagSeguroLibrary.php'; $environment = PagSeguroConfig::getEnvironment(); if ($environment == 'production') { $environment = "Produção"; } else { $environment = "Sandbox"; } $tp = (string) Mage::getConfig()->getTablePrefix(); $table = $tp . 'pagseguro_orders'; $read = Mage::getSingleton('core/resource')->getConnection('core_read'); $value = $read->query("SELECT `order_id` FROM `" . $table . "` WHERE `order_id` = " . $orderId); $row = $value->fetch(); if ($row == false) { $connection = Mage::getSingleton('core/resource')->getConnection('core_write'); $sql = "INSERT INTO `" . $table . "` (`order_id`, `environment`) \n VALUES ('{$orderId}','{$environment}')"; $connection->query($sql); } try { $PagSeguroPaymentModel->setOrder($Order); $this->_redirectUrl($PagSeguroPaymentModel->getRedirectPaymentHtml($Order)); //after verify if the order was created, instantiates the sendEmail() method $this->sendEmail(); } catch (Exception $ex) { Mage::log($ex->getMessage()); Mage::getSingleton('core/session')->addError(self::MENSAGEM); $this->_redirectUrl(Mage::getUrl('checkout/cart')); if ($checkout == 'PADRAO') { $this->_redirectUrl(Mage::getUrl() . $feedback); } $this->_canceledStatus($Order); } } else { Mage::getSingleton('core/session/canceled')->addError(self::MENSAGEM); $this->_redirectUrl(Mage::getUrl('checkout/cart')); if ($checkout == 'PADRAO') { $this->_redirectUrl(Mage::getUrl() . $feedback); } $this->_canceledStatus($Order); } }
/** * Process the payment request and redirect to PagSeguro Gateway */ public function requestAction() { $helper = Mage::helper('pagseguro'); $paymentMethod = $helper->paymentModel(); $feedback = 'checkout/onepage'; $order = Mage::getModel('sales/order')->load($this->getCheckout()->getLastOrderId()); $method = $order->getPayment()->getMethod(); $code = $paymentMethod->getCode(); if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW && $method == $code && $order->getId()) { $orderId = $order->getEntityId(); include_once Mage::getBaseDir('lib') . '/PagSeguroLibrary/PagSeguroLibrary.php'; $environment = PagSeguroConfig::getEnvironment(); if ($environment == 'production') { $environment = $helper->__("Produção"); } else { $environment = $helper->__("Sandbox "); } $tp = (string) Mage::getConfig()->getTablePrefix(); $table = $tp . 'pagseguro_orders'; $read = Mage::getSingleton('core/resource')->getConnection('core_read'); $value = $read->query("SELECT `order_id` FROM `" . $table . "` WHERE `order_id` = " . $orderId); $row = $value->fetch(); if ($row == false) { $connection = Mage::getSingleton('core/resource')->getConnection('core_write'); $sql = "INSERT INTO `" . $table . "` (`order_id`, `environment`) VALUES ('{$orderId}','{$environment}')"; $connection->query($sql); } try { $paymentMethod->setOrder($order); $this->_redirectUrl($paymentMethod->getRedirectPaymentHtml($order)); //after verify if the order was created, instantiates the sendEmail() method $this->sendEmail(); } catch (Exception $ex) { Mage::log($ex->getMessage()); Mage::getSingleton('core/session')->addError($helper->__(self::MENSAGEM)); $this->_redirectUrl(Mage::getUrl('checkout/cart')); if ($checkout == 'PADRAO') { $this->_redirectUrl(Mage::getUrl() . $feedback); } $this->canceledStatus($order); } } else { Mage::getSingleton('core/session/canceled')->addError($helper->__(self::MENSAGEM)); $this->_redirectUrl(Mage::getUrl('checkout/cart')); if ($checkout == 'PADRAO') { $this->_redirectUrl(Mage::getUrl() . $feedback); } $this->canceledStatus($order); } }
public function __construct(Credentials $credentials, $serviceName) { $this->credentials = $credentials; $this->serviceName = $serviceName; $this->setEnvironment(PagSeguroConfig::getEnvironment()); $this->setWebserviceUrl(PagSeguroResources::getWebserviceUrl($this->getEnvironment())); $this->setCharset(PagSeguroConfig::getApplicationCharset()); $this->resources = PagSeguroResources::getData($this->serviceName); if (isset($this->resources['servicePath'])) { $this->setServicePath($this->resources['servicePath']); } if (isset($this->resources['serviceTimeout'])) { $this->setServiceTimeout($this->resources['serviceTimeout']); } }
public function initContent() { $this->display_column_left = false; parent::initContent(); $payment = new PagSeguroPaymentOrderPrestashop(); $payment->setVariablesPaymentExecutionView(); $environment = PagSeguroConfig::getEnvironment(); $this->context = Context::getContext(); $this->context->smarty->assign('environment', $environment); if (version_compare(_PS_VERSION_, '1.5.0.1', '>=')) { $this->context->smarty->assign('width_center_column', '100%'); } $url = "index.php?fc=module&module=pagseguro&controller=error"; $this->context->smarty->assign('errurl', $url); $this->setTemplate('payment_execution.tpl'); }
public function __construct(PagSeguroCredentials $credentials, $serviceName) { $this->credentials = $credentials; $this->serviceName = $serviceName; try { $this->setEnvironment(PagSeguroConfig::getEnvironment()); $this->setWebserviceUrl(PagSeguroResources::getWebserviceUrl($this->getEnvironment())); $this->setPaymentUrl(PagSeguroResources::getPaymentUrl($this->getEnvironment())); $this->setBaseUrl(PagSeguroResources::getBaseUrl($this->getEnvironment())); $this->setInstallmentUrl(PagSeguroResources::getInstallmentUrl()); $this->setAuthorizationUrl(PagSeguroResources::getAuthorizationUrl()); $this->setSessionUrl(PagSeguroResources::getSessionUrl()); $this->setCharset(PagSeguroConfig::getApplicationCharset()); $this->resources = PagSeguroResources::getData($this->serviceName); if (isset($this->resources['servicePath'])) { $this->setServicePath($this->resources['servicePath']); } if (isset($this->resources['serviceTimeout'])) { $this->setServiceTimeout($this->resources['serviceTimeout']); } } catch (Exception $e) { throw $e; } }
public function __construct() { include_once Mage::getBaseDir('lib') . '/PagSeguroLibrary/PagSeguroLibrary.php'; $this->environment = PagSeguroConfig::getEnvironment(); }
* * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once dirname(__FILE__) . '/../../../../config/config.inc.php'; include_once dirname(__FILE__) . '/../../../../init.php'; include_once dirname(__FILE__) . '/../../pagseguro.php'; include_once dirname(__FILE__) . '/../../backward_compatibility/backward.php'; include_once dirname(__FILE__) . '/../../features/payment/pagseguropaymentorderprestashop.php'; $useSSL = true; $showView = new BWDisplay(); $context = Context::getContext(); if (!$context->cookie->isLogged(true)) { Tools::redirect('authentication.php?back=order.php'); } $payment = new PagSeguroPaymentOrderPrestashop(); $payment->setVariablesPaymentExecutionView(); $environment = PagSeguroConfig::getEnvironment(); $context->smarty->assign('environment', $environment); $url = "modules/pagseguro/standard/front/error.php"; $context->smarty->assign('errurl', $url); $showView->setTemplate(_PS_MODULE_DIR_ . 'pagseguro/views/templates/front/payment_execution.tpl'); $showView->run();