/** * Build a URL for recovery a PagSeguroTransaction * * @param string $recoveryCode * @return URI */ private function abandonedRecoveryUrl($recoveryCode) { if (strtolower($this->_library->getEnvironment()) == "sandbox") { return 'https://sandbox.pagseguro.uol.com.br/checkout/v2/resume.html?r=' . $recoveryCode; } return 'https://pagseguro.uol.com.br/checkout/v2/resume.html?r=' . $recoveryCode; }
/** * Request a PagSeguro Cancel * * @param $config * @return \PagSeguro\Parsers\Cancel\Response * @throws \Exception */ private function requestCancel($config) { \PagSeguro\Configuration\Configure::setEnvironment($this->_library->getEnvironment()); try { return \PagSeguro\Services\Transactions\Cancel::create($this->_library->getPagSeguroCredentials(), $config->pagseguro_id); } catch (\Exception $exception) { throw $exception; } }
/** * Show payment page * @return \Magento\Framework\View\Result\PageFactory */ public function execute() { $resultPage = $this->_resultPageFactory->create(); $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('order', $this->_checkoutSession->getLastRealOrder()->getId()); try { $this->_library->setEnvironment(); $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('sessionCode', $this->_library->getSession()); $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('paymentUrl', $this->_library->getDirectPaymentUrl()); } catch (\Exception $exc) { /** @var \Magento\Sales\Model\Order $order */ $order = $this->_objectManager->create('\\Magento\\Sales\\Model\\Order')->load($this->_checkoutSession->getLastRealOrder()->getId()); /** change payment status in magento */ $order->addStatusToHistory('pagseguro_cancelada', null, true); /** save order */ $order->save(); return $this->_redirect('pagseguro/payment/failure'); } return $resultPage; }
/** * Get transaction from PagSeguro WS. * @param $code * @return \PagSeguroTransaction * @throws \Exception * @throws \PagSeguroServiceException */ private function getTransaction() { return \PagSeguro\Services\Transactions\Notification::check($this->_library->getPagSeguroCredentials()); }