diff --git a/Controller/Adminhtml/Cancellation/Cancel.php b/Controller/Adminhtml/Cancellation/Cancel.php index 32edee6..63e29d6 100755 --- a/Controller/Adminhtml/Cancellation/Cancel.php +++ b/Controller/Adminhtml/Cancellation/Cancel.php @@ -53,7 +53,7 @@ public function execute() { $cancellation = new Cancellation( $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), - $this->_objectManager->create('Magento\Framework\App\ResourceConnection'), + $this->_objectManager->create('\Magento\Framework\App\ResourceConnection'), $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), $this->_objectManager->create('Magento\Backend\Model\Session'), $this->_objectManager->create('Magento\Sales\Model\Order'), diff --git a/Controller/Adminhtml/Cancellation/Request.php b/Controller/Adminhtml/Cancellation/Request.php index 2acc83d..123464e 100755 --- a/Controller/Adminhtml/Cancellation/Request.php +++ b/Controller/Adminhtml/Cancellation/Request.php @@ -52,14 +52,14 @@ public function __construct( public function execute() { $cancellation = new Cancellation( - $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), - $this->_objectManager->create('Magento\Framework\App\ResourceConnection'), - $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), - $this->_objectManager->create('Magento\Backend\Model\Session'), - $this->_objectManager->create('Magento\Sales\Model\Order'), - $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), - $this->_objectManager->create('UOL\PagSeguro\Helper\Crypt'), - $this->getRequest()->getParam('days') + $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), + $this->_objectManager->create('\Magento\Framework\App\ResourceConnection'), + $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), + $this->_objectManager->create('Magento\Backend\Model\Session'), + $this->_objectManager->create('Magento\Sales\Model\Order'), + $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), + $this->_objectManager->create('UOL\PagSeguro\Helper\Crypt'), + $this->getRequest()->getParam('days') ); try { diff --git a/Controller/Adminhtml/Conciliation/Conciliate.php b/Controller/Adminhtml/Conciliation/Conciliate.php index 5def2c9..7c80f53 100755 --- a/Controller/Adminhtml/Conciliation/Conciliate.php +++ b/Controller/Adminhtml/Conciliation/Conciliate.php @@ -52,13 +52,13 @@ public function __construct( public function execute() { $conciliation = new Conciliation( - $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), - $this->_objectManager->create('Magento\Framework\App\ResourceConnection'), - $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), - $this->_objectManager->create('Magento\Backend\Model\Session'), - $this->_objectManager->create('Magento\Sales\Model\Order'), - $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), - $this->_objectManager->create('UOL\PagSeguro\Helper\Crypt') + $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), + $this->_objectManager->create('\Magento\Framework\App\ResourceConnection'), + $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), + $this->_objectManager->create('Magento\Backend\Model\Session'), + $this->_objectManager->create('Magento\Sales\Model\Order'), + $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), + $this->_objectManager->create('UOL\PagSeguro\Helper\Crypt') ); try { diff --git a/Controller/Adminhtml/Conciliation/Request.php b/Controller/Adminhtml/Conciliation/Request.php index 7ffef91..709d547 100755 --- a/Controller/Adminhtml/Conciliation/Request.php +++ b/Controller/Adminhtml/Conciliation/Request.php @@ -55,14 +55,14 @@ public function __construct( public function execute() { $conciliation = new Conciliation( - $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), - $this->_objectManager->create('Magento\Framework\App\ResourceConnection'), - $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), - $this->_objectManager->create('Magento\Backend\Model\Session'), - $this->_objectManager->create('Magento\Sales\Model\Order'), - $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), - $this->_objectManager->create('UOL\PagSeguro\Helper\Crypt'), - $this->getRequest()->getParam('days') + $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), + $this->_objectManager->create('\Magento\Framework\App\ResourceConnection'), + $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), + $this->_objectManager->create('Magento\Backend\Model\Session'), + $this->_objectManager->create('Magento\Sales\Model\Order'), + $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), + $this->_objectManager->create('UOL\PagSeguro\Helper\Crypt'), + $this->getRequest()->getParam('days') ); try { return $this->whenSuccess($conciliation->request()); diff --git a/Controller/Adminhtml/Refund/Request.php b/Controller/Adminhtml/Refund/Request.php index c8d2bd6..f28f8c1 100755 --- a/Controller/Adminhtml/Refund/Request.php +++ b/Controller/Adminhtml/Refund/Request.php @@ -50,14 +50,14 @@ public function __construct( public function execute() { $refund = new Methods\Refund( - $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), - $this->_objectManager->create('Magento\Framework\App\ResourceConnection'), - $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), - $this->_objectManager->create('Magento\Backend\Model\Session'), - $this->_objectManager->create('Magento\Sales\Model\Order'), - $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), - $this->_objectManager->create('UOL\PagSeguro\Helper\Crypt'), - $this->getRequest()->getParam('days') + $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), + $this->_objectManager->create('Magento\Framework\App\ResourceConnection'), + $this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'), + $this->_objectManager->create('Magento\Backend\Model\Session'), + $this->_objectManager->create('Magento\Sales\Model\Order'), + $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), + $this->_objectManager->create('UOL\PagSeguro\Helper\Crypt'), + $this->getRequest()->getParam('days') ); try { diff --git a/Controller/Direct/Payment.php b/Controller/Direct/Payment.php index f907be6..9814ac0 100755 --- a/Controller/Direct/Payment.php +++ b/Controller/Direct/Payment.php @@ -26,8 +26,8 @@ use UOL\PagSeguro\Model\PaymentMethod; /** - * Class Checkout - * @package UOL\PagSeguro\Controller\Payment + * Class Payment + * @package UOL\PagSeguro\Controller\Direct\Payment */ class Payment extends \Magento\Framework\App\Action\Action { diff --git a/Controller/Payment/Cancel.php b/Controller/Payment/Cancel.php new file mode 100644 index 0000000..39c921d --- /dev/null +++ b/Controller/Payment/Cancel.php @@ -0,0 +1,85 @@ +_resultPageFactory = $resultPageFactory; + + } + /** + * Show cancel page + * + * @return \Magento\Framework\View\Result\PageFactory + */ + public function execute() + { + + $this->_orderFactory = $this->_objectManager->get('\Magento\Sales\Model\OrderFactory'); + $this->_checkoutSession = $this->_objectManager->get('\Magento\Checkout\Model\Session'); + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load( + $this->_checkoutSession->getLastRealOrderId()); + + /** change payment status in magento */ + $order->addStatusToHistory('pagseguro_cancelada', null, true); + /** save order */ + $order->save(); + + return $this->_redirect('/'); + + } +} diff --git a/Controller/Payment/Checkout.php b/Controller/Payment/Checkout.php index ddac599..62a7422 100755 --- a/Controller/Payment/Checkout.php +++ b/Controller/Payment/Checkout.php @@ -69,7 +69,6 @@ public function __construct( public function execute() { $result = $this->payment->createPaymentRequest(); - $resultPage = $this->resultPageFactory->create(); $code = $result->getCode(); $resultPage->getLayout()->getBlock('pagseguro.payment.checkout') diff --git a/Controller/Payment/Request.php b/Controller/Payment/Request.php index 4936bd5..b43fdf0 100755 --- a/Controller/Payment/Request.php +++ b/Controller/Payment/Request.php @@ -23,6 +23,9 @@ namespace UOL\PagSeguro\Controller\Payment; +use UOL\PagSeguro\Model\Direct\BoletoMethod; +use UOL\PagSeguro\Model\Direct\CreditCardMethod; +use UOL\PagSeguro\Model\Direct\DebitMethod; use UOL\PagSeguro\Model\PaymentMethod; /** @@ -42,6 +45,16 @@ class Request extends \Magento\Framework\App\Action\Action * @var \UOL\PagSeguro\Model\PaymentMethod */ private $_payment; + + private $order; + + private $orderId; + + /** @var \Magento\Framework\Controller\Result\Json */ + protected $result; + + /** @var \Magento\Framework\View\Result\Page */ + protected $resultJsonFactory; /** * Request constructor. @@ -50,8 +63,11 @@ class Request extends \Magento\Framework\App\Action\Action */ public function __construct( \Magento\Framework\App\Action\Context $context + //\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context); + $this->resultJsonFactory = $this->_objectManager->create('\Magento\Framework\Controller\Result\JsonFactory'); + $this->result = $this->resultJsonFactory->create(); /** @var \Magento\Checkout\Model\Session _checkoutSession */ $this->_checkoutSession = $this->_objectManager->create('\Magento\Checkout\Model\Session'); @@ -72,6 +88,152 @@ public function __construct( */ public function execute() { + $lastRealOrder = $this->_checkoutSession->getLastRealOrder(); + + if (is_null($lastRealOrder->getPayment())) { + throw new \Magento\Framework\Exception\NotFoundException(__('No order associated.')); + } + + $paymentData = $lastRealOrder->getPayment()->getData(); + + if ($paymentData['method'] === 'pagseguro_boleto') { + try { + $this->orderId = $lastRealOrder->getId(); + if (is_null($this->orderId)) { + throw new \Exception("There is no order associated with this session."); + } + + if (! isset($paymentData['additional_information']['boleto_document']) + || ! isset($paymentData['additional_information']['hash'])) { + throw new \Exception("Error passing data from checkout page to pagseguro Request Controller"); + } + + $this->order = $this->loadOrder($this->orderId); + /** @var \UOL\PagSeguro\Model\Direct\BoletoMethod $boleto */ + $boleto = new BoletoMethod( + $this->_objectManager->create('Magento\Directory\Api\CountryInformationAcquirerInterface'), + $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), + $this->_objectManager->create('Magento\Framework\Module\ModuleList'), + $this->order, + $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), + $data = [ + 'sender_document' => $this->helperData()->formatDocument($paymentData['additional_information']['boleto_document']), + 'sender_hash' => $paymentData['additional_information']['hash'], + 'order_id' => $this->orderId + ] + ); + $this->placeOrder($boleto, $paymentData['method']); + return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/direct/success')); + } catch (\Exception $exception) { + if (!is_null($this->order)) { + $this->changeOrderHistory('pagseguro_cancelada'); + } + $this->pagseguroLogger($exception->getMessage()); + $this->clearSession(); + $this->whenError($exception->getMessage()); + return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/payment/failure')); + } + } + + if ($paymentData['method'] === 'pagseguro_online_debit') { + try { + $this->orderId = $lastRealOrder->getId(); + + if (is_null($this->orderId)) { + throw new \Exception("There is no order associated with this session."); + } + + if (!isset($paymentData['additional_information']['online_debit_document']) + || ! isset($paymentData['additional_information']['hash']) + || ! isset($paymentData['additional_information']['online_debit_bank']) + ) { + throw new \Exception("Error passing data from checkout page to pagseguro Request Controller"); + } + $this->order = $this->loadOrder($this->orderId); + /** @var \UOL\PagSeguro\Model\Direct\DebitMethod $debit */ + + $debit = new DebitMethod( + $this->_objectManager->create('Magento\Directory\Api\CountryInformationAcquirerInterface'), + $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), + $this->_objectManager->create('Magento\Framework\Module\ModuleList'), + $this->order, + $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), + $data = [ + 'sender_document' => $this->helperData()->formatDocument($paymentData['additional_information']['online_debit_document']), + 'sender_hash' => $paymentData['additional_information']['hash'], + 'bank_name' => $paymentData['additional_information']['online_debit_bank'], + 'order_id' => $this->orderId + ] + ); + $this->placeOrder($debit, $paymentData['method']); + return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/direct/success')); + } catch (\Exception $exception) { + $this->pagseguroLogger($exception->getMessage()); + if (!is_null($this->order)) { + $this->changeOrderHistory('pagseguro_cancelada'); + } + $this->clearSession(); + $this->whenError($exception->getMessage()); + return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/payment/failure')); + } + } + + if ($paymentData['method'] === 'pagseguro_credit_card') { + try { + $this->orderId = $lastRealOrder->getId(); + + if (is_null($this->orderId)) { + throw new \Exception("There is no order associated with this session."); + } + + if (!isset($paymentData['additional_information']['credit_card_document']) + || ! isset($paymentData['additional_information']['hash']) + || ! isset($paymentData['additional_information']['credit_card_token']) + || ! isset($paymentData['additional_information']['credit_card_holder_name']) + || ! isset($paymentData['additional_information']['credit_card_holder_birthdate']) + || ! isset($paymentData['additional_information']['credit_card_installment']) + || ! isset($paymentData['additional_information']['credit_card_installment_value']) + ) { + throw new \Exception("Error passing data from checkout page to pagseguro Request Controller"); + } + $this->order = $this->loadOrder($this->orderId); + /** @var \UOL\PagSeguro\Model\Direct\CreditCardMethod $creditCard */ + + $creditCard = new CreditCardMethod( + $this->_objectManager->create('Magento\Directory\Api\CountryInformationAcquirerInterface'), + $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), + $this->_objectManager->create('Magento\Framework\Module\ModuleList'), + $this->order, + $this->_objectManager->create('UOL\PagSeguro\Helper\Library'), + $data = [ + 'sender_document' => $this->helperData()->formatDocument($paymentData['additional_information']['credit_card_document']), + 'sender_hash' => $paymentData['additional_information']['hash'], + 'order_id' => $this->orderId, + 'installment' => [ + 'quantity' => $paymentData['additional_information']['credit_card_installment'], + 'amount' => $paymentData['additional_information']['credit_card_installment_value'] + ], + 'token' => $paymentData['additional_information']['credit_card_token'], + 'holder' => [ + 'name' => $paymentData['additional_information']['credit_card_holder_name'], + 'birth_date' => $paymentData['additional_information']['credit_card_holder_birthdate'], + + ] + ] + ); + $this->placeOrder($creditCard, $paymentData['method']); + return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/direct/success')); + } catch (\Exception $exception) { + $this->pagseguroLogger($exception->getMessage()); + if (!is_null($this->order)) { + $this->changeOrderHistory('pagseguro_cancelada'); + } + $this->clearSession(); + $this->whenError($exception->getMessage()); + return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/payment/failure')); + } + } + try { return $this->_redirect($this->_payment->createPaymentRequest()); } catch (\Exception $exception) { @@ -87,4 +249,145 @@ public function execute() return $this->_redirect('pagseguro/payment/failure'); } } + + /** + * Load a order by id + * + * @return \Magento\Sales\Model\Order + */ + private function loadOrder($orderId) + { + return $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); + } + + /** + * Load PagSeguro helper data + * + * @return \UOL\PagSeguro\Helper\Data + */ + private function helperData() + { + return $this->_objectManager->create('UOL\PagSeguro\Helper\Data'); + } + + /** + * Place order + * + * @param $payment + * @return string + */ + private function placeOrder($payment, $method) + { + $this->changeOrderHistory('pagseguro_aguardando_pagamento'); + return $this->whenSuccess($payment->createPaymentRequest(), $method); + } + + /** + * Change the magento order status + * + * @param $status + */ + private function changeOrderHistory($status) + { + /** change payment status in magento */ + $this->order->addStatusToHistory($status, null, true); + /** save order */ + $this->order->save(); + } + + /** + * Return when success + * + * @param $response + * @return $this + */ + private function whenSuccess($response, $method) + { + $this->makeSession($response, $method); + return $this->result->setData([ + 'success' => true, + 'payload' => [ + 'redirect' => sprintf('%s%s', $this->baseUrl(), 'pagseguro/direct/success') + ] + ]); + } + + /** + * Create new pagseguro payment session data + * + * @param $response + */ + private function makeSession($response, $method) + { + if ($method === 'pagseguro_credit_card') { + $this->session()->setData([ + 'pagseguro_payment' => [ + 'payment_type' => $method, + 'order_id' => $this->orderId, + ] + ]); + } else { + $this->session()->setData([ + 'pagseguro_payment' => ['payment_link' => $response->getPaymentLink(), + 'payment_type' => $method, + 'order_id' => $this->orderId, + ] + ]); + } + } + + /** + * Clear session storage + */ + private function clearSession() + { + $this->_objectManager->create('Magento\Framework\Session\SessionManager')->clearStorage(); + } + + /** + * Return when fails + * + * @param $message + * @return $this + */ + private function whenError($message) + { + return $this->result->setData([ + 'success' => false, + 'payload' => [ + 'error' => $message, + 'redirect' => sprintf('%s%s', $this->baseUrl(), 'pagseguro/payment/failure') + ] + ]); + } + + /** + * Get base url + * + * @return string url + */ + private function baseUrl() + { + return $this->_objectManager->create('Magento\Store\Model\StoreManagerInterface')->getStore()->getBaseUrl(); + } + + /** + * Create a new session object + * + * @return \Magento\Framework\Session\SessionManager + */ + private function session() + { + return $this->_objectManager->create('Magento\Framework\Session\SessionManager'); + } + + /** + * Save error log in system.log + * @param string $errorMessage + */ + private function pagseguroLogger($errorMessage) + { + $logger = $this->_objectManager->create('\Psr\Log\LoggerInterface'); + $logger->addError('[Uol PagSeguro Module][Payment Error] ' .$errorMessage); + } } diff --git a/Helper/Library.php b/Helper/Library.php index 47fb53f..238559c 100644 --- a/Helper/Library.php +++ b/Helper/Library.php @@ -83,7 +83,7 @@ public function getPagSeguroCredentials() */ public function isLightboxCheckoutType() { - if ($this->_scopeConfig->getValue('payment/pagseguro/checkout') + if ($this->_scopeConfig->getValue('payment/pagseguro_default_lightbox/checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::LIGHTBOX) { return true; } @@ -178,4 +178,17 @@ public function getDirectPaymentUrl() return Library::DIRECT_PAYMENT_URL; } } + + /** + * Get image full frontend url + * @return type + */ + public function getImageUrl($imageModulePath) + { + /** @var \Magento\Framework\App\ObjectManager $om */ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + /** @var \Magento\Framework\View\Asset\Repository */ + $viewRepository = $objectManager->get('\Magento\Framework\View\Asset\Repository'); + return $viewRepository->getUrl($imageModulePath); + } } diff --git a/Model/Direct/BoletoMethod.php b/Model/Direct/BoletoMethod.php index 8b2874c..267c31a 100644 --- a/Model/Direct/BoletoMethod.php +++ b/Model/Direct/BoletoMethod.php @@ -99,6 +99,7 @@ public function createPaymentRequest() try { $this->currency(); $this->reference(); + $this->discounts(); $this->shipping(); $this->sender(); $this->urls(); @@ -271,9 +272,9 @@ private function loggedIn() */ private function getEmail() { - if ($this->_scopeConfig->getValue('payment/pagseguro/environment') == "sandbox") { - return "magento2@sandbox.pagseguro.com.br"; //mock for sandbox - } +// if ($this->_scopeConfig->getValue('payment/pagseguro/environment') == "sandbox") { +// return "magento2@sandbox.pagseguro.com.br"; //mock for sandbox +// } return $this->_order->getCustomerEmail(); } @@ -424,4 +425,12 @@ private function getCountryName($countryId) $this->_countryInformation->getCountryInfo($countryId)->getFullNameLocale() : $countryId; } + + /** + * Set discounts using PagSeguro "extra amount" parameter + */ + private function discounts() + { + $this->_paymentRequest->setExtraAmount(round($this->_order->getDiscountAmount(), 2)); + } } diff --git a/Model/Direct/CreditCardMethod.php b/Model/Direct/CreditCardMethod.php index 6578214..f12294a 100644 --- a/Model/Direct/CreditCardMethod.php +++ b/Model/Direct/CreditCardMethod.php @@ -87,6 +87,7 @@ public function createPaymentRequest() try { $this->currency(); $this->reference(); + $this->discounts(); $this->shipping(); $this->sender(); $this->urls(); @@ -347,9 +348,9 @@ private function loggedIn() */ private function getEmail() { - if ($this->_scopeConfig->getValue('payment/pagseguro/environment') == "sandbox") { - return "magento2@sandbox.pagseguro.com.br"; //mock for sandbox - } +// if ($this->_scopeConfig->getValue('payment/pagseguro/environment') == "sandbox") { +// return "magento2@sandbox.pagseguro.com.br"; //mock for sandbox +// } return $this->_order->getCustomerEmail(); } @@ -500,4 +501,12 @@ private function getCountryName($countryId) $this->_countryInformation->getCountryInfo($countryId)->getFullNameLocale() : $countryId; } + + /** + * Set discounts using PagSeguro "extra amount" parameter + */ + private function discounts() + { + $this->_paymentRequest->setExtraAmount(round($this->_order->getDiscountAmount(), 2)); + } } diff --git a/Model/Direct/DebitMethod.php b/Model/Direct/DebitMethod.php index e61b75e..6b8f8c7 100644 --- a/Model/Direct/DebitMethod.php +++ b/Model/Direct/DebitMethod.php @@ -96,6 +96,7 @@ public function createPaymentRequest() try { $this->currency(); $this->reference(); + $this->discounts(); $this->shipping(); $this->sender(); $this->urls(); @@ -277,9 +278,9 @@ private function loggedIn() */ private function getEmail() { - if ($this->_scopeConfig->getValue('payment/pagseguro/environment') == "sandbox") { - return "magento2@sandbox.pagseguro.com.br"; //mock for sandbox - } +// if ($this->_scopeConfig->getValue('payment/pagseguro/environment') == "sandbox") { +// return "magento2@sandbox.pagseguro.com.br"; //mock for sandbox +// } return $this->_order->getCustomerEmail(); } @@ -430,4 +431,12 @@ private function getCountryName($countryId) $this->_countryInformation->getCountryInfo($countryId)->getFullNameLocale() : $countryId; } + + /** + * Set discounts using PagSeguro "extra amount" parameter + */ + private function discounts() + { + $this->_paymentRequest->setExtraAmount(round($this->_order->getDiscountAmount(), 2)); + } } diff --git a/Model/Payment.php b/Model/Payment.php index 936fd14..1159dd1 100644 --- a/Model/Payment.php +++ b/Model/Payment.php @@ -100,9 +100,9 @@ public function __construct( */ public function isDirectCheckout() { - if ($this->getConfigData('checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::DIRECT) { - return true; - } +// if ($this->getConfigData('checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::DIRECT) { +// return true; +// } return false; } @@ -148,4 +148,9 @@ public function getDirectCheckoutPaymentUrl() { return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/direct/payment"); } + + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null){ + return false + && parent::isAvailable($quote); + } } diff --git a/Model/PaymentBoleto.php b/Model/PaymentBoleto.php new file mode 100644 index 0000000..6ef4a2a --- /dev/null +++ b/Model/PaymentBoleto.php @@ -0,0 +1,135 @@ +_cart = $cart; + } + + /** + * Assign data to info model instance + * + * @param \Magento\Framework\DataObject $data + * @return \Magento\Payment\Model\Info + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function assignData(\Magento\Framework\DataObject $data) + { + parent::assignData($data); + + $info = $this->getInfoInstance(); + if (isset($data->getData('additional_data')['boleto_document'])) { + $info->setAdditionalInformation('boleto_document', $data->getData('additional_data')['boleto_document']); + } + + if (isset($data->getData('additional_data')['boleto_hash'])) { + $info->setAdditionalInformation('hash', $data->getData('additional_data')['boleto_hash']); + } + + return $this; + } + + /** + * Get standard checkout payment url + * + * @return url + */ + public function getStandardCheckoutPaymentUrl() + { + return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/payment/request/"); + } + + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null){ + return true + && parent::isAvailable($quote); + } +} diff --git a/Model/PaymentConfigProvider.php b/Model/PaymentConfigProvider.php index d42ce8b..40d76fe 100644 --- a/Model/PaymentConfigProvider.php +++ b/Model/PaymentConfigProvider.php @@ -35,12 +35,19 @@ class PaymentConfigProvider implements \Magento\Checkout\Model\ConfigProviderInt /** * Get payment method code for PagSeguro from Payment model. */ - const PAYMENT_METHOD_PAGSEGURO_CODE = \UOL\PagSeguro\Model\Payment::PAYMENT_METHOD_PAGSEGURO_CODE; + const PAYMENT_METHOD_PAGSEGURO_CODE = 'pagseguro_default_lightbox';//\UOL\PagSeguro\Model\Payment::PAYMENT_METHOD_PAGSEGURO_CODE; + + const PAYMENT_METHOD_PAGSEGURO_BOLETO_CODE = 'pagseguro_boleto'; + + const PAYMENT_METHOD_PAGSEGURO_ONLINE_DEBIT_CODE = 'pagseguro_oline_debit'; + /** * @var */ private $method; + + private $boletoMethod; /** * PaymentConfigProvider constructor. @@ -49,6 +56,9 @@ class PaymentConfigProvider implements \Magento\Checkout\Model\ConfigProviderInt public function __construct(PaymentHelper $helper) { $this->method = $helper->getMethodInstance(self::PAYMENT_METHOD_PAGSEGURO_CODE); + $this->boletoMethod = $helper->getMethodInstance(self::PAYMENT_METHOD_PAGSEGURO_BOLETO_CODE); + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $this->_library = $objectManager->create('\UOL\PagSeguro\Helper\Library'); } /** @@ -58,9 +68,16 @@ public function __construct(PaymentHelper $helper) */ public function getConfig() { + $this->_library->setEnvironment(); + $config = [ + 'library' => [ + 'session' => $this->_library->getSession(), + 'directPaymentJs' => $this->_library->getDirectPaymentUrl() + ], + 'brazilFlagPath' => $this->_library->getImageUrl('UOL_PagSeguro::images/flag-origin-country.png'), 'payment' => [ - self::PAYMENT_METHOD_PAGSEGURO_CODE => [ + 'pagseguro' => [ 'isDirect' => $this->method->isDirectCheckout(), 'isLightbox' => $this->method->isLightboxCheckoutType(), 'checkout' => [ @@ -69,7 +86,8 @@ public function getConfig() 'direct' => $this->method->getDirectCheckoutPaymentUrl() ] ] - ] + ], + 'pagseguro_boleto' => $this->boletoMethod->getStandardCheckoutPaymentUrl(), ]; return $config; } diff --git a/Model/PaymentCreditCard.php b/Model/PaymentCreditCard.php new file mode 100644 index 0000000..514ece6 --- /dev/null +++ b/Model/PaymentCreditCard.php @@ -0,0 +1,154 @@ +_cart = $cart; + } + + /** + * Assign data to info model instance + * + * @param \Magento\Framework\DataObject $data + * @return \Magento\Payment\Model\Info + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function assignData(\Magento\Framework\DataObject $data) + { + parent::assignData($data); + + $info = $this->getInfoInstance(); + if (isset($data->getData('additional_data')['credit_card_document'])) { + $info->setAdditionalInformation('credit_card_document', $data->getData('additional_data')['credit_card_document']); + } + + if (isset($data->getData('additional_data')['credit_card_hash'])) { + $info->setAdditionalInformation('hash', $data->getData('additional_data')['credit_card_hash']); + } + + if (isset($data->getData('additional_data')['credit_card_token'])) { + $info->setAdditionalInformation('credit_card_token', $data->getData('additional_data')['credit_card_token']); + } + + if (isset($data->getData('additional_data')['credit_card_holder_name'])) { + $info->setAdditionalInformation('credit_card_holder_name', $data->getData('additional_data')['credit_card_holder_name']); + } + + if (isset($data->getData('additional_data')['credit_card_holder_birthdate'])) { + $info->setAdditionalInformation('credit_card_holder_birthdate', $data->getData('additional_data')['credit_card_holder_birthdate']); + } + + if (isset($data->getData('additional_data')['credit_card_installment'])) { + $info->setAdditionalInformation('credit_card_installment', $data->getData('additional_data')['credit_card_installment']); + } + + if (isset($data->getData('additional_data')['credit_card_installment_value'])) { + $info->setAdditionalInformation('credit_card_installment_value', $data->getData('additional_data')['credit_card_installment_value']); + } + + return $this; + } + + /** + * Get standard checkout payment url + * + * @return url + */ + public function getStandardCheckoutPaymentUrl() + { + return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/payment/request/"); + } + + + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null){ + return true + && parent::isAvailable($quote); + } +} diff --git a/Model/PaymentDefaultlLightbox.php b/Model/PaymentDefaultlLightbox.php new file mode 100644 index 0000000..21307f0 --- /dev/null +++ b/Model/PaymentDefaultlLightbox.php @@ -0,0 +1,156 @@ +_cart = $cart; + } + + /** + * Check if checkout type is direct + * + * @return bool + */ + public function isDirectCheckout() + { +// if ($this->getConfigData('checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::DIRECT) { +// return true; +// } + return false; + } + + /** + * Check if checkout type is lightbox + * + * @return bool + */ + public function isLightboxCheckoutType() + { + if ($this->getConfigData('checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::LIGHTBOX) { + return true; + } + return false; + } + + /** + * Get lightbox checkout payment url + * + * @return url + */ + public function getLightboxCheckoutPaymentUrl() + { + return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/payment/checkout/"); + } + + /** + * Get standard checkout payment url + * + * @return url + */ + public function getStandardCheckoutPaymentUrl() + { + return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/payment/request/"); + } + + /** + * Get direct checkout payment url + * + * @return url + */ + public function getDirectCheckoutPaymentUrl() + { + return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/direct/payment"); + } + + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null){ + return true + && parent::isAvailable($quote); + } +} diff --git a/Model/PaymentMethod.php b/Model/PaymentMethod.php index f6ad591..d3c59a7 100644 --- a/Model/PaymentMethod.php +++ b/Model/PaymentMethod.php @@ -82,9 +82,11 @@ public function createPaymentRequest() { // Currency $this->_paymentRequest->setCurrency("BRL"); - // Order ID $this->_paymentRequest->setReference($this->getOrderStoreReference()); + // Cart discount + $lastRealOrder = $this->_checkoutSession->getLastRealOrder(); + $this->_paymentRequest->setExtraAmount(round($lastRealOrder->getDiscountAmount(), 2)); //Shipping $this->setShippingInformation(); $this->_paymentRequest->setShipping()->setType() diff --git a/Model/PaymentOnlineDebit.php b/Model/PaymentOnlineDebit.php new file mode 100644 index 0000000..bdb0418 --- /dev/null +++ b/Model/PaymentOnlineDebit.php @@ -0,0 +1,137 @@ +_cart = $cart; + } + + /** + * Assign data to info model instance + * + * @param \Magento\Framework\DataObject $data + * @return \Magento\Payment\Model\Info + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function assignData(\Magento\Framework\DataObject $data) + { + parent::assignData($data); + + $info = $this->getInfoInstance(); + if (isset($data->getData('additional_data')['online_debit_document'])) { + $info->setAdditionalInformation('online_debit_document', $data->getData('additional_data')['online_debit_document']); + } + + if (isset($data->getData('additional_data')['online_debit_hash'])) { + $info->setAdditionalInformation('hash', $data->getData('additional_data')['online_debit_hash']); + } + + if (isset($data->getData('additional_data')['online_debit_bank'])) { + $info->setAdditionalInformation('online_debit_bank', $data->getData('additional_data')['online_debit_bank']); + } + + return $this; + } + + /** + * Get standard checkout payment url + * + * @return url + */ + public function getStandardCheckoutPaymentUrl() + { + return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/payment/request/"); + } + + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null){ + return true + && parent::isAvailable($quote); + } +} diff --git a/Model/System/Config/Checkout.php b/Model/System/Config/Checkout.php index 370abf7..3d7c95d 100644 --- a/Model/System/Config/Checkout.php +++ b/Model/System/Config/Checkout.php @@ -43,10 +43,6 @@ class Checkout implements ArrayInterface * */ const LIGHTBOX = "lightbox"; - /** - * - */ - const DIRECT = "direct_payment"; /** * @return array of options @@ -55,8 +51,7 @@ public function toOptionArray() { return [ self::STANDARD => __('Padrão'), - self::LIGHTBOX => __('Lightbox'), - self::DIRECT => __('Checkout Transparente') + self::LIGHTBOX => __('Lightbox') ]; } } diff --git a/Model/Transactions/Methods/Abandoned.php b/Model/Transactions/Methods/Abandoned.php index 1742747..f3f0fab 100755 --- a/Model/Transactions/Methods/Abandoned.php +++ b/Model/Transactions/Methods/Abandoned.php @@ -60,6 +60,11 @@ class Abandoned extends Method */ protected $_scopeConfig; + /** + * @var \Magento\Framework\App\ResourceConnection + */ + protected $_resource; + /** * @var \Magento\Sales\Model\ResourceModel\Grid */ @@ -101,6 +106,7 @@ class Abandoned extends Method */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface, + \Magento\Framework\App\ResourceConnection $resourceConnection, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Backend\Model\Session $session, @@ -112,6 +118,8 @@ public function __construct( ) { /** @var \Magento\Framework\App\Config\ScopeConfigInterface _scopeConfig */ $this->_scopeConfig = $scopeConfigInterface; + /** @var Magento\Framework\App\ResourceConnection _resource */ + $this->_resource = $resourceConnection; /** @var \Magento\Backend\Model\Session _session */ $this->_session = $session; /** @var \Magento\Sales\Model\Order _order */ @@ -182,7 +190,7 @@ public function request() $order = \UOL\PagSeguro\Helper\Data::getReferenceDecryptOrderID($payment->getReference()); $order = $this->_order->load($order); if ($this->getStoreReference() == \UOL\PagSeguro\Helper\Data::getReferenceDecrypt( - $payment->getReference()) + $payment->getReference()) ) { if (!is_null($this->_session->getData('store_id'))) { array_push($this->_arrayPayments, $this->build($payment, $order)); diff --git a/Model/Transactions/Methods/Cancellation.php b/Model/Transactions/Methods/Cancellation.php index 797e2df..c13bac2 100755 --- a/Model/Transactions/Methods/Cancellation.php +++ b/Model/Transactions/Methods/Cancellation.php @@ -53,6 +53,11 @@ class Cancellation extends Method */ protected $_scopeConfig; + /** + * @var \Magento\Framework\App\ResourceConnection + */ + protected $_resource; + /** * @var \Magento\Sales\Model\ResourceModel\Grid */ @@ -89,6 +94,7 @@ class Cancellation extends Method */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface, + \Magento\Framework\App\ResourceConnection $resourceConnection, \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Backend\Model\Session $session, \Magento\Sales\Model\Order $order, @@ -98,6 +104,8 @@ public function __construct( ) { /** @var \Magento\Framework\App\Config\ScopeConfigInterface _scopeConfig */ $this->_scopeConfig = $scopeConfigInterface; + /** @var \Magento\Framework\App\ResourceConnection _resource */ + $this->_resource = $resourceConnection; /** @var \Magento\Backend\Model\Session _session */ $this->_session = $session; /** @var \Magento\Sales\Model\Order _order */ diff --git a/Model/Transactions/Methods/Conciliation.php b/Model/Transactions/Methods/Conciliation.php index 249bab3..5e7781f 100755 --- a/Model/Transactions/Methods/Conciliation.php +++ b/Model/Transactions/Methods/Conciliation.php @@ -94,6 +94,7 @@ class Conciliation extends Method */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface, + \Magento\Framework\App\ResourceConnection $resourceConnection, \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Backend\Model\Session $session, \Magento\Sales\Model\Order $order, @@ -105,6 +106,8 @@ public function __construct( $this->_scopeConfig = $scopeConfigInterface; /** @var \Magento\Backend\Model\Session _session */ $this->_session = $session; + /** @var \Magento\Framework\App\ResourceConnection _resource */ + $this->_resource = $resourceConnection; /** @var \Magento\Sales\Model\Order _order */ $this->_order = $order; /** @var \UOL\PagSeguro\Helper\Library _library */ diff --git a/Model/Transactions/Methods/Refund.php b/Model/Transactions/Methods/Refund.php index 08eb861..25eaf18 100755 --- a/Model/Transactions/Methods/Refund.php +++ b/Model/Transactions/Methods/Refund.php @@ -53,6 +53,11 @@ class Refund extends Method */ protected $_scopeConfig; + /** + * @var \Magento\Framework\App\ResourceConnection + */ + protected $_resource; + /** * @var \Magento\Sales\Model\ResourceModel\Grid */ @@ -89,6 +94,7 @@ class Refund extends Method */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface, + \Magento\Framework\App\ResourceConnection $resourceConnection, \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Backend\Model\Session $session, \Magento\Sales\Model\Order $order, @@ -98,6 +104,9 @@ public function __construct( ) { /** @var \Magento\Framework\App\Config\ScopeConfigInterface _scopeConfig */ $this->_scopeConfig = $scopeConfigInterface; + /** @var \Magento\Framework\App\ResourceConnection _resource */ + $this->_resource = $resourceConnection; + /** @var \Magento\Backend\Model\Session _session */ $this->_session = $session; /** @var \Magento\Sales\Model\Order _order */ diff --git a/README.md b/README.md index e5556eb..84d236d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Com o módulo instalado e configurado, você pode pode oferecer o PagSeguro como Requisitos ---------- --- - - [Magento] Community 2.0 | 2.1 + - [Magento] Community 2.0.8 | 2.1.0 até a versão 2.1.9 - [PHP] 5.5.0+ - [SPL] - [cURL] @@ -25,32 +25,103 @@ Requisitos Instalação ----------- +> É altamente recomendado que você tenha um ambiente de testes para validar alterações e atualizações antes de atualizar sua loja em produção. É recomendado também que seja feito um **backup** da sua loja e informações importantes antes de executar qualquer procedimento de atualização/instalação. + Navegue até o diretório raíz da sua instalação do Magento 2 e siga os seguintes passos: +> A instalação do módulo é feita utilizando o Composer. Para baixar e instalar o Composer no seu ambiente acesse https://getcomposer.org/download/ e caso tenha dúvidas de como utilizá-lo consulte a [documentação oficial do Composer](https://getcomposer.org/doc/). + 1. Instale via packagist - ```composer require pagseguro/magento2``` - Neste momento, podem ser solicitadas suas credenciais de autenticação do Magento. Caso tenha alguma dúvida, há uma descrição de como proceder nesse [link da documentação oficial](http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html). 2. Execute os comandos: - ```php bin/magento setup:upgrade``` - ```php bin/magento setup:static-content:deploy``` ou ```php bin/magento setup:static-content:deploy pt_BR```, de acordo com as configurações da sua loja. -3. Dê permissões as pastas var/ pub/ +3. Cheque e, caso necessário, configure as permissões corretas para seus diretórios. Por exemplo, para configrar a permissão 777 para as pastas var/ pub/ execute: - ```chmod 777 -R var/ pub/``` +4. Pode ser necessário atualizar o cache da sua loja ao finalizar o processo. +5. Acesse a seção do PagSeguro através da interface administrativa da sua loja e configure suas credenciais e meios de pagamento. Atualização ----------- -É altamente recomendado que você tenha um ambiente de testes para validar alterações e atualizações antes de atualizar sua loja em produção. É recomendado também que seja feito um **backup** da sua loja e informações importantes antes de executar qualquer procedimento de atualização/instalação. +> É altamente recomendado que você tenha um ambiente de testes para validar alterações e atualizações antes de atualizar sua loja em produção. É recomendado também que seja feito um **backup** da sua loja e informações importantes antes de executar qualquer procedimento de atualização/instalação. A atualização do módulo do PagSeguro é feita através do **composer** e pode ser feita de diversas maneiras, de acordo com suas preferências. Uma forma é através dos comandos: 1. ```composer update pagseguro/magento2``` 2. ```composer update pagseguro/pagseguro-php-sdk``` 3. ```php bin/magento setup:upgrade``` 4. ```php bin/magento setup:static-content:deploy``` ou ```php bin/magento setup:static-content:deploy pt_BR```, de acordo com as configurações da sua loja. +5. Cheque e, caso necessário, configure as permissões corretas para seus diretórios. +6. Pode ser necessário atualizar o cache da sua loja ao finalizar o processo. +5. Acesse a seção do PagSeguro através da interface administrativa da sua loja, confira as informações e configurações do PagSeguro e seus meios de pagamento e clique no botão para salvar. **Observações** - Em alguns casos, o Magento não atualiza os arquivos estáticos gerados, podendo ser necessário atualizar os mesmos via interface administrativa, comandos do terminal ou removendo diretamente conteúdo da pasta *pub/static/frontend/Magento/seu_tema/seu_idioma/UOL_PagSeguro*. - Em seguida, executar novamente o comando ```php bin/magento setup:static-content:deploy``` ou ```bin/magento setup:static-content:deploy pt_BR```, de acordo com as configurações da sua loja. +Configuração +------------ +--- +Para acessar e configurar o módulo acesse o menu PagSeguro -> Configurações. As opções disponíveis estão descritas abaixo. + + ------------------------- + **Configurações Gerais** + + - **ambiente**: especifica em que ambiente as transações serão feitas *(produção/sandbox)*. + - **e-mail**: e-mail cadastrado no PagSeguro. + - **token**: token cadastrado no PagSeguro. + - **url de redirecionamento**: ao final do fluxo de pagamento no PagSeguro, seu cliente será redirecionado automaticamente para a página de confirmação em sua loja ou então para a URL que você informar neste campo. Para ativar o redirecionamento ao final do pagamento é preciso ativar o serviço de [Pagamentos via API]. Obs.: Esta URL é informada automaticamente e você só deve alterá-la caso deseje que seus clientes sejam redirecionados para outro local. + - **url de notificação**: sempre que uma transação mudar de status, o PagSeguro envia uma notificação para sua loja. **O valor padrão que deve ser utilizado pelo módulo é: http://www.minhaloja.com.br/index.php/pagseguro/notification/response** + - *Observação: Esta URL só deve ser alterada caso você deseje receber as notificações em outro local.* + - **charset**: codificação do seu sistema (ISO-8859-1 ou UTF-8). + - **ativar log**: ativa/desativa a geração de logs. + - **diretório**: informe o local e nome do arquivo a partir da raíz de instalação do Magento onde se deseja criar o arquivo de log. Ex.: var/log/pagseguro.log. + - *Por padrão o módulo virá configurado para salvar o arquivo de log em var/log/pagseguro.log*. + - **listar transações abandonadas?**: ativa/desativa a pesquisa de transações que foram abandonadas no checkout do PagSeguro. + - **transações -> abandonadas**: permite consultar as transações que foram abandonadas nos últimos 10 dias, desta forma você pode enviar emails de recuperação de venda. O e-mail conterá um link que redirecionará o comprador para o fluxo de pagamento, exatamente no ponto onde ele parou. + - **listar parcelamento**: Habilita a exibição de uma listagem de parcelas na tela de visualização do produto. (Irá exibir o maior parcelamento disponível para o produto na tela de exibição do mesmo) + + ------------------------- + **Configurar Tipos de Checkout** + Nesta seção você irá configurar os meios de pagamento do PagSeguro que deseja disponibilizar na sua loja. + > Consulte na sua conta do PagSeguro os meios de pagamento que estão habilitados. + + - *PagSeguro (Padrão ou Lightbox)* + - **ativar**: ativa/desativa o meio de pagamento PagSeguro (padrão ou lightbox). + - **checkout**: especifica o modelo de checkout que será utilizado. É possível escolher entre checkout padrão ou checkout lightbox. + - **nome de exibição**: define o nome que será utilizado para o meio de pagamento na tela de checkout. + - **posição na tela de checkout (Sort Order)**: Configura a ordem de exibição deste meio de pagamento na sua loja. Esta ordem é relativa à todos os outros meios de pagamento configurados na sua loja. + + - *Checkout Transparente - Cartão de Crédito* + - **ativar**: ativa/desativa o meio de pagamento Checkout Transparente - Cartão de Crédito. + - **nome de exibição**: define o nome que será utilizado para esse meio de pagamento na tela de checkout. + - **posição na tela de checkout (Sort Order)**: Configura a ordem de exibição deste meio de pagamento na sua loja. Esta ordem é relativa à todos os outros meios de pagamento configurados na sua loja. + + + - *Checkout Transparente - Boleto Bancário* + - **ativar**: ativa/desativa o meio de pagamento Checkout Transparente - Boleto Bancário. + - **nome de exibição**: define o nome que será utilizado para esse meio de pagamento na tela de checkout. + - **posição na tela de checkout (Sort Order)**: Configura a ordem de exibição deste meio de pagamento na sua loja. Esta ordem é relativa à todos os outros meios de pagamento configurados na sua loja. + + + - *Checkout Transparente - Débito Online* + - **ativar**: ativa/desativa o meio de pagamento Checkout Transparente - Débito Online. + - **nome de exibição**: define o nome que será utilizado para esse meio de pagamento na tela de checkout. + - **posição na tela de checkout (Sort Order)**: Configura a ordem de exibição deste meio de pagamento na sua loja. Esta ordem é relativa à todos os outros meios de pagamento configurados na sua loja. + + + Transações +------------ +--- + Para realizar consultas e outras operações acesse o menu PagSeguro -> *Transação*, onde *Transação* pode ser escolhida as opções: Conciliação, Abandonadas, Cancelamento, Estorno. As opções disponíveis estão descritas abaixo: + + - **abandonadas**: permite pesquisar as transações que foram abandonadas dentro da quantidade de dias definidos para a pesquisa. + - **cancelamento**: esta pesquisa retornará todas as transações que estejam com status "em análise" e "aguardando pagamento", dentro da quantidade de dias definidos para a pesquisa. Desta forma você pode solicitar o cancelamento destas transações. + - **conciliação**: permite consultar as transações efetivadas no PagSeguro nos últimos 30 dias. A pesquisa retornará um comparativo com o status das transações em sua base local e o status atual da transação no PagSeguro, desta forma você pode identificar e atualizar transações com status divergentes. + - **estorno**: esta pesquisa retornará todas as transações que estejam com status "paga", "disponível" e "em disputa", dentro da quantidade de dias definidos para a pesquisa. Desta forma você pode solicitar o estorno dos valores pagos para seus compradores. + + > É aconselhável que antes de usar as funcionalidades de **estorno** ou **cancelamento** você faça a **conciliação** de suas transações para obter os status mais atuais. Inputs --------- @@ -80,6 +151,11 @@ Caso tenha dúvidas ou precise de suporte, acesse nosso [fórum]. Changelog --------- +1.4.0 +- Alterado o fluxo do checkout transparente (na própria tela de checkout do Magento) +- Alterada a forma de configurar o módulo e os meios de pagamento do PagSeguro, que agora são configurados individualmente. +- Melhorias gerais e correções de bugs: transações do admin, css muito abrangente, remoção de arquivos velhos e desnecessários, refatorações. + 1.3.0 - Adicionada validação e mensagens de erro (frontend) nos formulários do checkout transparente diff --git a/etc/acl.xml b/etc/acl.xml index f424424..b423ff9 100755 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -1,11 +1,13 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 5ecf53d..c9ea11b 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -25,76 +25,12 @@
- - - - - - UOL\PagSeguro\Model\System\Config\Yesno - - - - Informe o nome que deve ser apresentado para este meio de pagamento no checkout de sua loja. - - - - Define o ambiente de uso - UOL\PagSeguro\Model\System\Config\Environment - - - - Clique <a href="https://pagseguro.uol.com.br/registration/registration.jhtml?ep=7&tipo=cadastro#!vendedor" target="_blank">aqui</a> e cadastre-se grátis. - - - - Acesse sua conta PagSeguro ou Sandbox para obter um token. - - - - Ao final do fluxo de pagamento no PagSeguro, seu cliente será redirecionado de volta para sua loja ou para a URL que você informar neste campo. Para utilizar essa funcionalidade você deve acessar sua conta PagSeguro ou Sandbox e habilitar requisições de pagamentos gerados somente via API. - - - - Sempre que uma transação mudar de status, o PagSeguro envia uma notificação para sua loja ou para a URL que você informar neste campo. - - - - Defina o charset de acordo com a codificação do seu sistema. - UOL\PagSeguro\Model\System\Config\Charset - - - - UOL\PagSeguro\Model\System\Config\Yesno - - - - - 1 - - - Nome do arquivo de log a ser utilizado, com caminho relativo ou absoluto, que tenha permissões de leitura e escrita (Ex.: var/log/pagseguro.log). - - - Para que ocorra normalmente a geração de logs é estritamente necessário que o diretório e o arquivo de log configurados tenham permissões de leitura e escrita. - - - - - Selecione o tipo de checkout desejado. - UOL\PagSeguro\Model\System\Config\Checkout - - - - - UOL\PagSeguro\Model\System\Config\Yesno - - - - Ativar a exibição da listagem de parcelas na tela de visualização do produto. (Irá exibir o maior parcelamento disponível para o produto no pagamento com cartão de crédito) - UOL\PagSeguro\Model\System\Config\Yesno - - + + + +
diff --git a/etc/adminhtml/system/general_configuration.xml b/etc/adminhtml/system/general_configuration.xml new file mode 100644 index 0000000..c172cfa --- /dev/null +++ b/etc/adminhtml/system/general_configuration.xml @@ -0,0 +1,71 @@ + + + + + + + Define o ambiente de uso + UOL\PagSeguro\Model\System\Config\Environment + payment/pagseguro/environment + + + + Clique <a href="https://pagseguro.uol.com.br/registration/registration.jhtml?ep=7&tipo=cadastro#!vendedor" target="_blank">aqui</a> e cadastre-se grátis. + payment/pagseguro/email + required-entry validate-email + + + + Acesse sua conta PagSeguro ou Sandbox para obter um token. + payment/pagseguro/token + required-entry + + + + Ao final do fluxo de pagamento no PagSeguro, seu cliente será redirecionado de volta para sua loja ou para a URL que você informar neste campo. Para utilizar essa funcionalidade você deve acessar sua conta PagSeguro ou Sandbox e habilitar requisições de pagamentos gerados somente via API. + payment/pagseguro/redirect + + + + Sempre que uma transação mudar de status, o PagSeguro envia uma notificação para sua loja ou para a URL que você informar neste campo. + payment/pagseguro/notification + + + + Defina o charset de acordo com a codificação do seu sistema. + UOL\PagSeguro\Model\System\Config\Charset + payment/pagseguro/charset + + + + UOL\PagSeguro\Model\System\Config\Yesno + payment/pagseguro/log + + + + + 1 + + + Nome do arquivo de log a ser utilizado, com caminho relativo ou absoluto, que tenha permissões de leitura e escrita (Ex.: var/log/pagseguro.log). + + + Para que ocorra normalmente a geração de logs é estritamente necessário que o diretório e o arquivo de log configurados tenham permissões de leitura e escrita. + + payment/pagseguro/log_file + + + + Deseja habilitar o módulo? + UOL\PagSeguro\Model\System\Config\Yesno + payment/pagseguro/abandoned_active + + + + Ativar a exibição da listagem de parcelas na tela de visualização do produto. (Irá exibir o maior parcelamento disponível para o produto no pagamento com cartão de crédito) + UOL\PagSeguro\Model\System\Config\Yesno + payment/pagseguro/installments + + + diff --git a/etc/adminhtml/system/payment_boleto.xml b/etc/adminhtml/system/payment_boleto.xml new file mode 100644 index 0000000..04b1590 --- /dev/null +++ b/etc/adminhtml/system/payment_boleto.xml @@ -0,0 +1,30 @@ + + + + + + + UOL\PagSeguro\Model\System\Config\Yesno + payment/pagseguro_boleto/active + + + + Informe o nome que deve ser apresentado para este meio de pagamento no checkout de sua loja. + payment/pagseguro_boleto/title + + 1 + + required-entry + + + + Irá aparecer depois de todos os meios de pagamento configurados na sua loja com valor menor e antes dos de valor maior. + payment/pagseguro_boleto/sort_order + validate-zero-or-greater + 1 + + 1 + + + + diff --git a/etc/adminhtml/system/payment_configuration.xml b/etc/adminhtml/system/payment_configuration.xml new file mode 100644 index 0000000..3a44e8a --- /dev/null +++ b/etc/adminhtml/system/payment_configuration.xml @@ -0,0 +1,12 @@ + + + + + Configure nesta seção os meios de pagamento do PagSeguro que deseja disponibilizar em sua loja. + + + + + + diff --git a/etc/adminhtml/system/payment_credit_card.xml b/etc/adminhtml/system/payment_credit_card.xml new file mode 100644 index 0000000..086b182 --- /dev/null +++ b/etc/adminhtml/system/payment_credit_card.xml @@ -0,0 +1,30 @@ + + + + + + + UOL\PagSeguro\Model\System\Config\Yesno + payment/pagseguro_credit_card/active + + + + Informe o nome que deve ser apresentado para este meio de pagamento no checkout de sua loja. + payment/pagseguro_credit_card/title + + 1 + + required-entry + + + + Irá aparecer depois de todos os meios de pagamento configurados na sua loja com valor menor e antes dos de valor maior. + payment/pagseguro_credit_card/sort_order + validate-zero-or-greater + 1 + + 1 + + + + diff --git a/etc/adminhtml/system/payment_default_lightbox.xml b/etc/adminhtml/system/payment_default_lightbox.xml new file mode 100644 index 0000000..79fcb3c --- /dev/null +++ b/etc/adminhtml/system/payment_default_lightbox.xml @@ -0,0 +1,39 @@ + + + + + + + UOL\PagSeguro\Model\System\Config\Yesno + payment/pagseguro_default_lightbox/active + + + + Selecione o tipo de checkout desejado. + UOL\PagSeguro\Model\System\Config\Checkout + payment/pagseguro_default_lightbox/checkout + + 1 + + + + + Informe o nome que deve ser apresentado para este meio de pagamento no checkout de sua loja. + payment/pagseguro_default_lightbox/title + + 1 + + required-entry + + + + Irá aparecer depois de todos os meios de pagamento configurados na sua loja com valor menor e antes dos de valor maior. + payment/pagseguro_default_lightbox/sort_order + validate-zero-or-greater + 1 + + 1 + + + + diff --git a/etc/adminhtml/system/payment_online_debit.xml b/etc/adminhtml/system/payment_online_debit.xml new file mode 100644 index 0000000..71c3f3c --- /dev/null +++ b/etc/adminhtml/system/payment_online_debit.xml @@ -0,0 +1,30 @@ + + + + + + + UOL\PagSeguro\Model\System\Config\Yesno + payment/pagseguro_online_debit/active + + + + Informe o nome que deve ser apresentado para este meio de pagamento no checkout de sua loja. + payment/pagseguro_online_debit/title + + 1 + + required-entry + + + + Irá aparecer depois de todos os meios de pagamento configurados na sua loja com valor menor e antes dos de valor maior. + payment/pagseguro_online_debit/sort_order + validate-zero-or-greater + 1 + + 1 + + + + diff --git a/etc/config.xml b/etc/config.xml index 8e17bcb..db09674 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,7 +1,7 @@ - - - - - - - - - - - - diff --git a/view/frontend/templates/checkout.phtml b/view/frontend/templates/checkout.phtml index 75103a9..f7de6e3 100644 --- a/view/frontend/templates/checkout.phtml +++ b/view/frontend/templates/checkout.phtml @@ -11,7 +11,7 @@ window.location.href = "getUrl('checkout/onepage/success', array('_secure' => true));?>"; }, abort: function(){ - window.location.href = 'getBaseUrl(); ?>'; + window.location.href = 'getUrl('pagseguro/payment/cancel'); ?>'; } }); } diff --git a/view/frontend/templates/direct/payment.phtml b/view/frontend/templates/direct/payment.phtml deleted file mode 100644 index d8e61ca..0000000 --- a/view/frontend/templates/direct/payment.phtml +++ /dev/null @@ -1,772 +0,0 @@ -
-

Formas de pagamento

-

Escolha o método

- -
-
-

Cartão de Crédito

-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
-
-
- - -
-
- - -
-
-
-
-
- -
- - -
-
- - -
- Esta compra está sendo feita no Brasil -
- -
-
-
-

Débito On-line

-
-
- -
- - -
-
-
- - -
- - - - -
-
-
- Esta compra está sendo feita no Brasil -
- -
-
-
-

Boleto

-
-
- -
- - -
-
-
- Esta compra está sendo feita no Brasil -
- -
-
    -
  • Imprima o boleto e pague no banco
  • -
  • Ou pague pela internet utilizando o código de barras do boleto
  • -
  • O prazo de validade do boleto é de 1 dia útil
  • -
-
-
-
- - - - - - - - - - diff --git a/view/frontend/templates/success.phtml b/view/frontend/templates/success.phtml index 7edd5cf..e58bc58 100644 --- a/view/frontend/templates/success.phtml +++ b/view/frontend/templates/success.phtml @@ -24,33 +24,33 @@ getAdditionalInfoHtml() ?> getPaymentType()): - case 'uol\pagseguro\controller\direct\debit':?> - getPaymentLink())): ?> -
-
- -
-
- - - - - getPaymentLink())): ?> -
-
- -
-
- - - - -
-
- -
-
- + case 'pagseguro_online_debit':?> + getPaymentLink())): ?> +
+
+ +
+
+ + + + + getPaymentLink())): ?> +
+
+ +
+
+ + + + +
+
+ +
+
+ diff --git a/view/frontend/web/css/styles.css b/view/frontend/web/css/styles.css index 067cb29..d68b224 100644 --- a/view/frontend/web/css/styles.css +++ b/view/frontend/web/css/styles.css @@ -1,763 +1,92 @@ -button { +#payment-method-pagseguro button { overflow: visible; } -button, -select { +#payment-method-pagseguro button, +#payment-method-pagseguro select { text-transform: none; } -button, -html input[type="button"], -input[type="reset"], -input[type="submit"] { +#payment-method-pagseguro button { -webkit-appearance: button; cursor: pointer; } -button[disabled], -html input[disabled] { - cursor: default; -} -button::-moz-focus-inner, -input::-moz-focus-inner { +#payment-method-pagseguro button::-moz-focus-inner, +#payment-method-pagseguro input::-moz-focus-inner { border: 0; padding: 0; } -input { +#payment-method-pagseguro input { line-height: normal; } -input[type="checkbox"], -input[type="radio"] { +#payment-method-pagseguro input[type="radio"] { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0; } -input[type="number"]::-webkit-inner-spin-button, -input[type="number"]::-webkit-outer-spin-button { - height: auto; -} -input[type="search"] { - -webkit-appearance: textfield; - -webkit-box-sizing: content-box; - -moz-box-sizing: content-box; - box-sizing: content-box; -} -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} - -.row { +#payment-method-pagseguro .row { margin-left: -15px; margin-right: -15px; } -.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { +#payment-method-pagseguro .col-sm-2, #payment-method-pagseguro .col-sm-5, #payment-method-pagseguro .col-sm-6, #payment-method-pagseguro .col-md-8, #payment-method-pagseguro .col-sm-10, #payment-method-pagseguro .col-xs-12 { position: relative; min-height: 1px; padding-left: 15px; padding-right: 15px; } -.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 { +#payment-method-pagseguro .col-xs-12 { float: left; } -.col-xs-12 { +#payment-method-pagseguro .col-xs-12 { width: 100%; } -.col-xs-11 { - width: 91.66666667%; -} -.col-xs-10 { - width: 83.33333333%; -} -.col-xs-9 { - width: 75%; -} -.col-xs-8 { - width: 66.66666667%; -} -.col-xs-7 { - width: 58.33333333%; -} -.col-xs-6 { - width: 50%; -} -.col-xs-5 { - width: 41.66666667%; -} -.col-xs-4 { - width: 33.33333333%; -} -.col-xs-3 { - width: 25%; -} -.col-xs-2 { - width: 16.66666667%; -} -.col-xs-1 { - width: 8.33333333%; -} -.col-xs-pull-12 { - right: 100%; -} -.col-xs-pull-11 { - right: 91.66666667%; -} -.col-xs-pull-10 { - right: 83.33333333%; -} -.col-xs-pull-9 { - right: 75%; -} -.col-xs-pull-8 { - right: 66.66666667%; -} -.col-xs-pull-7 { - right: 58.33333333%; -} -.col-xs-pull-6 { - right: 50%; -} -.col-xs-pull-5 { - right: 41.66666667%; -} -.col-xs-pull-4 { - right: 33.33333333%; -} -.col-xs-pull-3 { - right: 25%; -} -.col-xs-pull-2 { - right: 16.66666667%; -} -.col-xs-pull-1 { - right: 8.33333333%; -} -.col-xs-pull-0 { - right: auto; -} -.col-xs-push-12 { - left: 100%; -} -.col-xs-push-11 { - left: 91.66666667%; -} -.col-xs-push-10 { - left: 83.33333333%; -} -.col-xs-push-9 { - left: 75%; -} -.col-xs-push-8 { - left: 66.66666667%; -} -.col-xs-push-7 { - left: 58.33333333%; -} -.col-xs-push-6 { - left: 50%; -} -.col-xs-push-5 { - left: 41.66666667%; -} -.col-xs-push-4 { - left: 33.33333333%; -} -.col-xs-push-3 { - left: 25%; -} -.col-xs-push-2 { - left: 16.66666667%; -} -.col-xs-push-1 { - left: 8.33333333%; -} -.col-xs-push-0 { - left: auto; -} -.col-xs-offset-12 { - margin-left: 100%; -} -.col-xs-offset-11 { - margin-left: 91.66666667%; -} -.col-xs-offset-10 { - margin-left: 83.33333333%; -} -.col-xs-offset-9 { - margin-left: 75%; -} -.col-xs-offset-8 { - margin-left: 66.66666667%; -} -.col-xs-offset-7 { - margin-left: 58.33333333%; -} -.col-xs-offset-6 { - margin-left: 50%; -} -.col-xs-offset-5 { - margin-left: 41.66666667%; -} -.col-xs-offset-4 { - margin-left: 33.33333333%; -} -.col-xs-offset-3 { - margin-left: 25%; -} -.col-xs-offset-2 { - margin-left: 16.66666667%; -} -.col-xs-offset-1 { - margin-left: 8.33333333%; -} -.col-xs-offset-0 { - margin-left: 0%; -} @media (min-width: 768px) { - .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { + #payment-method-pagseguro .col-sm-2, #payment-method-pagseguro .col-sm-5, #payment-method-pagseguro .col-sm-6, #payment-method-pagseguro .col-sm-10 { float: left; } - .col-sm-12 { - width: 100%; - } - .col-sm-11 { - width: 91.66666667%; - } - .col-sm-10 { + #payment-method-pagseguro .col-sm-10 { width: 83.33333333%; } - .col-sm-9 { - width: 75%; - } - .col-sm-8 { - width: 66.66666667%; - } - .col-sm-7 { - width: 58.33333333%; - } - .col-sm-6 { + #payment-method-pagseguro .col-sm-6 { width: 50%; } - .col-sm-5 { + #payment-method-pagseguro .col-sm-5 { width: 41.66666667%; } - .col-sm-4 { - width: 33.33333333%; - } - .col-sm-3 { - width: 25%; - } - .col-sm-2 { + #payment-method-pagseguro .col-sm-2 { width: 16.66666667%; } - .col-sm-1 { - width: 8.33333333%; - } - .col-sm-pull-12 { - right: 100%; - } - .col-sm-pull-11 { - right: 91.66666667%; - } - .col-sm-pull-10 { - right: 83.33333333%; - } - .col-sm-pull-9 { - right: 75%; - } - .col-sm-pull-8 { - right: 66.66666667%; - } - .col-sm-pull-7 { - right: 58.33333333%; - } - .col-sm-pull-6 { - right: 50%; - } - .col-sm-pull-5 { - right: 41.66666667%; - } - .col-sm-pull-4 { - right: 33.33333333%; - } - .col-sm-pull-3 { - right: 25%; - } - .col-sm-pull-2 { - right: 16.66666667%; - } - .col-sm-pull-1 { - right: 8.33333333%; - } - .col-sm-pull-0 { - right: auto; - } - .col-sm-push-12 { - left: 100%; - } - .col-sm-push-11 { - left: 91.66666667%; - } - .col-sm-push-10 { - left: 83.33333333%; - } - .col-sm-push-9 { - left: 75%; - } - .col-sm-push-8 { - left: 66.66666667%; - } - .col-sm-push-7 { - left: 58.33333333%; - } - .col-sm-push-6 { - left: 50%; - } - .col-sm-push-5 { - left: 41.66666667%; - } - .col-sm-push-4 { - left: 33.33333333%; - } - .col-sm-push-3 { - left: 25%; - } - .col-sm-push-2 { - left: 16.66666667%; - } - .col-sm-push-1 { - left: 8.33333333%; - } - .col-sm-push-0 { - left: auto; - } - .col-sm-offset-12 { - margin-left: 100%; - } - .col-sm-offset-11 { - margin-left: 91.66666667%; - } - .col-sm-offset-10 { - margin-left: 83.33333333%; - } - .col-sm-offset-9 { - margin-left: 75%; - } - .col-sm-offset-8 { - margin-left: 66.66666667%; - } - .col-sm-offset-7 { - margin-left: 58.33333333%; - } - .col-sm-offset-6 { - margin-left: 50%; - } - .col-sm-offset-5 { - margin-left: 41.66666667%; - } - .col-sm-offset-4 { - margin-left: 33.33333333%; - } - .col-sm-offset-3 { - margin-left: 25%; - } - .col-sm-offset-2 { - margin-left: 16.66666667%; - } - .col-sm-offset-1 { + #payment-method-pagseguro .col-sm-offset-1 { margin-left: 8.33333333%; } - .col-sm-offset-0 { - margin-left: 0%; - } } @media (min-width: 992px) { - .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { - float: left; - } - .col-md-12 { - width: 100%; - } - .col-md-11 { - width: 91.66666667%; - } - .col-md-10 { - width: 83.33333333%; - } - .col-md-9 { - width: 75%; - } - .col-md-8 { - width: 66.66666667%; - } - .col-md-7 { - width: 58.33333333%; - } - .col-md-6 { - width: 50%; - } - .col-md-5 { - width: 41.66666667%; - } - .col-md-4 { - width: 33.33333333%; - } - .col-md-3 { - width: 25%; - } - .col-md-2 { - width: 16.66666667%; - } - .col-md-1 { - width: 8.33333333%; - } - .col-md-pull-12 { - right: 100%; - } - .col-md-pull-11 { - right: 91.66666667%; - } - .col-md-pull-10 { - right: 83.33333333%; - } - .col-md-pull-9 { - right: 75%; - } - .col-md-pull-8 { - right: 66.66666667%; - } - .col-md-pull-7 { - right: 58.33333333%; - } - .col-md-pull-6 { - right: 50%; - } - .col-md-pull-5 { - right: 41.66666667%; - } - .col-md-pull-4 { - right: 33.33333333%; - } - .col-md-pull-3 { - right: 25%; - } - .col-md-pull-2 { - right: 16.66666667%; - } - .col-md-pull-1 { - right: 8.33333333%; - } - .col-md-pull-0 { - right: auto; - } - .col-md-push-12 { - left: 100%; - } - .col-md-push-11 { - left: 91.66666667%; - } - .col-md-push-10 { - left: 83.33333333%; - } - .col-md-push-9 { - left: 75%; - } - .col-md-push-8 { - left: 66.66666667%; - } - .col-md-push-7 { - left: 58.33333333%; - } - .col-md-push-6 { - left: 50%; - } - .col-md-push-5 { - left: 41.66666667%; - } - .col-md-push-4 { - left: 33.33333333%; - } - .col-md-push-3 { - left: 25%; - } - .col-md-push-2 { - left: 16.66666667%; - } - .col-md-push-1 { - left: 8.33333333%; - } - .col-md-push-0 { - left: auto; - } - .col-md-offset-12 { - margin-left: 100%; - } - .col-md-offset-11 { - margin-left: 91.66666667%; - } - .col-md-offset-10 { - margin-left: 83.33333333%; - } - .col-md-offset-9 { - margin-left: 75%; - } - .col-md-offset-8 { - margin-left: 66.66666667%; - } - .col-md-offset-7 { - margin-left: 58.33333333%; - } - .col-md-offset-6 { - margin-left: 50%; - } - .col-md-offset-5 { - margin-left: 41.66666667%; - } - .col-md-offset-4 { - margin-left: 33.33333333%; - } - .col-md-offset-3 { - margin-left: 25%; - } - .col-md-offset-2 { - margin-left: 16.66666667%; - } - .col-md-offset-1 { - margin-left: 8.33333333%; - } - .col-md-offset-0 { - margin-left: 0%; - } -} -@media (min-width: 1200px) { - .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 { + #payment-method-pagseguro .col-md-8 { float: left; } - .col-lg-12 { - width: 100%; - } - .col-lg-11 { - width: 91.66666667%; - } - .col-lg-10 { - width: 83.33333333%; - } - .col-lg-9 { - width: 75%; - } - .col-lg-8 { + #payment-method-pagseguro .col-md-8 { width: 66.66666667%; } - .col-lg-7 { - width: 58.33333333%; - } - .col-lg-6 { - width: 50%; - } - .col-lg-5 { - width: 41.66666667%; - } - .col-lg-4 { - width: 33.33333333%; - } - .col-lg-3 { - width: 25%; - } - .col-lg-2 { - width: 16.66666667%; - } - .col-lg-1 { - width: 8.33333333%; - } - .col-lg-pull-12 { - right: 100%; - } - .col-lg-pull-11 { - right: 91.66666667%; - } - .col-lg-pull-10 { - right: 83.33333333%; - } - .col-lg-pull-9 { - right: 75%; - } - .col-lg-pull-8 { - right: 66.66666667%; - } - .col-lg-pull-7 { - right: 58.33333333%; - } - .col-lg-pull-6 { - right: 50%; - } - .col-lg-pull-5 { - right: 41.66666667%; - } - .col-lg-pull-4 { - right: 33.33333333%; - } - .col-lg-pull-3 { - right: 25%; - } - .col-lg-pull-2 { - right: 16.66666667%; - } - .col-lg-pull-1 { - right: 8.33333333%; - } - .col-lg-pull-0 { - right: auto; - } - .col-lg-push-12 { - left: 100%; - } - .col-lg-push-11 { - left: 91.66666667%; - } - .col-lg-push-10 { - left: 83.33333333%; - } - .col-lg-push-9 { - left: 75%; - } - .col-lg-push-8 { - left: 66.66666667%; - } - .col-lg-push-7 { - left: 58.33333333%; - } - .col-lg-push-6 { - left: 50%; - } - .col-lg-push-5 { - left: 41.66666667%; - } - .col-lg-push-4 { - left: 33.33333333%; - } - .col-lg-push-3 { - left: 25%; - } - .col-lg-push-2 { - left: 16.66666667%; - } - .col-lg-push-1 { - left: 8.33333333%; - } - .col-lg-push-0 { - left: auto; - } - .col-lg-offset-12 { - margin-left: 100%; - } - .col-lg-offset-11 { - margin-left: 91.66666667%; - } - .col-lg-offset-10 { - margin-left: 83.33333333%; - } - .col-lg-offset-9 { - margin-left: 75%; - } - .col-lg-offset-8 { - margin-left: 66.66666667%; - } - .col-lg-offset-7 { - margin-left: 58.33333333%; - } - .col-lg-offset-6 { - margin-left: 50%; - } - .col-lg-offset-5 { - margin-left: 41.66666667%; - } - .col-lg-offset-4 { - margin-left: 33.33333333%; - } - .col-lg-offset-3 { - margin-left: 25%; - } - .col-lg-offset-2 { + #payment-method-pagseguro .col-md-offset-2 { margin-left: 16.66666667%; } - .col-lg-offset-1 { - margin-left: 8.33333333%; - } - .col-lg-offset-0 { - margin-left: 0%; - } -} -fieldset { - padding: 0; - margin: 0; - border: 0; - min-width: 0; -} -legend { - display: block; - width: 100%; - padding: 0; - margin-bottom: 20px; - font-size: 21px; - line-height: inherit; - color: #333333; - border: 0; - border-bottom: 1px solid #e5e5e5; } -label { +#payment-method-pagseguro label { display: inline-block; max-width: 100%; margin-bottom: 5px; font-weight: bold; } -input[type="search"] { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -input[type="radio"], -input[type="checkbox"] { +#payment-method-pagseguro input[type="radio"] { margin: 4px 0 0; margin-top: 1px \9; line-height: normal; } -input[type="file"] { - display: block; -} -input[type="range"] { - display: block; - width: 100%; -} -select[multiple], -select[size] { - height: auto; -} -input[type="file"]:focus, -input[type="radio"]:focus, -input[type="checkbox"]:focus { +#payment-method-pagseguro input[type="radio"]:focus { outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } -output { - display: block; - padding-top: 7px; - font-size: 14px; - line-height: 1.42857143; - color: #555555; -} - - -/*================================================================== - Custom form control to replace styles magento input -==================================================================*/ -input[type="text"], -input[type="password"], -input[type="url"], -input[type="tel"], -input[type="search"], -input[type="number"], -input[type="datetime"], -input[type="email"], -.form-control { +#payment-method-pagseguro input[type="text"], +#payment-method-pagseguro .form-control { display: block; width: 100%; height: 34px; @@ -775,944 +104,216 @@ input[type="email"], -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; } - -select { +#payment-method-pagseguro select { -webkit-appearance: menulist; -moz-appearance: menulist; appearance: menulist; - } -/*================================================================== - //end inputs -==================================================================*/ - - - -.form-control:focus { +#payment-method-pagseguro .form-control:focus { border-color: #66afe9; outline: 0; - -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); - box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); } -.form-control::-moz-placeholder { +#payment-method-pagseguro .form-control::-moz-placeholder { color: #999999; opacity: 1; } -.form-control:-ms-input-placeholder { +#payment-method-pagseguro .form-control:-ms-input-placeholder { color: #999999; } -.form-control::-webkit-input-placeholder { +#payment-method-pagseguro .form-control::-webkit-input-placeholder { color: #999999; } -.form-control::-ms-expand { +#payment-method-pagseguro .form-control::-ms-expand { border: 0; background-color: transparent; } -.form-control[disabled], -.form-control[readonly], -fieldset[disabled] .form-control { - background-color: #eeeeee; - opacity: 1; -} -.form-control[disabled], -fieldset[disabled] .form-control { - cursor: not-allowed; -} -textarea.form-control { - height: auto; -} -input[type="search"] { - -webkit-appearance: none; -} -@media screen and (-webkit-min-device-pixel-ratio: 0) { - input[type="date"].form-control, - input[type="time"].form-control, - input[type="datetime-local"].form-control, - input[type="month"].form-control { - line-height: 34px; - } - input[type="date"].input-sm, - input[type="time"].input-sm, - input[type="datetime-local"].input-sm, - input[type="month"].input-sm, - .input-group-sm input[type="date"], - .input-group-sm input[type="time"], - .input-group-sm input[type="datetime-local"], - .input-group-sm input[type="month"] { - line-height: 30px; - } - input[type="date"].input-lg, - input[type="time"].input-lg, - input[type="datetime-local"].input-lg, - input[type="month"].input-lg, - .input-group-lg input[type="date"], - .input-group-lg input[type="time"], - .input-group-lg input[type="datetime-local"], - .input-group-lg input[type="month"] { - line-height: 46px; - } -} -.form-group { +#payment-method-pagseguro .form-group { margin-bottom: 15px; } -.radio, -.checkbox { +#payment-method-pagseguro .radio { position: relative; display: block; margin-top: 10px; margin-bottom: 10px; } -.radio label, -.checkbox label { - min-height: 20px; - padding-left: 20px; - margin-bottom: 0; - font-weight: normal; - cursor: pointer; -} -.radio input[type="radio"], -.radio-inline input[type="radio"], -.checkbox input[type="checkbox"], -.checkbox-inline input[type="checkbox"] { +#payment-method-pagseguro .radio input[type="radio"] { position: absolute; margin-left: -20px; margin-top: 4px \9; } -.radio + .radio, -.checkbox + .checkbox { +#payment-method-pagseguro .radio + .radio { margin-top: -5px; } -.radio-inline, -.checkbox-inline { - position: relative; - display: inline-block; - padding-left: 20px; - margin-bottom: 0; - vertical-align: middle; - font-weight: normal; - cursor: pointer; -} -.radio-inline + .radio-inline, -.checkbox-inline + .checkbox-inline { - margin-top: 0; - margin-left: 10px; -} -input[type="radio"][disabled], -input[type="checkbox"][disabled], -input[type="radio"].disabled, -input[type="checkbox"].disabled, -fieldset[disabled] input[type="radio"], -fieldset[disabled] input[type="checkbox"] { - cursor: not-allowed; -} -.radio-inline.disabled, -.checkbox-inline.disabled, -fieldset[disabled] .radio-inline, -fieldset[disabled] .checkbox-inline { - cursor: not-allowed; -} -.radio.disabled label, -.checkbox.disabled label, -fieldset[disabled] .radio label, -fieldset[disabled] .checkbox label { - cursor: not-allowed; -} -.form-control-static { - padding-top: 7px; - padding-bottom: 7px; - margin-bottom: 0; - min-height: 34px; -} -.form-control-static.input-lg, -.form-control-static.input-sm { - padding-left: 0; - padding-right: 0; -} -.input-sm { - height: 30px; - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -select.input-sm { - height: 30px; - line-height: 30px; -} -textarea.input-sm, -select[multiple].input-sm { - height: auto; -} -.form-group-sm .form-control { - height: 30px; - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.form-group-sm select.form-control { - height: 30px; - line-height: 30px; -} -.form-group-sm textarea.form-control, -.form-group-sm select[multiple].form-control { - height: auto; -} -.form-group-sm .form-control-static { - height: 30px; - min-height: 32px; - padding: 6px 10px; - font-size: 12px; - line-height: 1.5; -} -.input-lg { - height: 46px; - padding: 10px 16px; - font-size: 18px; - line-height: 1.3333333; - border-radius: 6px; -} -select.input-lg { - height: 46px; - line-height: 46px; -} -textarea.input-lg, -select[multiple].input-lg { - height: auto; -} -.form-group-lg .form-control { - height: 46px; - padding: 10px 16px; - font-size: 18px; - line-height: 1.3333333; - border-radius: 6px; -} -.form-group-lg select.form-control { - height: 46px; - line-height: 46px; -} -.form-group-lg textarea.form-control, -.form-group-lg select[multiple].form-control { - height: auto; -} -.form-group-lg .form-control-static { - height: 46px; - min-height: 38px; - padding: 11px 16px; - font-size: 18px; - line-height: 1.3333333; -} -.has-feedback { - position: relative; -} -.has-feedback .form-control { - padding-right: 42.5px; -} -.form-control-feedback { - position: absolute; - top: 0; - right: 0; - z-index: 2; - display: block; - width: 34px; - height: 34px; - line-height: 34px; - text-align: center; - pointer-events: none; -} -.input-lg + .form-control-feedback, -.input-group-lg + .form-control-feedback, -.form-group-lg .form-control + .form-control-feedback { - width: 46px; - height: 46px; - line-height: 46px; -} -.input-sm + .form-control-feedback, -.input-group-sm + .form-control-feedback, -.form-group-sm .form-control + .form-control-feedback { - width: 30px; - height: 30px; - line-height: 30px; -} -.has-success .help-block, -.has-success .control-label, -.has-success .radio, -.has-success .checkbox, -.has-success .radio-inline, -.has-success .checkbox-inline, -.has-success.radio label, -.has-success.checkbox label, -.has-success.radio-inline label, -.has-success.checkbox-inline label { - color: #3c763d; -} -.has-success .form-control { - border-color: #3c763d; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-success .form-control:focus { - border-color: #2b542c; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168; -} -.has-success .input-group-addon { - color: #3c763d; - border-color: #3c763d; - background-color: #dff0d8; -} -.has-success .form-control-feedback { - color: #3c763d; -} -.has-warning .help-block, -.has-warning .control-label, -.has-warning .radio, -.has-warning .checkbox, -.has-warning .radio-inline, -.has-warning .checkbox-inline, -.has-warning.radio label, -.has-warning.checkbox label, -.has-warning.radio-inline label, -.has-warning.checkbox-inline label { - color: #8a6d3b; -} -.has-warning .form-control { - border-color: #8a6d3b; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-warning .form-control:focus { - border-color: #66512c; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b; -} -.has-warning .input-group-addon { - color: #8a6d3b; - border-color: #8a6d3b; - background-color: #fcf8e3; -} -.has-warning .form-control-feedback { - color: #8a6d3b; -} -.has-error .help-block, -.has-error .control-label, -.has-error .radio, -.has-error .checkbox, -.has-error .radio-inline, -.has-error .checkbox-inline, -.has-error.radio label, -.has-error.checkbox label, -.has-error.radio-inline label, -.has-error.checkbox-inline label { - color: #a94442; -} -.has-error .form-control { - border-color: #a94442; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-error .form-control:focus { - border-color: #843534; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483; -} -.has-error .input-group-addon { - color: #a94442; - border-color: #a94442; - background-color: #f2dede; -} -.has-error .form-control-feedback { - color: #a94442; -} -.has-feedback label ~ .form-control-feedback { - top: 25px; -} -.has-feedback label.sr-only ~ .form-control-feedback { - top: 0; -} -.help-block { +#payment-method-pagseguro .help-block { display: block; margin-top: 5px; margin-bottom: 10px; color: #737373; } -@media (min-width: 768px) { - .form-inline .form-group { - display: inline-block; - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .form-control { - display: inline-block; - width: auto; - vertical-align: middle; - } - .form-inline .form-control-static { - display: inline-block; - } - .form-inline .input-group { - display: inline-table; - vertical-align: middle; - } - .form-inline .input-group .input-group-addon, - .form-inline .input-group .input-group-btn, - .form-inline .input-group .form-control { - width: auto; - } - .form-inline .input-group > .form-control { - width: 100%; - } - .form-inline .control-label { - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .radio, - .form-inline .checkbox { - display: inline-block; - margin-top: 0; - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .radio label, - .form-inline .checkbox label { - padding-left: 0; - } - .form-inline .radio input[type="radio"], - .form-inline .checkbox input[type="checkbox"] { - position: relative; - margin-left: 0; - } - .form-inline .has-feedback .form-control-feedback { - top: 0; - } -} -.form-horizontal .radio, -.form-horizontal .checkbox, -.form-horizontal .radio-inline, -.form-horizontal .checkbox-inline { +#payment-method-pagseguro .form-horizontal .radio { margin-top: 0; margin-bottom: 0; padding-top: 7px; } -.form-horizontal .radio, -.form-horizontal .checkbox { +#payment-method-pagseguro .form-horizontal .radio { min-height: 27px; } -.form-horizontal .form-group { +#payment-method-pagseguro .form-horizontal .form-group { margin-left: -15px; margin-right: -15px; } @media (min-width: 768px) { - .form-horizontal .control-label { + #payment-method-pagseguro .form-horizontal .control-label { text-align: right; margin-bottom: 0; padding-top: 7px; } } -.form-horizontal .has-feedback .form-control-feedback { - right: 15px; -} -@media (min-width: 768px) { - .form-horizontal .form-group-lg .control-label { - padding-top: 11px; - font-size: 18px; - } -} -@media (min-width: 768px) { - .form-horizontal .form-group-sm .control-label { - padding-top: 6px; - font-size: 12px; - } -} -.input-group { - position: relative; +#payment-method-pagseguro .clearfix:before, +#payment-method-pagseguro .clearfix:after, +#payment-method-pagseguro .row:before, +#payment-method-pagseguro .row:after, +#payment-method-pagseguro .form-horizontal .form-group:before, +#payment-method-pagseguro .form-horizontal .form-group:after { + content: " "; display: table; - border-collapse: separate; -} -.input-group[class*="col-"] { - float: none; - padding-left: 0; - padding-right: 0; -} -.input-group .form-control { - position: relative; - z-index: 2; - float: left; - width: 100%; - margin-bottom: 0; -} -.input-group .form-control:focus { - z-index: 3; -} -.input-group-lg > .form-control, -.input-group-lg > .input-group-addon, -.input-group-lg > .input-group-btn > .btn { - height: 46px; - padding: 10px 16px; - font-size: 18px; - line-height: 1.3333333; - border-radius: 6px; -} -select.input-group-lg > .form-control, -select.input-group-lg > .input-group-addon, -select.input-group-lg > .input-group-btn > .btn { - height: 46px; - line-height: 46px; -} -textarea.input-group-lg > .form-control, -textarea.input-group-lg > .input-group-addon, -textarea.input-group-lg > .input-group-btn > .btn, -select[multiple].input-group-lg > .form-control, -select[multiple].input-group-lg > .input-group-addon, -select[multiple].input-group-lg > .input-group-btn > .btn { - height: auto; -} -.input-group-sm > .form-control, -.input-group-sm > .input-group-addon, -.input-group-sm > .input-group-btn > .btn { - height: 30px; - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -select.input-group-sm > .form-control, -select.input-group-sm > .input-group-addon, -select.input-group-sm > .input-group-btn > .btn { - height: 30px; - line-height: 30px; -} -textarea.input-group-sm > .form-control, -textarea.input-group-sm > .input-group-addon, -textarea.input-group-sm > .input-group-btn > .btn, -select[multiple].input-group-sm > .form-control, -select[multiple].input-group-sm > .input-group-addon, -select[multiple].input-group-sm > .input-group-btn > .btn { - height: auto; -} -.input-group-addon, -.input-group-btn, -.input-group .form-control { - display: table-cell; -} -.input-group-addon:not(:first-child):not(:last-child), -.input-group-btn:not(:first-child):not(:last-child), -.input-group .form-control:not(:first-child):not(:last-child) { - border-radius: 0; -} -.input-group-addon, -.input-group-btn { - width: 1%; - white-space: nowrap; - vertical-align: middle; } -.input-group-addon { - padding: 6px 12px; - font-size: 14px; - font-weight: normal; - line-height: 1; - color: #555555; - text-align: center; - background-color: #eeeeee; - border: 1px solid #cccccc; - border-radius: 4px; -} -.input-group-addon.input-sm { - padding: 5px 10px; - font-size: 12px; - border-radius: 3px; -} -.input-group-addon.input-lg { - padding: 10px 16px; - font-size: 18px; - border-radius: 6px; -} -.input-group-addon input[type="radio"], -.input-group-addon input[type="checkbox"] { - margin-top: 0; -} -.input-group .form-control:first-child, -.input-group-addon:first-child, -.input-group-btn:first-child > .btn, -.input-group-btn:first-child > .btn-group > .btn, -.input-group-btn:first-child > .dropdown-toggle, -.input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle), -.input-group-btn:last-child > .btn-group:not(:last-child) > .btn { - border-bottom-right-radius: 0; - border-top-right-radius: 0; -} -.input-group-addon:first-child { - border-right: 0; -} -.input-group .form-control:last-child, -.input-group-addon:last-child, -.input-group-btn:last-child > .btn, -.input-group-btn:last-child > .btn-group > .btn, -.input-group-btn:last-child > .dropdown-toggle, -.input-group-btn:first-child > .btn:not(:first-child), -.input-group-btn:first-child > .btn-group:not(:first-child) > .btn { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} -.input-group-addon:last-child { - border-left: 0; -} -.input-group-btn { - position: relative; - font-size: 0; - white-space: nowrap; -} -.input-group-btn > .btn { - position: relative; -} -.input-group-btn > .btn + .btn { - margin-left: -1px; -} -.input-group-btn > .btn:hover, -.input-group-btn > .btn:focus, -.input-group-btn > .btn:active { - z-index: 2; -} -.input-group-btn:first-child > .btn, -.input-group-btn:first-child > .btn-group { - margin-right: -1px; -} -.input-group-btn:last-child > .btn, -.input-group-btn:last-child > .btn-group { - z-index: 2; - margin-left: -1px; -} -.label { - display: inline; - padding: .2em .6em .3em; - font-size: 75%; - font-weight: bold; - line-height: 1; - color: #ffffff; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - border-radius: .25em; -} -a.label:hover, -a.label:focus { - color: #ffffff; - text-decoration: none; - cursor: pointer; -} -.label:empty { - display: none; -} -.btn .label { - position: relative; - top: -1px; -} -.label-default { - background-color: #777777; -} -.label-default[href]:hover, -.label-default[href]:focus { - background-color: #5e5e5e; -} -.label-primary { - background-color: #337ab7; -} -.label-primary[href]:hover, -.label-primary[href]:focus { - background-color: #286090; -} -.label-success { - background-color: #5cb85c; -} -.label-success[href]:hover, -.label-success[href]:focus { - background-color: #449d44; -} -.label-info { - background-color: #5bc0de; -} -.label-info[href]:hover, -.label-info[href]:focus { - background-color: #31b0d5; -} -.label-warning { - background-color: #f0ad4e; -} -.label-warning[href]:hover, -.label-warning[href]:focus { - background-color: #ec971f; -} -.label-danger { - background-color: #d9534f; +#payment-method-pagseguro .clearfix:after, +#payment-method-pagseguro .row:after, +#payment-method-pagseguro .form-horizontal .form-group:after { + clear: both; } -.label-danger[href]:hover, -.label-danger[href]:focus { - background-color: #c9302c; +#payment-method-pagseguro *, +#payment-method-pagseguro *::before, +#payment-method-pagseguro *::after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } -.badge { - display: inline-block; - min-width: 10px; - padding: 3px 7px; - font-size: 12px; - font-weight: bold; - color: #ffffff; - line-height: 1; - vertical-align: middle; - white-space: nowrap; - text-align: center; - background-color: #777777; - border-radius: 10px; +#payment-method-pagseguro .tabs-pagseguro { + width: 100%; } -.badge:empty { - display: none; +#payment-method-pagseguro .tabs-pagseguro > .items { + width: 100%; } -.btn .badge { +#payment-method-pagseguro .tabs-pagseguro > .items > .item { position: relative; - top: -1px; -} -.btn-xs .badge, -.btn-group-xs > .btn .badge { - top: 0; - padding: 1px 5px; + float: left; + width: 33.33%; + /* borders */ + border-color: #827e7e; + border-top-style: solid; + border-top-width: 1px; + border-bottom-style: solid; + border-bottom-width: 1px; } -a.badge:hover, -a.badge:focus { - color: #ffffff; - text-decoration: none; - cursor: pointer; +@media (max-width: 767px) { + #payment-method-pagseguro .tabs-pagseguro > .items > .item { + height: 125px; + } } -.list-group-item.active > .badge, -.nav-pills > .active > a > .badge { - color: #337ab7; - background-color: #ffffff; +#payment-method-pagseguro .tabs-pagseguro > .items > .item:first-child { + border-left-style: solid; + border-left-width: 1.5px; } -.list-group-item > .badge { - float: right; +#payment-method-pagseguro .tabs-pagseguro > .items > .item:nth-child(2) { + border-left-style: solid; + border-left-width: 1.5px; + border-right-style: solid; + border-right-width: 1.5px; } -.list-group-item > .badge + .badge { - margin-right: 5px; +#payment-method-pagseguro .tabs-pagseguro > .items > .item:last-child { + border-right-style: solid; + border-right-width: 1.5px; } -.nav-pills > li > a > .badge { - margin-left: 3px; +#payment-method-pagseguro .tabs-pagseguro > .items > .item.--active > .action { + color: #FFF; + background-color: #4F7743; } -.clearfix:before, -.clearfix:after, -.container:before, -.container:after, -.container-fluid:before, -.container-fluid:after, -.row:before, -.row:after, -.form-horizontal .form-group:before, -.form-horizontal .form-group:after { - content: " "; - display: table; +#payment-method-pagseguro .tabs-pagseguro > .items > .item.--active > .action::after { + bottom: -15px; + /* subtract the height unit this element */ + opacity: 1; + border-top-color: #4F7743; + -webkit-transition-duration: .25s; + -moz-transition-duration: .25s; + transition-duration: .25s; } -.clearfix:after, -.container:after, -.container-fluid:after, -.row:after, -.form-horizontal .form-group:after { - clear: both; +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action { + padding: .75em 1em; + height: 100%; } -.center-block { +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action::after { + content: ""; + position: absolute; + left: 0; + right: 0; display: block; margin-left: auto; margin-right: auto; + width: 0px; + height: 0px; + border-left: 15px solid transparent; + border-right: 15px solid transparent; + border-top: 15px solid #827e7e; + /* style of animation */ + opacity: 0; + bottom: -5px; + -webkit-transition: all linear; + -moz-transition: all linear; + transition: all linear; + -webkit-transition-duration: 0s; + -moz-transition-duration: 0s; + transition-duration: 0s; +} +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action, +#payment-method-pagseguro .btn-pagseguro { + text-align: center; + display: block; + background-color: transparent; + -webkit-transition: all 0.25s linear; + -moz-transition: all 0.25s linear; + transition: all 0.25s linear; } -.pull-right { - float: right !important; -} -.pull-left { - float: left !important; -} -.hide { - display: none !important; +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action { + color: #827e7e; } -.show { - display: block !important; +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action:hover, +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action:focus { + text-decoration: none; } -.invisible { - visibility: hidden; +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action:hover, +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action:focus, +#payment-method-pagseguro .btn-pagseguro:hover, +#payment-method-pagseguro .btn-pagseguro:focus { + color: #FFF; + background-color: #4F7743; } -.text-hide { - font: 0/0 a; - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action > .fa { + display: block; } -.hidden { - display: none !important; +#payment-method-pagseguro .tabs-pagseguro > .items > .item > .action > .name { + display: block; + margin-top: .5em; } -.affix { - position: fixed; +#payment-method-pagseguro .tabs-content { + padding: 1em; } - -/*================================================================== - Set to default box sizing for all elements -==================================================================*/ -*, -*::before, -*::after { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; +#payment-method-pagseguro .title-tab { + margin-bottom: 1em; } - -/*================================================================== - Tabs Components Styles -==================================================================*/ -/* tabs */ -.tabs-pagseguro { +#payment-method-pagseguro .tabs-content > .item-tab { + /* active tab current */ + display: none; width: 100%; } - - .tabs-pagseguro > .items { - width: 100%; - } - - .tabs-pagseguro > .items > .item { - position: relative; - float: left; - width: 33.33%; - /* borders */ - border-color: #827e7e; - border-top-style: solid; - border-top-width: 1px; - border-bottom-style: solid; - border-bottom-width: 1px; - } - @media (max-width: 767px){ - .tabs-pagseguro > .items > .item { - height: 125px; - } - } - - .tabs-pagseguro > .items > .item:first-child { - border-left-style: solid; - border-left-width: 1.5px; - } - - .tabs-pagseguro > .items > .item:nth-child(2) { - border-left-style: solid; - border-left-width: 1.5px; - border-right-style: solid; - border-right-width: 1.5px; - } - - .tabs-pagseguro > .items > .item:last-child { - border-right-style: solid; - border-right-width: 1.5px; - } - - /* init item active */ - .tabs-pagseguro > .items > .item.--active > .action { - color: #FFF; - background-color: #4F7743; - } - - - .tabs-pagseguro > .items > .item.--active > .action::after { - bottom: -15px; /* subtract the height unit this element */ - opacity: 1; - border-top-color: #4F7743; - -webkit-transition-duration: .25s; - -moz-transition-duration: .25s; - transition-duration: .25s; - } - /* end item active */ - - .tabs-pagseguro > .items > .item > .action { - padding: .75em 1em; - height: 100%; - } - - .tabs-pagseguro > .items > .item > .action::after { - content: ""; - position: absolute; - left: 0; - right: 0; - display: block; - margin-left: auto; - margin-right: auto; - width: 0px; - height: 0px; - border-left: 15px solid transparent; - border-right: 15px solid transparent; - border-top: 15px solid #827e7e; - - /* style of animation */ - opacity: 0; - bottom: -5px; - -webkit-transition: all linear; - -moz-transition: all linear; - transition: all linear; - -webkit-transition-duration: 0s; - -moz-transition-duration: 0s; - transition-duration: 0s; - } - - - /* action tab + btn-pagseguro */ - .tabs-pagseguro > .items > .item > .action, - .btn-pagseguro { - text-align: center; - display: block; - background-color: transparent; - -webkit-transition: all 0.25s linear; - -moz-transition: all 0.25s linear; - transition: all 0.25s linear; - } - - .tabs-pagseguro > .items > .item > .action { - color: #827e7e; - } - - .tabs-pagseguro > .items > .item > .action:hover, - .tabs-pagseguro > .items > .item > .action:focus, - a.btn-pagseguro:hover, - a.btn-pagseguro:focus { - text-decoration: none; - } - - .tabs-pagseguro > .items > .item > .action:hover, - .tabs-pagseguro > .items > .item > .action:focus, - .btn-pagseguro:hover, - .btn-pagseguro:focus { - color: #FFF; - background-color: #4F7743; - } - - .tabs-pagseguro > .items > .item > .action > .fa { - display: block; - } - - .tabs-pagseguro > .items > .item > .action > .name { - display: block; - margin-top: .5em; - } - -/* tabs content */ -.tabs-content { - padding: 1em; +#payment-method-pagseguro .tabs-content > .item-tab.--current { + display: block; } - .title-tab { - margin-bottom: 1em; - } - .tabs-content > .item-tab { - /* active tab current */ - display: none; - width: 100%; - } - - .tabs-content > .item-tab.--current { - display: block; - } - -/* btn-pagseguro */ -button:not(.primary), -.btn-pagseguro { +#payment-method-pagseguro button:not(.primary), +#payment-method-pagseguro .btn-pagseguro { color: #4F7743; font-size: 1.2em; white-space: nowrap; @@ -1731,62 +332,38 @@ button:not(.primary), -ms-touch-action: manipulation; touch-action: manipulation; } - .btn-pagseguro.--align-right { - float: right; - margin-top: 1.5em; - } - - .btn-pagseguro:hover, - .btn-pagseguro:focus { - /* fix native magento style - border hover button */ - border: 1px solid #4F7743; - } - -/* list warning */ -.list-warning { +#payment-method-pagseguro .btn-pagseguro.--align-right { + float: right; + margin-top: 1.5em; +} +#payment-method-pagseguro .btn-pagseguro:hover, +#payment-method-pagseguro .btn-pagseguro:focus { + /* fix native magento style - border hover button */ + border: 1px solid #4F7743; +} +#payment-method-pagseguro .list-warning { display: block; margin-top: 2em; width: 100%; } - -/* total value */ -.credit-total > .control-label { +#payment-method-pagseguro .credit-total > .control-label { font-size: 1.4em; } - -.credit-total > div > span { +#payment-method-pagseguro .credit-total > div > span { font-size: 1.15em; line-height: 34px; display: block; - padding-top: 5px; /* diferece font-size value at label */ + padding-top: 5px; + /* diferece font-size value at label */ } - - @media (max-width: 767px) { - - /* form inline custom config */ - .form-inline-childs > div{ + #payment-method-pagseguro { + /* form inline custom config */ + } + #payment-method-pagseguro .form-inline-childs > div { margin-bottom: 15px; } } - -.display-none { +#payment-method-pagseguro .display-none { display: none; -} - -.pagseguro-installments-table { - max-width: 100%; - margin-bottom: 1rem; -} - -.pagseguro-installments-table table, th, td { - border: 1px solid #DDD; - border-collapse: collapse; - text-align: center; - font-size: 1.2rem; - padding: 2px 2px !important; -} - -.pagseguro-installments-table tr:nth-child(even) { - background-color: #EEE; } \ No newline at end of file diff --git a/view/frontend/web/js/model/credit-card.js b/view/frontend/web/js/model/credit-card.js new file mode 100644 index 0000000..ca812ab --- /dev/null +++ b/view/frontend/web/js/model/credit-card.js @@ -0,0 +1,229 @@ +/** + * 2007-2017 [PagSeguro Internet Ltda.] + * + * NOTICE OF LICENSE + * + *Licensed under the Apache License, Version 2.0 (the "License"); + *you may not use this file except in compliance with the License. + *You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + *Unless required by applicable law or agreed to in writing, software + *distributed under the License is distributed on an "AS IS" BASIS, + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *See the License for the specific language governing permissions and + *limitations under the License. + * + * @author PagSeguro Internet Ltda. + * @copyright 2016 PagSeguro Internet Ltda. + * @license http://www.apache.org/licenses/LICENSE-2.0 + */ +//function setCreditCardSessionId(session) { +// return PagSeguroDirectPayment.setSessionId(session) +//} +// +//function getSenderHash() { +// return PagSeguroDirectPayment.getSenderHash() +//} +// +//function assignCreditCardHash() { +// setTimeout(function () { +// document.getElementById('creditCardHash').value = getSenderHash() +// }, 500) +//} + +function validateCreditCard(self) { + if (self.validity.valid && removeNumbers(unmask(self.value)) === "" && (self.value.length >= 14 && self.value.length <= 22)) { + displayError(self, false) + return true + } else { + displayError(self) + return false + } +} + +function validateCardHolder (self) { + if (self.validity.tooShort || !self.validity.valid || removeLetters(unmask(self.value)) !== "") { + displayError(self) + return false + } else { + displayError(self, false) + return true + } + } + + function validateCreditCardHolderBirthdate (self) { + var val = self.value + var date_regex = /^(0[1-9]|1\d|2\d|3[01])\/(0[1-9]|1[0-2])\/(19|20)\d{2}$/ + if (!(date_regex.test(val))) { + displayError(self) + return false + } else { + displayError(self, false) + return true + } + } + + function validateCreditCardMonth (self) { + if (self.validity.valid && self.value !== "") { + displayError(self, false) + return true + } else { + displayError(self) + return false + } + } + + function validateCreditCardYear (self) { + if (self.validity.valid && self.value !== "") { + displayError(self, false) + return true + } else { + displayError(self) + return false + } + } + +function cardInstallmentOnChange(data) { + data = JSON.parse(data.value) + document.getElementById('creditCardInstallment').value = data.quantity + document.getElementById('creditCardInstallmentValue').value = data.installmentAmount + document.getElementById('card_total').innerHTML = 'R$ ' + data.totalAmount +} + +function cardInstallment(data) { + var select = document.getElementById('card_installment_option') + data = data[Object.getOwnPropertyNames(data)[0]] + data.forEach(function (item) { + select.options[select.options.length] = new Option(item.quantity + 'x de R$ ' + item.installmentAmount, + JSON.stringify(item)) + }) + if (data) { + select.removeAttribute('disabled') + } +} + +function validateCreditCardInstallment (self) { + if (self.validity.valid && self.value != "null") { + displayError(self, false) + return true + } else { + displayError(self) + return false + } + } + +function getInstallments(brand) { + PagSeguroDirectPayment.getInstallments({ + amount: document.getElementById('grand_total').value, + brand: brand, + success: function (response) { + cardInstallment(response.installments) + }, + error: function (response){ + console.log('erro ao gerar parcelamento'); + }, + }) +} + +function getBrand(self) { + var select = document.getElementById('card_installment_option'); + select.options.length = 0; + select.options[0] = new Option('Escolha o N° de parcelas', null, true, true); + select.options[0].disabled = true + document.getElementById('card_total').innerHTML = 'selecione o número de parcelas'; + PagSeguroDirectPayment.setSessionId(document.getElementById('pagseguroCcSessionId').value); + if (validateCreditCard(self)) { + PagSeguroDirectPayment.getBrand({ + cardBin: unmask(document.getElementById('pagseguro_credit_card_number').value), + success: function (response) { + document.getElementById('creditCardBrand').value = response.brand.name + getInstallments(response.brand.name) + displayError(document.getElementById('pagseguro_credit_card_number'), false) + }, + error: function () { + console.log('erro na chamada'); + }, + complete: function(response) { + //console.log('tratamento comum para todas chamadas');//// + } + }); + } else { + displayError(document.getElementById('pagseguro_credit_card_number')) + } + return false; +} + + +function validateCreditCardCode(self) { + if (self.validity.tooLong || self.validity.tooShort || !self.validity.valid) { + displayError(self) + return false + } else { + displayError(self, false) + return true + } +} + +function validateCreditCardForm() { + if ( + validateCreditCard(document.querySelector('#pagseguro_credit_card_number')) && + validateDocumentFinal(document.querySelector('#creditCardDocument')) && + validateCardHolder(document.querySelector('#creditCardHolder')) && + validateCreditCardHolderBirthdate(document.querySelector('#creditCardHolderBirthdate')) && + validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')) && + validateCreditCardYear(document.querySelector('#creditCardExpirationYear')) && + validateCreditCardCode(document.querySelector('#creditCardCode')) && + validateCreditCardInstallment(document.querySelector('#card_installment_option')) + ) { + return true; + } + + validateCreditCard(document.querySelector('#pagseguro_credit_card_number')) + validateDocumentFinal(document.querySelector('#creditCardDocument')) + validateCardHolder(document.querySelector('#creditCardHolder')) + validateCreditCardHolderBirthdate(document.querySelector('#creditCardHolderBirthdate')) + validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')) + validateCreditCardYear(document.querySelector('#creditCardExpirationYear')) + validateCreditCardCode(document.querySelector('#creditCardCode'), false) + validateCreditCardInstallment(document.querySelector('#card_installment_option')) + return false; +} + +function validateCreateToken() { + if(validateCreditCard(document.querySelector('#pagseguro_credit_card_number')) + && validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')) + && validateCreditCardYear(document.querySelector('#creditCardExpirationYear')) + && validateCreditCardCode(document.querySelector('#creditCardCode')) + && document.getElementById('creditCardBrand').value !== "" + ) { + return true + } + + validateCreditCard(document.querySelector('#pagseguro_credit_card_number')); + validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')); + validateCreditCardYear(document.querySelector('#creditCardExpirationYear')); + validateCreditCardCode(document.querySelector('#creditCardCode')); + + return false; +} + +/** + * Return the value of 'el' without letters + * @param {string} el + * @returns {string} + */ +function removeLetters(el) { + return el.replace(/[a-zA-Z]/g, ''); + +} + +/** + * Return the value of 'el' without numbers + * @param {string} el + * @returns {string} + */ +function removeNumbers(el) { + return el.replace(/[0-9]/g, ''); +} \ No newline at end of file diff --git a/view/frontend/web/js/model/direct-payment-validator.js b/view/frontend/web/js/model/direct-payment-validator.js new file mode 100644 index 0000000..93b9f04 --- /dev/null +++ b/view/frontend/web/js/model/direct-payment-validator.js @@ -0,0 +1,418 @@ +/** + * 2007-2017 [PagSeguro Internet Ltda.] + * + * NOTICE OF LICENSE + * + *Licensed under the Apache License, Version 2.0 (the "License"); + *you may not use this file except in compliance with the License. + *You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + *Unless required by applicable law or agreed to in writing, software + *distributed under the License is distributed on an "AS IS" BASIS, + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *See the License for the specific language governing permissions and + *limitations under the License. + * + * @author PagSeguro Internet Ltda. + * @copyright 2016 PagSeguro Internet Ltda. + * @license http://www.apache.org/licenses/LICENSE-2.0 + */ + +/* + * This file have all the pagseguro direct payment common functions, like + * form input masks and validations and calls to the pagseguro js api + */ + +function mascaraMutuario(o,f){ + v_obj=o + v_fun=f + setTimeout('execmascara()',1) +} + +function execmascara(){ + v_obj.value=v_fun(v_obj.value) +} + +function cpfCnpj(v){ + + //Remove tudo o que não é dígito + v=v.replace(/\D/g,"") + + if (v.length <= 14) { //CPF + + //Coloca um ponto entre o terceiro e o quarto dígitos + v=v.replace(/(\d{3})(\d)/,"$1.$2") + + //Coloca um ponto entre o terceiro e o quarto dígitos + //de novo (para o segundo bloco de números) + v=v.replace(/(\d{3})(\d)/,"$1.$2") + + //Coloca um hífen entre o terceiro e o quarto dígitos + v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") + } else { //CNPJ + //Coloca ponto entre o segundo e o terceiro dígitos + v=v.replace(/^(\d{2})(\d)/,"$1.$2") + + //Coloca ponto entre o quinto e o sexto dígitos + v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") + + //Coloca uma barra entre o oitavo e o nono dígitos + v=v.replace(/\.(\d{3})(\d)/,".$1/$2") + + //Coloca um hífen depois do bloco de quatro dígitos + v=v.replace(/(\d{4})(\d)/,"$1-$2") + + } + + return v + +} + +function validateDocumentFinal(self) { + var value = unmask(self.value) + if (value.length === 11) { + return validateCpf(self) + } else if (value.length === 14) { + return validateCnpj(self) + } else { + displayError(self) + return false + } +} + +/** + * Validate document (cpf or cnpj) according with it's length + * @param {type} self + * @returns {Boolean} + */ +function validateDocument(self) { + var value = unmask(self.value) + if (value.length === 11) { + status = validateCpf(self); + } else if (value.length === 14) { + status = validateCnpj(self) + } else if (value.length === 0) { + return false; + } else if (value.length !== 11 && value.length !== 14){ + displayError(self) + return false + } + if (status == "true") { + //displayError(self, false) + return false; + } else { + displayError(self) + return false + } +} + +/** + * Remove special characters, spaces + * @param {type} el + * @returns {unresolved} + */ +function unmask(el) { + return el.replace(/[/ -. ]+/g, '').trim() +} + +/** + * Validate CPF + * @param {object} self + * @returns {Boolean} + */ +function validateCpf(self) { + var cpf = unmask(self.value) + var numeros, digitos, soma, i, resultado, digitos_iguais + digitos_iguais = 1 + if (cpf.length < 11) { + displayError(self) + return false + } + for (i = 0; i < cpf.length - 1; i++) + if (cpf.charAt(i) != cpf.charAt(i + 1)) { + digitos_iguais = 0 + break + } + if (!digitos_iguais) { + numeros = cpf.substring(0, 9) + digitos = cpf.substring(9) + soma = 0 + for (i = 10; i > 1; i--) { + soma += numeros.charAt(10 - i) * i + } + resultado = soma % 11 < 2 ? 0 : 11 - soma % 11 + if (resultado != digitos.charAt(0)) { + displayError(self) + return false + } + numeros = cpf.substring(0, 10) + soma = 0 + for (i = 11; i > 1; i--) { + soma += numeros.charAt(11 - i) * i + } + resultado = soma % 11 < 2 ? 0 : 11 - soma % 11 + if (resultado != digitos.charAt(1)) { + displayError(self) + return false + } + displayError(self, false) + return true + } else { + displayError(self) + return false + } +} + +/** + * Validates CNPJ + * @param {object} self + * @returns {Boolean} + */ +function validateCnpj(self) { + var cnpj = unmask(self.value) + var numbersVal + var digits + var sum + var i + var result + var pos + var size + var equal_digits + equal_digits = 1 + if (cnpj.length < 14 && cnpj.length < 15) { + displayError(self) + return false + } + for (i = 0; i < cnpj.length - 1; i++) { + if (cnpj.charAt(i) != cnpj.charAt(i + 1)) { + equal_digits = 0 + break + } + } + if (!equal_digits) { + size = cnpj.length - 2 + numbersVal = cnpj.substring(0, size) + digits = cnpj.substring(size) + sum = 0 + pos = size - 7 + for (i = size; i >= 1; i--) { + sum += numbersVal.charAt(size - i) * pos-- + if (pos < 2) { + pos = 9 + } + } + result = sum % 11 < 2 ? 0 : 11 - sum % 11 + if (result != digits.charAt(0)) { + displayError(self) + return false + } + size = size + 1 + numbersVal = cnpj.substring(0, size) + sum = 0 + pos = size - 7 + for (i = size; i >= 1; i--) { + sum += numbersVal.charAt(size - i) * pos-- + if (pos < 2) { + pos = 9 + } + } + result = sum % 11 < 2 ? 0 : 11 - sum % 11 + if (result != digits.charAt(1)) { + displayError(self) + return false + } + displayError(self, false) + return true + } else { + displayError(self) + return false + } +} + +/** + * Show input error + * @param {type} target + * @param {type} error + * @returns {undefined} + */ +function displayError(target, error = true) { + target = document.getElementsByClassName(target.id + '-error-message')[0] + if (error && target.classList.contains('display-none')) { + target.classList.remove('display-none') + target.style.display = ""; + } else if (!error) { + target.classList.add('display-none') + target.style.display = "none"; + } +} + +/** + * Add mask for document (cpf or cnpj) + * Important: Called on keyup event + * @param {this} document + * @returns {bool} + */ +function documentMask(document) { + if (document.value.length < 14 + || (document.value.length == 14 && (event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 46)) + ) { + MascaraCPF(document); + } else { + MascaraCNPJ(document); + } +} + +/* + * Mask functions below adapted from + * http://www.fabiobmed.com.br/excelente-codigo-para-mascara-e-validacao-de-cnpj-cpf-cep-data-e-telefone/ + */ + +/** + * Add CNPJ mask to input + * @param {type} cnpj + * @returns {Boolean} + */ +function MascaraCNPJ(cnpj) { + if (mascaraInteiro(cnpj) == false) { + event.returnValue = false; + } + return formataCampo(cnpj, '00.000.000/0000-00', event); +} + +/** + * Add date mask to input + * @param {type} cnpj + * @returns {Boolean} + */ +function MascaraData(data) { + if (mascaraInteiro(data) == false) { + event.returnValue = false; + } + return formataCampo(data, '00/00/0000', event); +} + +/** + * Add CPF mask to input + * @param {type} cnpj + * @returns {Boolean} + */ +function MascaraCPF(cpf) { + if (mascaraInteiro(cpf) == false) { + event.returnValue = false; + } + return formataCampo(cpf, '000.000.000-00', event); +} + +/** + * Add credit card mask to input + * @param {type} cnpj + * @returns {Boolean} + */ +function creditCardMask(cc) { + if (mascaraInteiro(cc) == false) { + event.returnValue = false; + } + return formataCampo(cc, '0000 0000 0000 0000', event); +} + +/** + * Add not number mask to input + * @param {type} cnpj + * @returns {Boolean} + */ +function notNumberMask(someString) { + if (maskNotNumber(someString) == false) { + event.returnValue = false; + } + return true; +} + +/** + * Validate and prevent key typed event if it is a numbers + * @returns {Boolean} + */ +function maskNotNumber() { + if (event.keyCode == 8 + || event.keyCode == 9 + || event.keyCode == 46 + || event.keyCode < 48 + || (event.keyCode > 57 && event.keyCode < 96) + || (event.keyCode > 105)) { + + return true; + } + event.returnValue = false; + return false; +} + +/** + * Validate and prevent key typed event if it is not an integer([48,57] || [96, 105]), + * backspace(8), tab(9), or del(46) + * @returns {Boolean} + */ +function mascaraInteiro() { + if (event.keyCode == 8 + || event.keyCode == 9 + || event.keyCode == 46 + || (event.keyCode > 47 && event.keyCode < 58) + || (event.keyCode > 95 && event.keyCode < 106)) { + + return true; + } + event.returnValue = false; + return false; +} + +/** + * Format fields, according with the mask pattern + * @param {type} campo + * @param {type} Mascara + * @param {type} evento + * @returns {Boolean} + */ +function formataCampo(campo, Mascara, evento) { + var boleanoMascara; + + var Digitato = evento.keyCode; + exp = /\-|\.|\/|\(|\)| /g + campoSoNumeros = campo.value.toString().replace(exp, ""); + + var posicaoCampo = 0; + var NovoValorCampo = ""; + var TamanhoMascara = campoSoNumeros.length; + ; + + if (Digitato != 8) { // backspace + for (i = 0; i <= TamanhoMascara; i++) { + boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".") + || (Mascara.charAt(i) == "/")) + boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(") + || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " ")) + if (boleanoMascara) { + NovoValorCampo += Mascara.charAt(i); + TamanhoMascara++; + } else { + NovoValorCampo += campoSoNumeros.charAt(posicaoCampo); + posicaoCampo++; + } + } + campo.value = NovoValorCampo; + return true; + } else { + return true; + } +} + +/** + * Add credit card code mask to input + * @param {type} cnpj + * @returns {Boolean} + */ +function creditCardCodeMask(code) { + if (mascaraInteiro(code) == false) { + event.returnValue = false; + } + return true; +} \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/method-renderer/boleto-method.js b/view/frontend/web/js/view/payment/method-renderer/boleto-method.js new file mode 100644 index 0000000..ae67b52 --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/boleto-method.js @@ -0,0 +1,120 @@ +/** + * 2007-2016 [PagSeguro Internet Ltda.] + * + * NOTICE OF LICENSE + * + *Licensed under the Apache License, Version 2.0 (the "License"); + *you may not use this file except in compliance with the License. + *You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + *Unless required by applicable law or agreed to in writing, software + *distributed under the License is distributed on an "AS IS" BASIS, + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *See the License for the specific language governing permissions and + *limitations under the License. + * + * @author PagSeguro Internet Ltda. + * @copyright 2016 PagSeguro Internet Ltda. + * @license http://www.apache.org/licenses/LICENSE-2.0 + */ +/* + * browser:true + * global define + */ +define( + [ + 'jquery', + 'Magento_Checkout/js/view/payment/default', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_Checkout/js/action/set-payment-information', + 'Magento_Checkout/js/action/place-order', + 'UOL_PagSeguro/js/model/direct-payment-validator', + window.checkoutConfig.library.directPaymentJs + ], + function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, directPaymentValidator) { + 'use strict'; + + return Component.extend({ + defaults: { + template: 'UOL_PagSeguro/payment/boleto-form', + brazilFlagPath: window.checkoutConfig.brazilFlagPath + }, + + initObservable: function () { + + this._super() + .observe([ + 'boletoDocument' + ]); + return this; + }, + + context: function() { + return this; + }, + + getCode: function() { + return "pagseguro_boleto" + }, + + getData: function() { + return { + 'method': this.item.method, + 'additional_data': { + 'boleto_document': this.boletoDocument() + } + }; + }, + + doDocumentMask: function(data, event) { + //directPaymentValidator.documentValidator(document.getElementById('pagseguro_boleto_boleto_document')); + //value.length + documentMask(document.getElementById('pagseguro_boleto_boleto_document')); + //console.log(event.keyCode); + //console.log(directPaymentValidator.documentValidator()); + return true; + }, + + /** + * @override + */ + placeOrder: function () { + var self = this; + var paymentData = quote.paymentMethod(); + var messageContainer = this.messageContainer; + PagSeguroDirectPayment.setSessionId(window.checkoutConfig.library.session); + fullScreenLoader.startLoader(); + this.isPlaceOrderActionAllowed(false); + if (! self.validatePlaceOrder()) { + fullScreenLoader.stopLoader(); + this.isPlaceOrderActionAllowed(true); + return; + } + + $.when(setPaymentInformationAction(this.messageContainer, { + 'method': self.getCode(), + 'additional_data': { + 'boleto_document': (self.boletoDocument()) ? self.boletoDocument() : document.getElementById('pagseguro_boleto_boleto_document').value, + 'boleto_hash': PagSeguroDirectPayment.getSenderHash() + } + })).done(function () { + delete paymentData['title']; + $.when(placeOrder(paymentData, messageContainer)).done(function () { + $.mage.redirect(window.checkoutConfig.pagseguro_boleto); + }); + }).fail(function () { + self.isPlaceOrderActionAllowed(true); + }).always(function(){ + fullScreenLoader.stopLoader(); + }); + }, + + validatePlaceOrder: function() { + return validateDocumentFinal(document.getElementById('pagseguro_boleto_boleto_document')); + } + }); + } +); diff --git a/view/frontend/web/js/view/payment/method-renderer/credit_card-method.js b/view/frontend/web/js/view/payment/method-renderer/credit_card-method.js new file mode 100644 index 0000000..36557d6 --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/credit_card-method.js @@ -0,0 +1,174 @@ +/** + * 2007-2016 [PagSeguro Internet Ltda.] + * + * NOTICE OF LICENSE + * + *Licensed under the Apache License, Version 2.0 (the "License"); + *you may not use this file except in compliance with the License. + *You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + *Unless required by applicable law or agreed to in writing, software + *distributed under the License is distributed on an "AS IS" BASIS, + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *See the License for the specific language governing permissions and + *limitations under the License. + * + * @author PagSeguro Internet Ltda. + * @copyright 2016 PagSeguro Internet Ltda. + * @license http://www.apache.org/licenses/LICENSE-2.0 + */ +/* + * browser:true + * global define + */ +define( + [ + 'jquery', + 'Magento_Checkout/js/view/payment/default', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_Checkout/js/action/set-payment-information', + 'Magento_Checkout/js/action/place-order', + 'UOL_PagSeguro/js/model/direct-payment-validator', + 'UOL_PagSeguro/js/model/credit-card', + window.checkoutConfig.library.directPaymentJs + ], + function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, directPaymentValidator, creditCard) { + 'use strict'; + + return Component.extend({ + defaults: { + template: 'UOL_PagSeguro/payment/credit-card-form', + brazilFlagPath: window.checkoutConfig.brazilFlagPath, + pagseguroCcSessionId: window.checkoutConfig.library.session +// totals: parseFloat( +// _.findLast(q.getTotals()()['total_segments'], 'value').value +// ) + }, + + initObservable: function () { + + this._super() + .observe([ + 'creditCardDocument' + ]); + return this; + }, + + getGrandTotal: function() { + var totals = quote.getTotals()(); + var x = (totals ? totals : quote)['grand_total']; + //var y = _.findLast(quote.getTotals()()['total_segments'], 'value').value; + //console.log(x); + //console.log(y); + return parseFloat(x); + }, + + getPagSeguroCcMonthsValues: function() { + var months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; + return _.map(months, function (value, key) { + return { + 'value': key + 1, + 'month': value + }; + }); + }, + + getPagSeguroCcYearsValues: function() { + var thisYear = (new Date()).getFullYear(); + var maxYear = thisYear + 20; + var years = []; + var i = thisYear; + for (i = thisYear; i < maxYear; i++) { + years.push(i); + } + + return _.map(years, function (value, key) { + return { + 'value': value, + 'year': value + }; + }); + }, + + context: function() { + return this; + }, + + getCode: function() { + return "pagseguro_credit_card" + }, + + /** + * @override + */ + placeOrder: function () { + var self = this; + var paymentData = quote.paymentMethod(); + var messageContainer = this.messageContainer; + // remove previous token error message if it exists + displayError(document.getElementById('creditCardToken'), false); + fullScreenLoader.startLoader(); + this.isPlaceOrderActionAllowed(false); + + if (! self.validatePlaceOrder()) { + fullScreenLoader.stopLoader(); + this.isPlaceOrderActionAllowed(true); + return; + } else { + var pagseguroHash = PagSeguroDirectPayment.getSenderHash(); + var param = { + cardNumber: unmask(document.getElementById('pagseguro_credit_card_number').value), + brand: document.getElementById('creditCardBrand').value, + cvv: document.getElementById('creditCardCode').value, + expirationMonth: document.getElementById('creditCardExpirationMonth').value, + expirationYear: document.getElementById('creditCardExpirationYear').value, + success: function (response) { + document.getElementById('creditCardToken').value = response.card.token; + self.finishOrder(self, paymentData, messageContainer, pagseguroHash); + }, + error: function (error) { + displayError(document.getElementById('creditCardToken')); + fullScreenLoader.stopLoader(); + self.isPlaceOrderActionAllowed(true); + return; + }, + } + + PagSeguroDirectPayment.createCardToken(param); + } + }, + + validatePlaceOrder: function() { + return validateCreditCardForm(); + }, + + finishOrder: function(self, paymentData, messageContainer, pagseguroHash) { + $.when(setPaymentInformationAction(messageContainer, { + 'method': self.getCode(), + 'additional_data': { + 'credit_card_document': (self.creditCardDocument()) ? self.creditCardDocument() : document.getElementById('creditCardDocument').value, + 'credit_card_hash' : pagseguroHash,//PagSeguroDirectPayment.getSenderHash(), + 'credit_card_token' : document.getElementById('creditCardToken').value, + 'credit_card_holder_name' : document.getElementById('creditCardHolder').value, + 'credit_card_holder_birthdate' : document.getElementById('creditCardHolderBirthdate').value, + 'credit_card_installment' : document.getElementById('creditCardInstallment').value, + 'credit_card_installment_value' : document.getElementById('creditCardInstallmentValue').value + } + })).done(function () { + delete paymentData['title']; + $.when(placeOrder(paymentData, messageContainer)).done(function () { + $.mage.redirect(window.checkoutConfig.pagseguro_boleto); + }); + //return; + }).fail(function () { + self.isPlaceOrderActionAllowed(true); + }).always(function(){ + fullScreenLoader.stopLoader(); + }); + } + }); + } +); diff --git a/view/frontend/web/js/view/payment/method-renderer/payment-method.js b/view/frontend/web/js/view/payment/method-renderer/default_lightbox-method.js similarity index 87% rename from view/frontend/web/js/view/payment/method-renderer/payment-method.js rename to view/frontend/web/js/view/payment/method-renderer/default_lightbox-method.js index 7d6bcbc..7f48c8a 100644 --- a/view/frontend/web/js/view/payment/method-renderer/payment-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/default_lightbox-method.js @@ -37,7 +37,7 @@ define( return Component.extend({ defaults: { - template: 'UOL_PagSeguro/payment/payment-form' + template: 'UOL_PagSeguro/payment/default-lightbox-form' }, context: function() { @@ -45,7 +45,7 @@ define( }, getCode: function() { - return "pagseguro" + return "pagseguro_default_lightbox" }, /** @@ -61,10 +61,9 @@ define( $.when(setPaymentInformationAction(this.messageContainer, { 'method': self.getCode() })).done(function () { + delete paymentData['title']; $.when(placeOrder(paymentData, messageContainer)).done(function () { - if (window.checkoutConfig.payment.pagseguro.isDirect) { - $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.direct); - } else if (window.checkoutConfig.payment.pagseguro.isLightbox){ + if (window.checkoutConfig.payment.pagseguro.isLightbox){ $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.lightbox); } else { $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.standard); diff --git a/view/frontend/web/js/view/payment/method-renderer/online_debit-method.js b/view/frontend/web/js/view/payment/method-renderer/online_debit-method.js new file mode 100644 index 0000000..8f75881 --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/online_debit-method.js @@ -0,0 +1,116 @@ +/** + * 2007-2016 [PagSeguro Internet Ltda.] + * + * NOTICE OF LICENSE + * + *Licensed under the Apache License, Version 2.0 (the "License"); + *you may not use this file except in compliance with the License. + *You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + *Unless required by applicable law or agreed to in writing, software + *distributed under the License is distributed on an "AS IS" BASIS, + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *See the License for the specific language governing permissions and + *limitations under the License. + * + * @author PagSeguro Internet Ltda. + * @copyright 2016 PagSeguro Internet Ltda. + * @license http://www.apache.org/licenses/LICENSE-2.0 + */ +/* + * browser:true + * global define + */ +define( + [ + 'jquery', + 'Magento_Checkout/js/view/payment/default', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_Checkout/js/action/set-payment-information', + 'Magento_Checkout/js/action/place-order', + 'UOL_PagSeguro/js/model/direct-payment-validator', + window.checkoutConfig.library.directPaymentJs + ], + function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, directPaymentValidator) { + 'use strict'; + + return Component.extend({ + defaults: { + template: 'UOL_PagSeguro/payment/online-debit-form', + brazilFlagPath: window.checkoutConfig.brazilFlagPath + }, + + initObservable: function () { + + this._super() + .observe([ + 'onlineDebitDocument', + 'checkedBank' + ]); + return this; + }, + + context: function() { + return this; + }, + + getCode: function() { + return "pagseguro_online_debit" + }, + + /** + * @override + */ + placeOrder: function () { + var self = this; + var paymentData = quote.paymentMethod(); + var messageContainer = this.messageContainer; + fullScreenLoader.startLoader(); + this.isPlaceOrderActionAllowed(false); + + if (! self.validatePlaceOrder(self.checkedBank())) { + fullScreenLoader.stopLoader(); + this.isPlaceOrderActionAllowed(true); + return; + } + /* @TODO verify if session id is already set */ + PagSeguroDirectPayment.setSessionId(window.checkoutConfig.library.session); + + $.when(setPaymentInformationAction(this.messageContainer, { + 'method': self.getCode(), + 'additional_data': { + 'online_debit_document': (self.onlineDebitDocument()) ? self.onlineDebitDocument() : document.getElementById('pagseguro_online_debit_online_debit_document').value, + 'online_debit_hash': PagSeguroDirectPayment.getSenderHash(), + 'online_debit_bank' : self.checkedBank() + } + })).done(function () { + delete paymentData['title']; + $.when(placeOrder(paymentData, messageContainer)).done(function () { + $.mage.redirect(window.checkoutConfig.pagseguro_boleto); + }); + }).fail(function () { + self.isPlaceOrderActionAllowed(true); + }).always(function(){ + fullScreenLoader.stopLoader(); + }); + }, + + validatePlaceOrder: function(checkedBank) { + var invalidBank = checkedBank === undefined; + + if (invalidBank) { + document.getElementById('debitbankNameError').style.display = ""; + } + return validateDocumentFinal(document.getElementById('pagseguro_online_debit_online_debit_document')) && ! invalidBank; + }, + + hideBankError: function() { + document.getElementById('debitbankNameError').style.display = 'none'; + return false; + } + }); + } +); diff --git a/view/frontend/web/js/view/payment/payment.js b/view/frontend/web/js/view/payment/payment.js index 0ca9e65..ddacbff 100644 --- a/view/frontend/web/js/view/payment/payment.js +++ b/view/frontend/web/js/view/payment/payment.js @@ -35,8 +35,20 @@ define( 'use strict'; rendererList.push( { - type: 'pagseguro', - component: 'UOL_PagSeguro/js/view/payment/method-renderer/payment-method' + type: 'pagseguro_default_lightbox', + component: 'UOL_PagSeguro/js/view/payment/method-renderer/default_lightbox-method' + }, + { + type: 'pagseguro_credit_card', + component: 'UOL_PagSeguro/js/view/payment/method-renderer/credit_card-method' + }, + { + type: 'pagseguro_boleto', + component: 'UOL_PagSeguro/js/view/payment/method-renderer/boleto-method' + }, + { + type: 'pagseguro_online_debit', + component: 'UOL_PagSeguro/js/view/payment/method-renderer/online_debit-method' } ); diff --git a/view/frontend/web/template/payment/boleto-form.html b/view/frontend/web/template/payment/boleto-form.html new file mode 100644 index 0000000..082fccf --- /dev/null +++ b/view/frontend/web/template/payment/boleto-form.html @@ -0,0 +1,107 @@ + +
+
+ + +
+
+ + + +
+ + + +
+ +
+
+
+ +
+ + + +
+
+
+
+
    +
  • Imprima o boleto e pague no banco ou na internet utilizando o seu código de barras.
  • +
  • O prazo de validade do boleto é de 1 dia útil.
  • +
+
+
+ Esta compra está sendo feita no Brasil + +
+
+
+
+ +
+ + + +
+ +
+
+ +
+
+
+
\ No newline at end of file diff --git a/view/frontend/web/template/payment/credit-card-form.html b/view/frontend/web/template/payment/credit-card-form.html new file mode 100644 index 0000000..82ae02a --- /dev/null +++ b/view/frontend/web/template/payment/credit-card-form.html @@ -0,0 +1,316 @@ + +
+
+ + +
+
+ + + +
+ + + +
+ +
+ + + + + + + +
+ + +
+ + +
+
+ + +
+ + +
+ + +
+
+ + +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+ + +
+ + +
+ + +
+
+ + +
+ + +
+ + +
+
+ + +
+ + +
+ + +
+
+ + +
+ + +
+ + +
+
+ + +
+ + + + + selecione o número de parcelas + + +
+ +
+ +
+ +
+
+ Esta compra está sendo feita no Brasil + +
+
+
+ +
+ + + +
+
+
+ +
+
+
+
diff --git a/view/frontend/web/template/payment/payment-form.html b/view/frontend/web/template/payment/default-lightbox-form.html similarity index 70% rename from view/frontend/web/template/payment/payment-form.html rename to view/frontend/web/template/payment/default-lightbox-form.html index 6a5ad67..2e5efd7 100644 --- a/view/frontend/web/template/payment/payment-form.html +++ b/view/frontend/web/template/payment/default-lightbox-form.html @@ -30,7 +30,24 @@
-

Com o PagSeguro, você pode escolher como quer pagar e ainda parcelar sua compra em até 18x.

+ + + + +
+ + + +
+ +
+ + + +
+
+
+
+