From 9053b28ae57eaa94d6ec8027096b0009a8ef51a7 Mon Sep 17 00:00:00 2001 From: Victor Freitas Date: Tue, 23 May 2017 13:05:43 -0300 Subject: [PATCH 01/22] Add variable resource --- .idea/vcs.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 5b4f5117ccfe99306d0585dba75950552b6762b0 Mon Sep 17 00:00:00 2001 From: Victor Freitas Date: Tue, 23 May 2017 13:05:58 -0300 Subject: [PATCH 02/22] Add variable resource --- Model/Transactions/Methods/Abandoned.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Model/Transactions/Methods/Abandoned.php b/Model/Transactions/Methods/Abandoned.php index 861bc53..ae0ff43 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 */ From 7b4e959293b3ed48ce639e65705ff7f230c5f2e8 Mon Sep 17 00:00:00 2001 From: Victor Freitas Date: Tue, 23 May 2017 17:38:35 -0300 Subject: [PATCH 03/22] Bug fixes in refund, cancellation, abandonment and conciliation --- Controller/Adminhtml/Cancellation/Cancel.php | 1 - Controller/Adminhtml/Cancellation/Request.php | 15 +++++++-------- Controller/Adminhtml/Conciliation/Conciliate.php | 13 ++++++------- Controller/Adminhtml/Conciliation/Request.php | 15 +++++++-------- Controller/Adminhtml/Refund/Request.php | 16 ++++++++-------- Model/Transactions/Methods/Abandoned.php | 5 ++++- Model/Transactions/Methods/Refund.php | 9 +++++++++ 7 files changed, 41 insertions(+), 33 deletions(-) diff --git a/Controller/Adminhtml/Cancellation/Cancel.php b/Controller/Adminhtml/Cancellation/Cancel.php index 32edee6..5576043 100755 --- a/Controller/Adminhtml/Cancellation/Cancel.php +++ b/Controller/Adminhtml/Cancellation/Cancel.php @@ -53,7 +53,6 @@ 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'), diff --git a/Controller/Adminhtml/Cancellation/Request.php b/Controller/Adminhtml/Cancellation/Request.php index 2acc83d..24e8d92 100755 --- a/Controller/Adminhtml/Cancellation/Request.php +++ b/Controller/Adminhtml/Cancellation/Request.php @@ -52,14 +52,13 @@ 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\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..338ec3e 100755 --- a/Controller/Adminhtml/Conciliation/Conciliate.php +++ b/Controller/Adminhtml/Conciliation/Conciliate.php @@ -52,13 +52,12 @@ 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\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..c6acf38 100755 --- a/Controller/Adminhtml/Conciliation/Request.php +++ b/Controller/Adminhtml/Conciliation/Request.php @@ -55,14 +55,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->getRequest()->getParam('days') + $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'), + $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/Model/Transactions/Methods/Abandoned.php b/Model/Transactions/Methods/Abandoned.php index 01e1050..f3f0fab 100755 --- a/Model/Transactions/Methods/Abandoned.php +++ b/Model/Transactions/Methods/Abandoned.php @@ -106,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, @@ -117,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 */ @@ -187,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/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 */ From 6173c03a752e8f98b283898d51837744fb04f9c1 Mon Sep 17 00:00:00 2001 From: Victor Freitas Date: Tue, 23 May 2017 17:42:25 -0300 Subject: [PATCH 04/22] Delete .idea --- .idea/vcs.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 30cb0dbaeff50b52d433aaa82357ce465baca2fc Mon Sep 17 00:00:00 2001 From: Victor Freitas Date: Tue, 30 May 2017 11:03:02 -0300 Subject: [PATCH 05/22] Correction of methods --- Controller/Adminhtml/Cancellation/Cancel.php | 1 + Controller/Adminhtml/Cancellation/Request.php | 1 + Controller/Adminhtml/Conciliation/Conciliate.php | 1 + Controller/Adminhtml/Conciliation/Request.php | 1 + Model/Transactions/Methods/Cancellation.php | 8 ++++++++ Model/Transactions/Methods/Conciliation.php | 3 +++ 6 files changed, 15 insertions(+) diff --git a/Controller/Adminhtml/Cancellation/Cancel.php b/Controller/Adminhtml/Cancellation/Cancel.php index 5576043..63e29d6 100755 --- a/Controller/Adminhtml/Cancellation/Cancel.php +++ b/Controller/Adminhtml/Cancellation/Cancel.php @@ -53,6 +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\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 24e8d92..123464e 100755 --- a/Controller/Adminhtml/Cancellation/Request.php +++ b/Controller/Adminhtml/Cancellation/Request.php @@ -53,6 +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\Model\ResourceModel\Db\Context'), $this->_objectManager->create('Magento\Backend\Model\Session'), $this->_objectManager->create('Magento\Sales\Model\Order'), diff --git a/Controller/Adminhtml/Conciliation/Conciliate.php b/Controller/Adminhtml/Conciliation/Conciliate.php index 338ec3e..7c80f53 100755 --- a/Controller/Adminhtml/Conciliation/Conciliate.php +++ b/Controller/Adminhtml/Conciliation/Conciliate.php @@ -53,6 +53,7 @@ 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'), diff --git a/Controller/Adminhtml/Conciliation/Request.php b/Controller/Adminhtml/Conciliation/Request.php index c6acf38..709d547 100755 --- a/Controller/Adminhtml/Conciliation/Request.php +++ b/Controller/Adminhtml/Conciliation/Request.php @@ -56,6 +56,7 @@ 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'), 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 */ From 157dc77ee9e72704705dc46e8a2a0aca7566296e Mon Sep 17 00:00:00 2001 From: Victor Freitas Date: Wed, 31 May 2017 17:12:59 -0300 Subject: [PATCH 06/22] Correction of title problem at the time of payment completion --- .../web/js/view/payment/method-renderer/payment-method.js | 1 + 1 file changed, 1 insertion(+) diff --git a/view/frontend/web/js/view/payment/method-renderer/payment-method.js b/view/frontend/web/js/view/payment/method-renderer/payment-method.js index 7d6bcbc..939c081 100644 --- a/view/frontend/web/js/view/payment/method-renderer/payment-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/payment-method.js @@ -61,6 +61,7 @@ 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); From 203ce9fcfb19c8013bfab5038af2128d149c2195 Mon Sep 17 00:00:00 2001 From: Victor Freitas Date: Tue, 13 Jun 2017 11:20:43 -0300 Subject: [PATCH 07/22] Added status cancellation lightbox --- Controller/Payment/Cancel.php | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Controller/Payment/Cancel.php 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('/'); + + } +} From 13e3e424c41994e6ded520b899d7180e30bf8427 Mon Sep 17 00:00:00 2001 From: Victor Freitas Date: Tue, 13 Jun 2017 11:30:30 -0300 Subject: [PATCH 08/22] Add redirect cancel controller --- view/frontend/templates/checkout.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'); ?>'; } }); } From a87bdc54a4b1b84613135cb1b66b906518ce034a Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Tue, 26 Sep 2017 16:25:36 -0300 Subject: [PATCH 09/22] refactor: created, updated and deleted files to change direct payment flow to the Magento 2 default checkout page feature: added direct payment methods configuration section in the module admin feature: added direct payment radio buttons in the the Magento 2 default checkout page --- Model/Payment.php | 11 +- Model/PaymentBoleto.php | 156 ++++++++++++++++++ Model/PaymentCreditCard.php | 156 ++++++++++++++++++ Model/PaymentDefaultlLightbox.php | 156 ++++++++++++++++++ Model/PaymentOnlineDebit.php | 156 ++++++++++++++++++ Model/System/Config/Checkout.php | 7 +- etc/adminhtml/system.xml | 74 +-------- .../system/general_configuration.xml | 71 ++++++++ etc/adminhtml/system/payment_boleto.xml | 20 +++ .../system/payment_configuration.xml | 12 ++ etc/adminhtml/system/payment_credit_card.xml | 20 +++ .../system/payment_default_lightbox.xml | 29 ++++ etc/adminhtml/system/payment_online_debit.xml | 20 +++ etc/config.xml | 31 +++- view/frontend/layout/checkout_index_index.xml | 12 ++ .../payment/method-renderer/boleto-method.js | 82 +++++++++ .../method-renderer/credit_card-method.js | 82 +++++++++ .../default_lightbox-method.js | 82 +++++++++ .../method-renderer/online_debit-method.js | 82 +++++++++ view/frontend/web/js/view/payment/payment.js | 16 ++ .../web/template/payment/boleto-form.html | 50 ++++++ .../template/payment/credit-card-form.html | 50 ++++++ .../payment/default-lightbox-form.html | 50 ++++++ .../template/payment/online-debit-form.html | 50 ++++++ 24 files changed, 1396 insertions(+), 79 deletions(-) create mode 100644 Model/PaymentBoleto.php create mode 100644 Model/PaymentCreditCard.php create mode 100644 Model/PaymentDefaultlLightbox.php create mode 100644 Model/PaymentOnlineDebit.php create mode 100644 etc/adminhtml/system/general_configuration.xml create mode 100644 etc/adminhtml/system/payment_boleto.xml create mode 100644 etc/adminhtml/system/payment_configuration.xml create mode 100644 etc/adminhtml/system/payment_credit_card.xml create mode 100644 etc/adminhtml/system/payment_default_lightbox.xml create mode 100644 etc/adminhtml/system/payment_online_debit.xml create mode 100644 view/frontend/web/js/view/payment/method-renderer/boleto-method.js create mode 100644 view/frontend/web/js/view/payment/method-renderer/credit_card-method.js create mode 100644 view/frontend/web/js/view/payment/method-renderer/default_lightbox-method.js create mode 100644 view/frontend/web/js/view/payment/method-renderer/online_debit-method.js create mode 100644 view/frontend/web/template/payment/boleto-form.html create mode 100644 view/frontend/web/template/payment/credit-card-form.html create mode 100644 view/frontend/web/template/payment/default-lightbox-form.html create mode 100644 view/frontend/web/template/payment/online-debit-form.html 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..1f4a710 --- /dev/null +++ b/Model/PaymentBoleto.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/PaymentCreditCard.php b/Model/PaymentCreditCard.php new file mode 100644 index 0000000..c1065d7 --- /dev/null +++ b/Model/PaymentCreditCard.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/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/PaymentOnlineDebit.php b/Model/PaymentOnlineDebit.php new file mode 100644 index 0000000..f1449d4 --- /dev/null +++ b/Model/PaymentOnlineDebit.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/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/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 5ecf53d..243fc65 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..aa71566 --- /dev/null +++ b/etc/adminhtml/system/payment_boleto.xml @@ -0,0 +1,20 @@ + + + + + + + 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 + + + diff --git a/etc/adminhtml/system/payment_configuration.xml b/etc/adminhtml/system/payment_configuration.xml new file mode 100644 index 0000000..09458cd --- /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..268e458 --- /dev/null +++ b/etc/adminhtml/system/payment_credit_card.xml @@ -0,0 +1,20 @@ + + + + + + + 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 + + + diff --git a/etc/adminhtml/system/payment_default_lightbox.xml b/etc/adminhtml/system/payment_default_lightbox.xml new file mode 100644 index 0000000..19f45f0 --- /dev/null +++ b/etc/adminhtml/system/payment_default_lightbox.xml @@ -0,0 +1,29 @@ + + + + + + + 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 + + + diff --git a/etc/adminhtml/system/payment_online_debit.xml b/etc/adminhtml/system/payment_online_debit.xml new file mode 100644 index 0000000..d252155 --- /dev/null +++ b/etc/adminhtml/system/payment_online_debit.xml @@ -0,0 +1,20 @@ + + + + + + + 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 + + + diff --git a/etc/config.xml b/etc/config.xml index 8e17bcb..d3e2492 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,7 +1,7 @@ +
+
+ + +
+
+

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

+
+
+ +
+
+
+
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..74be337 --- /dev/null +++ b/view/frontend/web/template/payment/credit-card-form.html @@ -0,0 +1,50 @@ + +
+
+ + +
+
+

Cartão de crédito: Com o PagSeguro, você pode escolher como quer pagar e ainda parcelar sua compra em até 18x.

+
+
+ +
+
+
+
diff --git a/view/frontend/web/template/payment/default-lightbox-form.html b/view/frontend/web/template/payment/default-lightbox-form.html new file mode 100644 index 0000000..53062f6 --- /dev/null +++ b/view/frontend/web/template/payment/default-lightbox-form.html @@ -0,0 +1,50 @@ + +
+
+ + +
+
+

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

+
+
+ +
+
+
+
diff --git a/view/frontend/web/template/payment/online-debit-form.html b/view/frontend/web/template/payment/online-debit-form.html new file mode 100644 index 0000000..fbbbb23 --- /dev/null +++ b/view/frontend/web/template/payment/online-debit-form.html @@ -0,0 +1,50 @@ + +
+
+ + +
+
+

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

+
+
+ +
+
+
+
From c3224a951ebf0d7da6829451d0c3348bb8370870 Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Fri, 29 Sep 2017 16:45:02 -0300 Subject: [PATCH 10/22] feature: add sort order value to payment methods feature: add billing address form in the payment methods in the checkout page, for edit or, when is a guest, to put billing data required for checkout fix: attribute group id pattern (use '_' instead of '-') --- etc/adminhtml/system.xml | 2 +- etc/adminhtml/system/payment_boleto.xml | 10 ++++++++++ etc/adminhtml/system/payment_configuration.xml | 2 +- etc/adminhtml/system/payment_credit_card.xml | 10 ++++++++++ etc/adminhtml/system/payment_default_lightbox.xml | 10 ++++++++++ etc/adminhtml/system/payment_online_debit.xml | 10 ++++++++++ etc/config.xml | 2 +- .../web/template/payment/boleto-form.html | 13 +++++++++++++ .../web/template/payment/credit-card-form.html | 13 +++++++++++++ .../template/payment/default-lightbox-form.html | 14 ++++++++++++++ .../web/template/payment/online-debit-form.html | 15 ++++++++++++++- 11 files changed, 97 insertions(+), 4 deletions(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 243fc65..c9ea11b 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -25,7 +25,7 @@
- diff --git a/etc/adminhtml/system/payment_boleto.xml b/etc/adminhtml/system/payment_boleto.xml index aa71566..04b1590 100644 --- a/etc/adminhtml/system/payment_boleto.xml +++ b/etc/adminhtml/system/payment_boleto.xml @@ -16,5 +16,15 @@ 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 index 09458cd..3a44e8a 100644 --- a/etc/adminhtml/system/payment_configuration.xml +++ b/etc/adminhtml/system/payment_configuration.xml @@ -1,6 +1,6 @@ - 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 index 268e458..086b182 100644 --- a/etc/adminhtml/system/payment_credit_card.xml +++ b/etc/adminhtml/system/payment_credit_card.xml @@ -16,5 +16,15 @@ 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 index 19f45f0..79fcb3c 100644 --- a/etc/adminhtml/system/payment_default_lightbox.xml +++ b/etc/adminhtml/system/payment_default_lightbox.xml @@ -25,5 +25,15 @@ 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 index d252155..71c3f3c 100644 --- a/etc/adminhtml/system/payment_online_debit.xml +++ b/etc/adminhtml/system/payment_online_debit.xml @@ -16,5 +16,15 @@ 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 d3e2492..db09674 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -35,7 +35,7 @@ pagseguro - PagSeguro Default Lightbox + PagSeguro 0 UOL\PagSeguro\Model\PaymentDefaultlLightbox pagseguro_iniciado diff --git a/view/frontend/web/template/payment/boleto-form.html b/view/frontend/web/template/payment/boleto-form.html index b86ac6a..b289e86 100644 --- a/view/frontend/web/template/payment/boleto-form.html +++ b/view/frontend/web/template/payment/boleto-form.html @@ -31,6 +31,19 @@

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

+ + + +
+ + + +
+
+ + + +
-

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

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

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

-

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

@@ -39,11 +38,67 @@
+ + +
+ +
+ + +
+ + + +
This is a required field.
+ +
+
+
+
+
    +
  • 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 From e1f3d82d7e10e036ce227b093c4fc6f68073ffa7 Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Sat, 25 Nov 2017 17:26:25 -0200 Subject: [PATCH 12/22] feature: add pagseguro online debit payment to magento checkout page refactor: boleto files --- Controller/Payment/Request.php | 70 +++++++++++++++---- Model/PaymentBoleto.php | 14 +--- Model/PaymentOnlineDebit.php | 57 +++++---------- view/frontend/templates/success.phtml | 54 +++++++------- .../payment/method-renderer/boleto-method.js | 3 +- .../method-renderer/online_debit-method.js | 41 ++++++++--- .../web/template/payment/boleto-form.html | 10 +-- .../template/payment/online-debit-form.html | 64 ++++++++++++++++- 8 files changed, 202 insertions(+), 111 deletions(-) diff --git a/Controller/Payment/Request.php b/Controller/Payment/Request.php index 616fe2c..341de1a 100755 --- a/Controller/Payment/Request.php +++ b/Controller/Payment/Request.php @@ -25,6 +25,7 @@ use UOL\PagSeguro\Model\PaymentMethod; use UOL\PagSeguro\Model\Direct\BoletoMethod; +use UOL\PagSeguro\Model\Direct\DebitMethod; /** * Class Request @@ -110,23 +111,55 @@ public function execute() 'order_id' => $this->orderId ] ); - $this->placeOrder($boleto); + $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')); } - - die('boletão'); } - var_dump($this->_checkoutSession->getLastRealOrder()->getEntityId());die(); + 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."); + } + $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')); + } + } + die('request o/'); - try { return $this->_redirect($this->_payment->createPaymentRequest()); } catch (\Exception $exception) { @@ -166,13 +199,13 @@ private function helperData() /** * Place order * - * @param $boleto - * @return Boleto + * @param $payment + * @return string */ - private function placeOrder($boleto) + private function placeOrder($payment, $method) { $this->changeOrderHistory('pagseguro_aguardando_pagamento'); - return $this->whenSuccess($boleto->createPaymentRequest()); + return $this->whenSuccess($payment->createPaymentRequest(), $method); } /** @@ -194,9 +227,9 @@ private function changeOrderHistory($status) * @param $response * @return $this */ - private function whenSuccess($response) + private function whenSuccess($response, $method) { - $this->makeSession($response); + $this->makeSession($response, $method); return $this->result->setData([ 'success' => true, 'payload' => [ @@ -210,11 +243,11 @@ private function whenSuccess($response) * * @param $response */ - private function makeSession($response) + private function makeSession($response, $method) { $this->session()->setData([ 'pagseguro_payment' => ['payment_link' => $response->getPaymentLink(), - 'payment_type' => 'uol\pagseguro\controller\direct\boleto',//strtolower(Boleto::class), + 'payment_type' => $method, 'order_id' => $this->orderId, ] ]); @@ -264,5 +297,14 @@ 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/Model/PaymentBoleto.php b/Model/PaymentBoleto.php index a9371d7..6ef4a2a 100644 --- a/Model/PaymentBoleto.php +++ b/Model/PaymentBoleto.php @@ -24,7 +24,6 @@ namespace UOL\PagSeguro\Model; use Magento\Sales\Model\Order\Payment as PaymentOrder; -use Magento\Checkout\Model\Session as CheckoutSession; /** * Model Class PaymentBoleto, it is the model from PagSeguro Boleto payment method @@ -80,8 +79,7 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, - \Magento\Checkout\Model\Cart $cart, - CheckoutSession $checkoutSession + \Magento\Checkout\Model\Cart $cart ) { parent::__construct( @@ -95,14 +93,6 @@ public function __construct( ); /** @var \Magento\Checkout\Model\Cart _cart */ $this->_cart = $cart; - $this->_checkoutSession = $checkoutSession; - } - /** - * @return \Magento\Checkout\Model\Session - */ - public function getCheckoutSession() - { - return $this->_checkoutSession; } /** @@ -119,12 +109,10 @@ public function assignData(\Magento\Framework\DataObject $data) $info = $this->getInfoInstance(); if (isset($data->getData('additional_data')['boleto_document'])) { $info->setAdditionalInformation('boleto_document', $data->getData('additional_data')['boleto_document']); - $this->getCheckoutSession()->setBoletoDocument($data->getData('additional_data')['boleto_document']); } if (isset($data->getData('additional_data')['boleto_hash'])) { $info->setAdditionalInformation('hash', $data->getData('additional_data')['boleto_hash']); - $this->getCheckoutSession()->setHash($data->getData('additional_data')['boleto_hash']); } return $this; diff --git a/Model/PaymentOnlineDebit.php b/Model/PaymentOnlineDebit.php index f1449d4..bdb0418 100644 --- a/Model/PaymentOnlineDebit.php +++ b/Model/PaymentOnlineDebit.php @@ -38,7 +38,7 @@ class PaymentOnlineDebit extends \Magento\Payment\Model\Method\AbstractMethod /** * @var string */ - protected $_code = self::PAYMENT_METHOD_PAGSEGURO_CODE; + protected $_code = self::PAYMENT_METHOD_PAGSEGURO_CODE; /** * @var bool */ @@ -94,39 +94,30 @@ public function __construct( } /** - * Check if checkout type is direct + * Assign data to info model instance * - * @return bool + * @param \Magento\Framework\DataObject $data + * @return \Magento\Payment\Model\Info + * @throws \Magento\Framework\Exception\LocalizedException */ - public function isDirectCheckout() + public function assignData(\Magento\Framework\DataObject $data) { -// if ($this->getConfigData('checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::DIRECT) { -// return true; -// } - return false; - } + parent::assignData($data); - /** - * Check if checkout type is lightbox - * - * @return bool - */ - public function isLightboxCheckoutType() - { - if ($this->getConfigData('checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::LIGHTBOX) { - return true; + $info = $this->getInfoInstance(); + if (isset($data->getData('additional_data')['online_debit_document'])) { + $info->setAdditionalInformation('online_debit_document', $data->getData('additional_data')['online_debit_document']); } - return false; - } - /** - * Get lightbox checkout payment url - * - * @return url - */ - public function getLightboxCheckoutPaymentUrl() - { - return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/payment/checkout/"); + 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; } /** @@ -138,16 +129,6 @@ 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 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/js/view/payment/method-renderer/boleto-method.js b/view/frontend/web/js/view/payment/method-renderer/boleto-method.js index fd4351f..9a5181a 100644 --- a/view/frontend/web/js/view/payment/method-renderer/boleto-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/boleto-method.js @@ -34,13 +34,12 @@ define( 'UOL_PagSeguro/js/model/boleto-validator', window.checkoutConfig.library.directPaymentJs ], - function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, boletoValidator, PagSeguroD) { + function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, boletoValidator) { 'use strict'; return Component.extend({ defaults: { template: 'UOL_PagSeguro/payment/boleto-form', -// boletoDocument: '', brazilFlagPath: window.checkoutConfig.brazilFlagPath }, 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 index 891e117..569dbea 100644 --- 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 @@ -31,13 +31,26 @@ define( 'Magento_Checkout/js/model/full-screen-loader', 'Magento_Checkout/js/action/set-payment-information', 'Magento_Checkout/js/action/place-order', + 'UOL_PagSeguro/js/model/boleto-validator', + window.checkoutConfig.library.directPaymentJs ], - function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder) { + function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, boletoValidator) { 'use strict'; return Component.extend({ defaults: { - template: 'UOL_PagSeguro/payment/online-debit-form' + template: 'UOL_PagSeguro/payment/online-debit-form', + brazilFlagPath: window.checkoutConfig.brazilFlagPath + }, + + initObservable: function () { + + this._super() + .observe([ + 'onlineDebitDocument', + 'checkedBank' + ]); + return this; }, context: function() { @@ -52,24 +65,30 @@ define( * @override */ placeOrder: function () { - var self = this; var paymentData = quote.paymentMethod(); var messageContainer = this.messageContainer; + /* @TODO verify if session id is already set */ + PagSeguroDirectPayment.setSessionId(window.checkoutConfig.library.session); fullScreenLoader.startLoader(); this.isPlaceOrderActionAllowed(false); + if (self.onlineDebitDocument() == '') { + fullScreenLoader.stopLoader(); + boletoValidator.documentValidator(); + this.isPlaceOrderActionAllowed(true); + return; + } $.when(setPaymentInformationAction(this.messageContainer, { - 'method': self.getCode() + 'method': self.getCode(), + 'additional_data': { + 'online_debit_document': self.onlineDebitDocument(), + 'online_debit_hash': PagSeguroDirectPayment.getSenderHash(), + 'online_debit_bank' : self.checkedBank() + } })).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){ - $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.lightbox); - } else { - $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.standard); - } + $.mage.redirect(window.checkoutConfig.pagseguro_boleto); }); }).fail(function () { self.isPlaceOrderActionAllowed(true); diff --git a/view/frontend/web/template/payment/boleto-form.html b/view/frontend/web/template/payment/boleto-form.html index 5a86813..e4776ca 100644 --- a/view/frontend/web/template/payment/boleto-form.html +++ b/view/frontend/web/template/payment/boleto-form.html @@ -42,16 +42,16 @@
-
- - +
+
+ +
+ + + +
+ + +
+ + + +
This is a required field.
+ +
+
+ +
+ + +
+ + + + +
+
+ +
+
+ Esta compra está sendo feita no Brasil + +
+
+
+
-

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

+
- + +
-
+
@@ -58,14 +59,24 @@ id="boletoDocument" name="payment[boleto_document]" type="text" - data-validate="{required:true}" + data-validate="{'required-entry':true}" data-bind="attr: { id: getCode() + '_boleto_document', 'data-container': getCode() + '_boleto_document'}, enable: true, textInput: boletoDocument, - valueUpdate: 'input' + valueUpdate: 'input', + event: { + blur: validateDocument(document.getElementById('pagseguro_boleto_boleto_document')) + } "/> + + + + + + +
From f8942dc2279d77442687a9d0bf331ec1b761310c Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Sun, 26 Nov 2017 19:59:59 -0200 Subject: [PATCH 14/22] add: validation before place order in boleto and online debit payment refactor: boleto and online debit view and javascript files --- Controller/Payment/Request.php | 11 ++++- ...lidator.js => direct-payment-validator.js} | 12 +++++ .../payment/method-renderer/boleto-method.js | 25 ++++++++--- .../method-renderer/online_debit-method.js | 27 +++++++++--- .../web/template/payment/boleto-form.html | 4 +- .../template/payment/online-debit-form.html | 44 +++++++++++++------ 6 files changed, 94 insertions(+), 29 deletions(-) rename view/frontend/web/js/model/{boleto-validator.js => direct-payment-validator.js} (97%) diff --git a/Controller/Payment/Request.php b/Controller/Payment/Request.php index 3a58eea..def522a 100755 --- a/Controller/Payment/Request.php +++ b/Controller/Payment/Request.php @@ -98,7 +98,8 @@ public function execute() throw new \Exception("There is no order associated with this session."); } - if (!isset($paymentData['additional_information']['boleto_document']) || isset($paymentData['additional_information']['hash'])) { + 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"); } @@ -132,9 +133,17 @@ public function execute() 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 */ diff --git a/view/frontend/web/js/model/boleto-validator.js b/view/frontend/web/js/model/direct-payment-validator.js similarity index 97% rename from view/frontend/web/js/model/boleto-validator.js rename to view/frontend/web/js/model/direct-payment-validator.js index 7ed086b..4b7d8e3 100644 --- a/view/frontend/web/js/model/boleto-validator.js +++ b/view/frontend/web/js/model/direct-payment-validator.js @@ -53,6 +53,18 @@ define( * form input masks and validations and calls to the pagseguro js api */ +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 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 index 9a5181a..f8d26ae 100644 --- a/view/frontend/web/js/view/payment/method-renderer/boleto-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/boleto-method.js @@ -31,10 +31,10 @@ define( 'Magento_Checkout/js/model/full-screen-loader', 'Magento_Checkout/js/action/set-payment-information', 'Magento_Checkout/js/action/place-order', - 'UOL_PagSeguro/js/model/boleto-validator', + 'UOL_PagSeguro/js/model/direct-payment-validator', window.checkoutConfig.library.directPaymentJs ], - function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, boletoValidator) { + function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, directPaymentValidator) { 'use strict'; return Component.extend({ @@ -68,6 +68,15 @@ define( } }; }, + + 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 @@ -79,13 +88,12 @@ define( PagSeguroDirectPayment.setSessionId(window.checkoutConfig.library.session); fullScreenLoader.startLoader(); this.isPlaceOrderActionAllowed(false); - if (self.boletoDocument() == '') { + if (! self.validatePlaceOrder()) { fullScreenLoader.stopLoader(); - console.log('exibir erros e reabilitar o botão do place order'); - boletoValidator.documentValidator(); this.isPlaceOrderActionAllowed(true); return; } + $.when(setPaymentInformationAction(this.messageContainer, { 'method': self.getCode(), 'additional_data': { @@ -93,8 +101,7 @@ define( 'boleto_hash': PagSeguroDirectPayment.getSenderHash() } })).done(function () { - delete paymentData['title']; - + delete paymentData['title']; $.when(placeOrder(paymentData, messageContainer)).done(function () { $.mage.redirect(window.checkoutConfig.pagseguro_boleto); }); @@ -103,6 +110,10 @@ define( }).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/online_debit-method.js b/view/frontend/web/js/view/payment/method-renderer/online_debit-method.js index 569dbea..10e87a0 100644 --- 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 @@ -31,10 +31,10 @@ define( 'Magento_Checkout/js/model/full-screen-loader', 'Magento_Checkout/js/action/set-payment-information', 'Magento_Checkout/js/action/place-order', - 'UOL_PagSeguro/js/model/boleto-validator', + 'UOL_PagSeguro/js/model/direct-payment-validator', window.checkoutConfig.library.directPaymentJs ], - function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, boletoValidator) { + function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, directPaymentValidator) { 'use strict'; return Component.extend({ @@ -68,16 +68,17 @@ define( var self = this; var paymentData = quote.paymentMethod(); var messageContainer = this.messageContainer; - /* @TODO verify if session id is already set */ - PagSeguroDirectPayment.setSessionId(window.checkoutConfig.library.session); fullScreenLoader.startLoader(); this.isPlaceOrderActionAllowed(false); - if (self.onlineDebitDocument() == '') { + + if (! self.validatePlaceOrder(self.checkedBank())) { fullScreenLoader.stopLoader(); - boletoValidator.documentValidator(); 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': { @@ -95,6 +96,20 @@ define( }).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/template/payment/boleto-form.html b/view/frontend/web/template/payment/boleto-form.html index 52f4a66..9f171e4 100644 --- a/view/frontend/web/template/payment/boleto-form.html +++ b/view/frontend/web/template/payment/boleto-form.html @@ -59,6 +59,7 @@ id="boletoDocument" name="payment[boleto_document]" type="text" + maxlength="18" data-validate="{'required-entry':true}" data-bind="attr: { id: getCode() + '_boleto_document', @@ -75,8 +76,7 @@ - - + -
+
@@ -58,13 +58,18 @@ class="input-text required-entry required" name="payment[online_debit_document]" type="text" + maxlength="18" + minLength="11" data-validate="{required:true}" data-bind="attr: { id: getCode() + '_online_debit_document', 'data-container': getCode() + '_online_debit_document'}, enable: true, textInput: onlineDebitDocument, - valueUpdate: 'input' + valueUpdate: 'input', + event: { + blur: validateDocument(document.getElementById('pagseguro_online_debit_online_debit_document')) + } "/> - -
This is a required field.
- + +
@@ -85,13 +89,27 @@
- - - - + + + +
+ +
Esta compra está sendo feita no Brasil From a707d0375dcfa3e6d8e78b762172c4fd99d813ae Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Sun, 26 Nov 2017 21:02:38 -0200 Subject: [PATCH 15/22] refactor: pagseguro default/lightbox payment --- Controller/Payment/Request.php | 1 - Helper/Library.php | 2 +- Model/PaymentConfigProvider.php | 4 ++-- .../web/js/view/payment/method-renderer/boleto-method.js | 2 +- .../view/payment/method-renderer/default_lightbox-method.js | 4 +--- .../frontend/web/template/payment/default-lightbox-form.html | 5 ++++- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Controller/Payment/Request.php b/Controller/Payment/Request.php index def522a..9ca2106 100755 --- a/Controller/Payment/Request.php +++ b/Controller/Payment/Request.php @@ -173,7 +173,6 @@ public function execute() } } - die('request o/'); try { return $this->_redirect($this->_payment->createPaymentRequest()); } catch (\Exception $exception) { diff --git a/Helper/Library.php b/Helper/Library.php index 720b72a..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; } diff --git a/Model/PaymentConfigProvider.php b/Model/PaymentConfigProvider.php index 5dc9a46..40d76fe 100644 --- a/Model/PaymentConfigProvider.php +++ b/Model/PaymentConfigProvider.php @@ -35,7 +35,7 @@ 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'; @@ -77,7 +77,7 @@ public function getConfig() ], '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' => [ 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 index f8d26ae..bab6300 100644 --- a/view/frontend/web/js/view/payment/method-renderer/boleto-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/boleto-method.js @@ -68,7 +68,7 @@ define( } }; }, - + doDocumentMask: function(data, event) { //directPaymentValidator.documentValidator(document.getElementById('pagseguro_boleto_boleto_document')); //value.length diff --git a/view/frontend/web/js/view/payment/method-renderer/default_lightbox-method.js b/view/frontend/web/js/view/payment/method-renderer/default_lightbox-method.js index 74d830a..7f48c8a 100644 --- a/view/frontend/web/js/view/payment/method-renderer/default_lightbox-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/default_lightbox-method.js @@ -63,9 +63,7 @@ define( })).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/template/payment/default-lightbox-form.html b/view/frontend/web/template/payment/default-lightbox-form.html index 42512bd..2e5efd7 100644 --- a/view/frontend/web/template/payment/default-lightbox-form.html +++ b/view/frontend/web/template/payment/default-lightbox-form.html @@ -30,7 +30,10 @@
-

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

+
    +
  • Com o PagSeguro, você pode escolher como quer pagar e ainda parcelar sua compra em até 18x.
  • +
  • Ao finalizar sua compra você será redirecionado para o PagSeguro.
  • +
From 741dd99065963fc32ba08f3aea88a19c6fa20a7b Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Wed, 29 Nov 2017 23:36:00 -0200 Subject: [PATCH 16/22] added credit card form inputs: credit card (cc) number, cc holder name, cc expiration date, cc code, cc document and cc birthdate --- view/frontend/web/js/model/credit-card.js | 276 ++++++++++++++++++ .../method-renderer/credit_card-method.js | 59 +++- .../template/payment/credit-card-form.html | 215 +++++++++++++- 3 files changed, 547 insertions(+), 3 deletions(-) create mode 100644 view/frontend/web/js/model/credit-card.js 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..2c4c4b0 --- /dev/null +++ b/view/frontend/web/js/model/credit-card.js @@ -0,0 +1,276 @@ +/** + * 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 + */ + +//define( +// [], +// function () { +// 'use strict'; +// return { +// /** +// * Validate something +// * +// * @returns {boolean} +// */ +// validate: function() { +// //Put your validation logic here +// console.log('validated'); +// return true; +// } +// } +// } +//); + + +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) + 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 test(id) { + console.log(id); +} + +function getBrand(self) { + if (validateCreditCard(self)) { + PagSeguroDirectPayment.getBrand({ + cardBin: unmask(document.getElementById('pagseguro_credit_card_number').value), + success: function (response) { + console.log('sucesso na chamada');//// + 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');//// + displayError(document.getElementById('pagseguro_credit_card_number')) + }, + complete: function(response) { + console.log('tratamento comum para todas chamadas');//// + } + }); + } else { + displayError(document.getElementById('pagseguro_credit_card_number')) + } + return false; +} + +function createCardToken() { + if (validateCreateToken()) { + 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; + }, + error: function (error) { + console.log(error); + }, + } + + PagSeguroDirectPayment.createCardToken(param) + } +} + +function validateCreditCardCode(self, createToken) { + if (self.validity.tooLong || self.validity.tooShort || !self.validity.valid) { + displayError(self) + return false + } else { + displayError(self, false) + if (createToken === true && validateCreateToken()) { + createCardToken(); + } + return true + } +} + +function validateCreditCardForm() { + if ( + validateCreditCard(document.querySelector('#pagseguro_credit_card_number')) && + validateDocument(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')) + ) { + + if (document.getElementById('creditCardToken').value === "") { + createCardToken(); + } + return true; + } + + validateCreditCard(document.querySelector('#pagseguro_credit_card_number')) + validateDocument(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'), false) + && 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'), false); + + 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/view/payment/method-renderer/credit_card-method.js b/view/frontend/web/js/view/payment/method-renderer/credit_card-method.js index d39c542..beb84c1 100644 --- 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 @@ -31,15 +31,70 @@ define( '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) { + function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, directPaymentValidator, creditCard) { 'use strict'; + //set pagseguro session + PagSeguroDirectPayment.setSessionId(window.checkoutConfig.library.session); + //console.log(quote.totals); return Component.extend({ defaults: { - template: 'UOL_PagSeguro/payment/credit-card-form' + template: 'UOL_PagSeguro/payment/credit-card-form', + brazilFlagPath: window.checkoutConfig.brazilFlagPath +// totals: parseFloat( +// _.findLast(q.getTotals()()['total_segments'], 'value').value +// ) }, + initObservable: function () { + + this._super() + .observe([ + 'creditCardDocument' + ]); + return this; + }, + + grandTotal: 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, + '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; }, diff --git a/view/frontend/web/template/payment/credit-card-form.html b/view/frontend/web/template/payment/credit-card-form.html index 719679f..5258b9e 100644 --- a/view/frontend/web/template/payment/credit-card-form.html +++ b/view/frontend/web/template/payment/credit-card-form.html @@ -30,7 +30,6 @@
-

Cartão de crédito: Com o PagSeguro, você pode escolher como quer pagar e ainda parcelar sua compra em até 18x.

@@ -39,6 +38,220 @@
+ +
+ + + + + + + + +
+ + +
+ + +
+
+ + +
+ + +
+ + +
+
+ + +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + + +
+
+ + + +
+
+
+
+ + +
+ + +
+ + +
+
+ + +
+ + +
+ + +
+
+ + +
+ + +
+ + +
+
+ + + + +
+
+ Esta compra está sendo feita no Brasil + +
+
+
+
From 0db4532fe959a594c846a80c7b31aa0f06ac91f4 Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Thu, 30 Nov 2017 21:53:48 -0200 Subject: [PATCH 17/22] feature: add pagseguro credit card payment method in magento default checkout page --- Controller/Payment/Request.php | 83 ++++++++++++-- Model/PaymentCreditCard.php | 72 ++++++------ view/frontend/web/js/model/credit-card.js | 59 +++------- .../web/js/model/direct-payment-validator.js | 73 +++++++----- .../method-renderer/credit_card-method.js | 36 ++++-- .../template/payment/credit-card-form.html | 107 +++++++++++------- 6 files changed, 266 insertions(+), 164 deletions(-) diff --git a/Controller/Payment/Request.php b/Controller/Payment/Request.php index 9ca2106..5d87e5b 100755 --- a/Controller/Payment/Request.php +++ b/Controller/Payment/Request.php @@ -23,9 +23,10 @@ namespace UOL\PagSeguro\Controller\Payment; -use UOL\PagSeguro\Model\PaymentMethod; use UOL\PagSeguro\Model\Direct\BoletoMethod; +use UOL\PagSeguro\Model\Direct\CreditCardMethod; use UOL\PagSeguro\Model\Direct\DebitMethod; +use UOL\PagSeguro\Model\PaymentMethod; /** * Class Request @@ -90,7 +91,6 @@ public function execute() $lastRealOrder = $this->_checkoutSession->getLastRealOrder(); $paymentData = $lastRealOrder->getPayment()->getData(); -// var_dump($paymentData);exit; if ($paymentData['method'] === 'pagseguro_boleto') { try { $this->orderId = $lastRealOrder->getId(); @@ -173,6 +173,62 @@ public function execute() } } + 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) { @@ -252,18 +308,27 @@ private function whenSuccess($response, $method) } /** - * Create new pogseguro payment session data + * Create new pagseguro payment session data * * @param $response */ private function makeSession($response, $method) { - $this->session()->setData([ - 'pagseguro_payment' => ['payment_link' => $response->getPaymentLink(), - 'payment_type' => $method, - 'order_id' => $this->orderId, - ] - ]); + 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, + ] + ]); + } } /** diff --git a/Model/PaymentCreditCard.php b/Model/PaymentCreditCard.php index c1065d7..514ece6 100644 --- a/Model/PaymentCreditCard.php +++ b/Model/PaymentCreditCard.php @@ -94,39 +94,46 @@ public function __construct( } /** - * Check if checkout type is direct + * Assign data to info model instance * - * @return bool + * @param \Magento\Framework\DataObject $data + * @return \Magento\Payment\Model\Info + * @throws \Magento\Framework\Exception\LocalizedException */ - public function isDirectCheckout() + public function assignData(\Magento\Framework\DataObject $data) { -// if ($this->getConfigData('checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::DIRECT) { -// return true; -// } - return false; - } + parent::assignData($data); - /** - * Check if checkout type is lightbox - * - * @return bool - */ - public function isLightboxCheckoutType() - { - if ($this->getConfigData('checkout') == \UOL\PagSeguro\Model\System\Config\Checkout::LIGHTBOX) { - return true; + $info = $this->getInfoInstance(); + if (isset($data->getData('additional_data')['credit_card_document'])) { + $info->setAdditionalInformation('credit_card_document', $data->getData('additional_data')['credit_card_document']); } - return false; - } - /** - * Get lightbox checkout payment url - * - * @return url - */ - public function getLightboxCheckoutPaymentUrl() - { - return $this->_cart->getQuote()->getStore()->getUrl("pagseguro/payment/checkout/"); + 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; } /** @@ -139,16 +146,7 @@ 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/view/frontend/web/js/model/credit-card.js b/view/frontend/web/js/model/credit-card.js index 2c4c4b0..74b5aa5 100644 --- a/view/frontend/web/js/model/credit-card.js +++ b/view/frontend/web/js/model/credit-card.js @@ -19,40 +19,19 @@ * @copyright 2016 PagSeguro Internet Ltda. * @license http://www.apache.org/licenses/LICENSE-2.0 */ - -//define( -// [], -// function () { -// 'use strict'; -// return { -// /** -// * Validate something -// * -// * @returns {boolean} -// */ -// validate: function() { -// //Put your validation logic here -// console.log('validated'); -// return true; -// } -// } -// } -//); - - -function setCreditCardSessionId(session) { - return PagSeguroDirectPayment.setSessionId(session) -} - -function getSenderHash() { - return PagSeguroDirectPayment.getSenderHash() -} - -function assignCreditCardHash() { - setTimeout(function () { - document.getElementById('creditCardHash').value = getSenderHash() - }, 500) -} +//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)) { @@ -107,7 +86,7 @@ function validateCardHolder (self) { } function cardInstallmentOnChange(data) { - data = JSON.parse(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 @@ -157,17 +136,15 @@ function getBrand(self) { PagSeguroDirectPayment.getBrand({ cardBin: unmask(document.getElementById('pagseguro_credit_card_number').value), success: function (response) { - console.log('sucesso na chamada');//// 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');//// - displayError(document.getElementById('pagseguro_credit_card_number')) + console.log('erro na chamada'); }, complete: function(response) { - console.log('tratamento comum para todas chamadas');//// + //console.log('tratamento comum para todas chamadas');//// } }); } else { @@ -212,7 +189,7 @@ function validateCreditCardCode(self, createToken) { function validateCreditCardForm() { if ( validateCreditCard(document.querySelector('#pagseguro_credit_card_number')) && - validateDocument(document.querySelector('#creditCardDocument')) && + validateDocumentFinal(document.querySelector('#creditCardDocument')) && validateCardHolder(document.querySelector('#creditCardHolder')) && validateCreditCardHolderBirthdate(document.querySelector('#creditCardHolderBirthdate')) && validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')) && @@ -228,7 +205,7 @@ function validateCreditCardForm() { } validateCreditCard(document.querySelector('#pagseguro_credit_card_number')) - validateDocument(document.querySelector('#creditCardDocument')) + validateDocumentFinal(document.querySelector('#creditCardDocument')) validateCardHolder(document.querySelector('#creditCardHolder')) validateCreditCardHolderBirthdate(document.querySelector('#creditCardHolderBirthdate')) validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')) diff --git a/view/frontend/web/js/model/direct-payment-validator.js b/view/frontend/web/js/model/direct-payment-validator.js index 4b7d8e3..93b9f04 100644 --- a/view/frontend/web/js/model/direct-payment-validator.js +++ b/view/frontend/web/js/model/direct-payment-validator.js @@ -20,39 +20,56 @@ * @license http://www.apache.org/licenses/LICENSE-2.0 */ -define( - [], - function () { - 'use strict'; - return { - /** - * Validate something - * - * @returns {boolean} - */ - documentValidator: function(el) { -// var value = unmask(el.value) -// console.log(value); -// console.log(value.length); -// if (value.length === 11) { -// return validateCpf(self) -// } else if (value.length === 14) { -// return validateCnpj(self) -// } else { -// displayError(self) -// return false -// } - }, - } - } -); - - /* * 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) { 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 index beb84c1..3f460b0 100644 --- 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 @@ -37,6 +37,7 @@ define( ], function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, directPaymentValidator, creditCard) { 'use strict'; + /* @TODO verify if session id is already set */ //set pagseguro session PagSeguroDirectPayment.setSessionId(window.checkoutConfig.library.session); @@ -59,11 +60,11 @@ define( return this; }, - grandTotal: function() { + 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(x); //console.log(y); return parseFloat(x); }, @@ -107,30 +108,43 @@ define( * @override */ placeOrder: function () { - var self = this; var paymentData = quote.paymentMethod(); var messageContainer = this.messageContainer; fullScreenLoader.startLoader(); this.isPlaceOrderActionAllowed(false); + + if (! self.validatePlaceOrder()) { + fullScreenLoader.stopLoader(); + this.isPlaceOrderActionAllowed(true); + return; + } + $.when(setPaymentInformationAction(this.messageContainer, { - 'method': self.getCode() + 'method': self.getCode(), + 'additional_data': { + 'credit_card_document': self.creditCardDocument(), + 'credit_card_hash' : 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 () { - if (window.checkoutConfig.payment.pagseguro.isDirect) { - $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.direct); - } else if (window.checkoutConfig.payment.pagseguro.isLightbox){ - $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.lightbox); - } else { - $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.standard); - } + $.mage.redirect(window.checkoutConfig.pagseguro_boleto); }); }).fail(function () { self.isPlaceOrderActionAllowed(true); }).always(function(){ fullScreenLoader.stopLoader(); }); + }, + + validatePlaceOrder: function() { + return validateCreditCardForm(); } }); } diff --git a/view/frontend/web/template/payment/credit-card-form.html b/view/frontend/web/template/payment/credit-card-form.html index 5258b9e..66c2bff 100644 --- a/view/frontend/web/template/payment/credit-card-form.html +++ b/view/frontend/web/template/payment/credit-card-form.html @@ -40,12 +40,11 @@
- - + - +
@@ -59,7 +58,7 @@ name="payment[credit_card_number]" type="text" maxlength="19" - minLength="16" + minlength="16" data-validate="{required:true}" data-bind="attr: { id: getCode() + '_number', @@ -68,8 +67,7 @@ valueUpdate: 'input', event: { blur : getBrand.bind($data, document.getElementById('pagseguro_credit_card_number')), - keydown: creditCardMask.bind($data, document.getElementById('pagseguro_credit_card_number')), - click: grandTotal + keydown: creditCardMask.bind($data, document.getElementById('pagseguro_credit_card_number')) } "/> @@ -87,8 +85,9 @@ class="input-text required" name="payment[credit_card_holder]" type="text" - minLength="3" + minlength="3" data-validate="{required:true}" + required data-bind="attr: { id: 'creditCardHolder'}, enable: true, @@ -146,14 +145,10 @@
- - - +
- - - +
@@ -161,30 +156,31 @@
- + -
- - -
+
+ +
+
@@ -198,15 +194,17 @@ name="payment[credit_card_document]" type="text" maxlength="18" - minLength="11" + minlength="11" data-validate="{required:true}" + required data-bind="attr: { id: 'creditCardDocument'}, enable: true, textInput: creditCardDocument, valueUpdate: 'input', event: { - blur: validateDocument(document.getElementById('creditCardDocument')) + blur: validateDocumentFinal.bind($data, document.getElementById('creditCardDocument')), + keydown: mascaraMutuario(document.getElementById('creditCardDocument'), cpfCnpj) } "/> @@ -225,12 +223,14 @@ name="payment[creditCardHolderBirthdate]" type="text" maxlength="10" - minLength="1" + minlength="1" data-validate="{required:true}" placeholder="dd/mm/aaaa" + required data-bind="attr: { id: 'creditCardHolderBirthdate'}, enable: true, + textInput: creditCardHolderBirthdate, valueUpdate: 'input', event: { blur: validateCreditCardHolderBirthdate.bind($data,document.getElementById('creditCardHolderBirthdate')), @@ -242,8 +242,39 @@
+
+ + +
+ + +
+
+
+ + + + + selecione o número de parcelas + + +
+
Esta compra está sendo feita no Brasil From e21ca579e4ecbdd43edffdcc311f42f196b62ac6 Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Fri, 1 Dec 2017 00:20:20 -0200 Subject: [PATCH 18/22] refactor: removed unused code from direct payment method forms and added mask to document field in boleto and online debit payment --- .../web/template/payment/boleto-form.html | 29 +---- .../template/payment/credit-card-form.html | 2 +- .../template/payment/online-debit-form.html | 123 ++++++++---------- 3 files changed, 60 insertions(+), 94 deletions(-) diff --git a/view/frontend/web/template/payment/boleto-form.html b/view/frontend/web/template/payment/boleto-form.html index 9f171e4..729898f 100644 --- a/view/frontend/web/template/payment/boleto-form.html +++ b/view/frontend/web/template/payment/boleto-form.html @@ -38,17 +38,9 @@
- - +
- -
diff --git a/view/frontend/web/template/payment/credit-card-form.html b/view/frontend/web/template/payment/credit-card-form.html index 66c2bff..56e8361 100644 --- a/view/frontend/web/template/payment/credit-card-form.html +++ b/view/frontend/web/template/payment/credit-card-form.html @@ -220,6 +220,7 @@
- - +
+ -
- - -
- + - - -
+
+
-
- +
+ -
- - - - -
+
+ + + +
+
- + -
-
- Esta compra está sendo feita no Brasil - -
+
+
+ Esta compra está sendo feita no Brasil +
-
+
+
- +
From 7c6fbebc87b589c867b1f89ec6b1a8800c0b85e5 Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Sat, 9 Dec 2017 23:29:28 -0200 Subject: [PATCH 19/22] fix: bug when copy and paste a document in direct payment sometimes not set the value for backend calls; fix: redirect to 404 when access payment request controller without an order; fix: credit card month value was one less than should be (0 to 11, when shoud be 1 to 12) --- Controller/Payment/Checkout.php | 1 - Controller/Payment/Request.php | 9 +++++++-- Model/Direct/BoletoMethod.php | 9 +++++++++ Model/Direct/CreditCardMethod.php | 9 +++++++++ Model/Direct/DebitMethod.php | 9 +++++++++ Model/PaymentMethod.php | 4 +++- .../web/js/view/payment/method-renderer/boleto-method.js | 2 +- .../view/payment/method-renderer/credit_card-method.js | 4 ++-- .../view/payment/method-renderer/online_debit-method.js | 2 +- view/frontend/web/template/payment/boleto-form.html | 1 - 10 files changed, 41 insertions(+), 9 deletions(-) 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 5d87e5b..b43fdf0 100755 --- a/Controller/Payment/Request.php +++ b/Controller/Payment/Request.php @@ -89,6 +89,11 @@ 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') { @@ -98,7 +103,7 @@ public function execute() throw new \Exception("There is no order associated with this session."); } - if (!isset($paymentData['additional_information']['boleto_document']) + 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"); } @@ -129,7 +134,7 @@ public function execute() return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/payment/failure')); } } - + if ($paymentData['method'] === 'pagseguro_online_debit') { try { $this->orderId = $lastRealOrder->getId(); diff --git a/Model/Direct/BoletoMethod.php b/Model/Direct/BoletoMethod.php index d87776c..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(); @@ -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..57ac9da 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(); @@ -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..52887bf 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(); @@ -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/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/view/frontend/web/js/view/payment/method-renderer/boleto-method.js b/view/frontend/web/js/view/payment/method-renderer/boleto-method.js index bab6300..ae67b52 100644 --- a/view/frontend/web/js/view/payment/method-renderer/boleto-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/boleto-method.js @@ -97,7 +97,7 @@ define( $.when(setPaymentInformationAction(this.messageContainer, { 'method': self.getCode(), 'additional_data': { - 'boleto_document': self.boletoDocument(), + 'boleto_document': (self.boletoDocument()) ? self.boletoDocument() : document.getElementById('pagseguro_boleto_boleto_document').value, 'boleto_hash': PagSeguroDirectPayment.getSenderHash() } })).done(function () { 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 index 3f460b0..07629ea 100644 --- 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 @@ -73,7 +73,7 @@ define( var months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; return _.map(months, function (value, key) { return { - 'value': key, + 'value': key + 1, 'month': value }; }); @@ -123,7 +123,7 @@ define( $.when(setPaymentInformationAction(this.messageContainer, { 'method': self.getCode(), 'additional_data': { - 'credit_card_document': self.creditCardDocument(), + 'credit_card_document': (self.creditCardDocument()) ? self.creditCardDocument() : document.getElementById('creditCardDocument').value, 'credit_card_hash' : PagSeguroDirectPayment.getSenderHash(), 'credit_card_token' : document.getElementById('creditCardToken').value, 'credit_card_holder_name' : document.getElementById('creditCardHolder').value, 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 index 10e87a0..8f75881 100644 --- 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 @@ -82,7 +82,7 @@ define( $.when(setPaymentInformationAction(this.messageContainer, { 'method': self.getCode(), 'additional_data': { - 'online_debit_document': self.onlineDebitDocument(), + '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() } diff --git a/view/frontend/web/template/payment/boleto-form.html b/view/frontend/web/template/payment/boleto-form.html index 729898f..082fccf 100644 --- a/view/frontend/web/template/payment/boleto-form.html +++ b/view/frontend/web/template/payment/boleto-form.html @@ -48,7 +48,6 @@
Date: Mon, 11 Dec 2017 23:02:26 -0200 Subject: [PATCH 20/22] feature: create pagseguro credit card token only before place order, with error message case something whent wrong fix: fix installments option duplicated when change credit card number fix: credit card code error message --- Model/Direct/CreditCardMethod.php | 6 +- Model/Direct/DebitMethod.php | 6 +- view/frontend/templates/direct/payment.phtml | 772 ------------------ view/frontend/web/js/model/credit-card.js | 44 +- .../method-renderer/credit_card-method.js | 77 +- .../template/payment/credit-card-form.html | 15 +- 6 files changed, 78 insertions(+), 842 deletions(-) diff --git a/Model/Direct/CreditCardMethod.php b/Model/Direct/CreditCardMethod.php index 57ac9da..f12294a 100644 --- a/Model/Direct/CreditCardMethod.php +++ b/Model/Direct/CreditCardMethod.php @@ -348,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(); } diff --git a/Model/Direct/DebitMethod.php b/Model/Direct/DebitMethod.php index 52887bf..6b8f8c7 100644 --- a/Model/Direct/DebitMethod.php +++ b/Model/Direct/DebitMethod.php @@ -278,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(); } diff --git a/view/frontend/templates/direct/payment.phtml b/view/frontend/templates/direct/payment.phtml index d8e61ca..e69de29 100644 --- a/view/frontend/templates/direct/payment.phtml +++ b/view/frontend/templates/direct/payment.phtml @@ -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/web/js/model/credit-card.js b/view/frontend/web/js/model/credit-card.js index 74b5aa5..ca812ab 100644 --- a/view/frontend/web/js/model/credit-card.js +++ b/view/frontend/web/js/model/credit-card.js @@ -127,11 +127,13 @@ function getInstallments(brand) { }) } -function test(id) { - console.log(id); -} - 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), @@ -153,35 +155,13 @@ function getBrand(self) { return false; } -function createCardToken() { - if (validateCreateToken()) { - 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; - }, - error: function (error) { - console.log(error); - }, - } - - PagSeguroDirectPayment.createCardToken(param) - } -} -function validateCreditCardCode(self, createToken) { +function validateCreditCardCode(self) { if (self.validity.tooLong || self.validity.tooShort || !self.validity.valid) { displayError(self) return false } else { displayError(self, false) - if (createToken === true && validateCreateToken()) { - createCardToken(); - } return true } } @@ -194,13 +174,9 @@ function validateCreditCardForm() { validateCreditCardHolderBirthdate(document.querySelector('#creditCardHolderBirthdate')) && validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')) && validateCreditCardYear(document.querySelector('#creditCardExpirationYear')) && - validateCreditCardCode(document.querySelector('#creditCardCode'), false) && + validateCreditCardCode(document.querySelector('#creditCardCode')) && validateCreditCardInstallment(document.querySelector('#card_installment_option')) ) { - - if (document.getElementById('creditCardToken').value === "") { - createCardToken(); - } return true; } @@ -219,7 +195,7 @@ function validateCreateToken() { if(validateCreditCard(document.querySelector('#pagseguro_credit_card_number')) && validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')) && validateCreditCardYear(document.querySelector('#creditCardExpirationYear')) - && validateCreditCardCode(document.querySelector('#creditCardCode'), false) + && validateCreditCardCode(document.querySelector('#creditCardCode')) && document.getElementById('creditCardBrand').value !== "" ) { return true @@ -228,7 +204,7 @@ function validateCreateToken() { validateCreditCard(document.querySelector('#pagseguro_credit_card_number')); validateCreditCardMonth(document.querySelector('#creditCardExpirationMonth')); validateCreditCardYear(document.querySelector('#creditCardExpirationYear')); - validateCreditCardCode(document.querySelector('#creditCardCode'), false); + validateCreditCardCode(document.querySelector('#creditCardCode')); return false; } 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 index 07629ea..36557d6 100644 --- 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 @@ -37,15 +37,12 @@ define( ], function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, directPaymentValidator, creditCard) { 'use strict'; - /* @TODO verify if session id is already set */ - //set pagseguro session - PagSeguroDirectPayment.setSessionId(window.checkoutConfig.library.session); - //console.log(quote.totals); return Component.extend({ defaults: { template: 'UOL_PagSeguro/payment/credit-card-form', - brazilFlagPath: window.checkoutConfig.brazilFlagPath + brazilFlagPath: window.checkoutConfig.brazilFlagPath, + pagseguroCcSessionId: window.checkoutConfig.library.session // totals: parseFloat( // _.findLast(q.getTotals()()['total_segments'], 'value').value // ) @@ -111,6 +108,8 @@ define( 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); @@ -118,33 +117,57 @@ define( fullScreenLoader.stopLoader(); this.isPlaceOrderActionAllowed(true); return; - } - - $.when(setPaymentInformationAction(this.messageContainer, { - 'method': self.getCode(), - 'additional_data': { - 'credit_card_document': (self.creditCardDocument()) ? self.creditCardDocument() : document.getElementById('creditCardDocument').value, - 'credit_card_hash' : 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 + } 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; + }, } - })).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(); - }); + + 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/template/payment/credit-card-form.html b/view/frontend/web/template/payment/credit-card-form.html index 56e8361..82ae02a 100644 --- a/view/frontend/web/template/payment/credit-card-form.html +++ b/view/frontend/web/template/payment/credit-card-form.html @@ -45,7 +45,7 @@ - +
@@ -275,6 +275,15 @@
+
+ +
+
Esta compra está sendo feita no Brasil From 5866f67ea963e8cb9f855d11890ba8b8f8bfcff7 Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Tue, 19 Dec 2017 17:10:51 -0200 Subject: [PATCH 21/22] fix: admin acl rules fix: css rules too invasive improvement: removed old and unecessary files --- etc/acl.xml | 20 +- .../layout/pagseguro_direct_payment.xml | 19 - view/frontend/templates/direct/payment.phtml | 0 view/frontend/web/css/styles.css | 1775 ++--------------- .../payment/method-renderer/payment-method.js | 82 - view/frontend/web/js/view/payment/payment.js | 4 - .../web/template/payment/payment-form.html | 50 - 7 files changed, 187 insertions(+), 1763 deletions(-) delete mode 100755 view/frontend/layout/pagseguro_direct_payment.xml delete mode 100644 view/frontend/templates/direct/payment.phtml delete mode 100644 view/frontend/web/js/view/payment/method-renderer/payment-method.js delete mode 100644 view/frontend/web/template/payment/payment-form.html 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/view/frontend/layout/pagseguro_direct_payment.xml b/view/frontend/layout/pagseguro_direct_payment.xml deleted file mode 100755 index 27b3885..0000000 --- a/view/frontend/layout/pagseguro_direct_payment.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - diff --git a/view/frontend/templates/direct/payment.phtml b/view/frontend/templates/direct/payment.phtml deleted file mode 100644 index e69de29..0000000 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/view/payment/method-renderer/payment-method.js b/view/frontend/web/js/view/payment/method-renderer/payment-method.js deleted file mode 100644 index 939c081..0000000 --- a/view/frontend/web/js/view/payment/method-renderer/payment-method.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * 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', - ], - function ($, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder) { - 'use strict'; - - return Component.extend({ - defaults: { - template: 'UOL_PagSeguro/payment/payment-form' - }, - - context: function() { - return this; - }, - - getCode: function() { - return "pagseguro" - }, - - /** - * @override - */ - placeOrder: function () { - - var self = this; - var paymentData = quote.paymentMethod(); - var messageContainer = this.messageContainer; - fullScreenLoader.startLoader(); - this.isPlaceOrderActionAllowed(false); - $.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){ - $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.lightbox); - } else { - $.mage.redirect(window.checkoutConfig.payment.pagseguro.checkout.standard); - } - }); - }).fail(function () { - self.isPlaceOrderActionAllowed(true); - }).always(function(){ - fullScreenLoader.stopLoader(); - }); - } - }); - } -); diff --git a/view/frontend/web/js/view/payment/payment.js b/view/frontend/web/js/view/payment/payment.js index 0fcd054..ddacbff 100644 --- a/view/frontend/web/js/view/payment/payment.js +++ b/view/frontend/web/js/view/payment/payment.js @@ -34,10 +34,6 @@ 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' diff --git a/view/frontend/web/template/payment/payment-form.html b/view/frontend/web/template/payment/payment-form.html deleted file mode 100644 index 6a5ad67..0000000 --- a/view/frontend/web/template/payment/payment-form.html +++ /dev/null @@ -1,50 +0,0 @@ - -
-
- - -
-
-

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

-
-
- -
-
-
-
From 1ab112911195b81267e6d1103d019a17965308bf Mon Sep 17 00:00:00 2001 From: s2it-moscou Date: Tue, 26 Dec 2017 15:44:00 -0200 Subject: [PATCH 22/22] Update README.md Uptaded changelog, added configuration section and improved instructions --- README.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) 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