From 0423eb601834ff7a272d25053dde327a9f977493 Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Fri, 6 Oct 2017 09:45:36 -0300 Subject: [PATCH 1/7] feature: accepts four line addresses, using Inovarti OneStepCheckout default configuration --- .../UOL/PagSeguro/Model/OrderAddress.php | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/code/community/UOL/PagSeguro/Model/OrderAddress.php b/app/code/community/UOL/PagSeguro/Model/OrderAddress.php index 7884b14..71b1490 100644 --- a/app/code/community/UOL/PagSeguro/Model/OrderAddress.php +++ b/app/code/community/UOL/PagSeguro/Model/OrderAddress.php @@ -46,15 +46,26 @@ public function getBillingAddress() private function setAddress(Mage_Sales_Model_Order_Address $address) { $response = new \PagSeguro\Domains\Address(); - $parse = $this->parseStreet($address->getStreet1()); - $response->setStreet($parse['street']); - $response->setNumber($parse['number']); - $response->setDistrict($address->getStreet2()); + + if (count($address->getStreet()) === 4) { + //one step checkout default values + $response->setStreet($address->getStreet1()); + $response->setNumber($address->getStreet2()); + $response->setComplement($address->getStreet3()); + $response->setDistrict($address->getStreet4()); + } else { + //default configuration + $parse = $this->parseStreet($address->getStreet1()); + $response->setStreet($parse['street']); + $response->setNumber($parse['number']); + $response->setDistrict($address->getStreet2()); + $response->setComplement($address->getStreet3()); + } + $response->setCity($address->getCity()); $response->setPostalCode($address->getPostcode()); $response->setState($this->getRegionAbbreviation($address)); $response->setCountry($address->getCountry()); - $response->setComplement($address->getStreet3()); return $response; } From 8f3b441b791390c220219155568a9e4a7a4113a4 Mon Sep 17 00:00:00 2001 From: gabriellucius Date: Mon, 9 Oct 2017 15:27:21 -0300 Subject: [PATCH 2/7] feature: added direct payment with boleto compatibility with Inovarti One Step Checkout module --- .../UOL/PagSeguro/Block/Form/Boleto.php | 26 ++++++++-- .../UOL/PagSeguro/Model/PaymentMethod.php | 9 ++++ .../base/default/layout/uol/pagseguro.xml | 6 +++ .../template/uol/pagseguro/form/boleto.phtml | 18 +++++-- .../base/default/uol/pagseguro/js/boleto.js | 7 +-- .../uol/pagseguro/js/pagseguro-before-save.js | 5 +- .../pagseguro-onestepcheckout-before-save.js | 50 +++++++++++++++++++ 7 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 skin/frontend/base/default/uol/pagseguro/js/pagseguro-onestepcheckout-before-save.js diff --git a/app/code/community/UOL/PagSeguro/Block/Form/Boleto.php b/app/code/community/UOL/PagSeguro/Block/Form/Boleto.php index e4bd30b..36fa215 100644 --- a/app/code/community/UOL/PagSeguro/Block/Form/Boleto.php +++ b/app/code/community/UOL/PagSeguro/Block/Form/Boleto.php @@ -7,9 +7,7 @@ class UOL_PagSeguro_Block_Form_Boleto extends Mage_Payment_Block_Form protected function _construct() { parent::_construct(); - $paymentModel = Mage::getSingleton('UOL_PagSeguro_Model_PaymentMethod'); - $this->setBoletoSession($paymentModel->getSession()); - $this->setTemplate('uol/pagseguro/form/boleto.phtml'); + $this->initializePagSeguro(); } protected function _prepareLayout() @@ -20,4 +18,26 @@ protected function _prepareLayout() $this->getLayout()->getBlock('head')->addItem('skin_css', 'uol/pagseguro/css/direct-payment.css'); } } + + /** + * Set variables to be used in pagseguro boleto form (boleto.phtml) + */ + private function initializePagSeguro() + { + $paymentModel = Mage::getSingleton('UOL_PagSeguro_Model_PaymentMethod'); + if ($paymentModel->getOneStepCheckoutIsEnabled()) { + $this->setPagSeguroBeforeSaveJsSkinUrl($this->getSkinUrl('uol/pagseguro/js/pagseguro-onestepcheckout-before-save.js')); + } else { + $this->setPagSeguroBeforeSaveJsSkinUrl($this->getSkinUrl('uol/pagseguro/js/pagseguro-before-save.js')); + } + // if customer is loged, get his document info (taxvat) + if (Mage::getSingleton('customer/session')->isLoggedIn()) { + $customer = Mage::getSingleton('customer/session')->getCustomer(); + $this->setBoletoDocument($customer->getData()['taxvat']); + } + // set boleto session + $this->setBoletoSession($paymentModel->getSession()); + // set template + $this->setTemplate('uol/pagseguro/form/boleto.phtml'); + } } \ No newline at end of file diff --git a/app/code/community/UOL/PagSeguro/Model/PaymentMethod.php b/app/code/community/UOL/PagSeguro/Model/PaymentMethod.php index edbaff3..eb6a552 100644 --- a/app/code/community/UOL/PagSeguro/Model/PaymentMethod.php +++ b/app/code/community/UOL/PagSeguro/Model/PaymentMethod.php @@ -282,4 +282,13 @@ public function getSession() } return $this->_session; } + + /** + * Return status (enabled or disabled) from the Inovarti One Step Checkout module + * @return boolean + */ + public function getOneStepCheckoutIsEnabled() + { + return (Mage::getStoreConfig("onestepcheckout/general/is_enabled") == 1) ? true : false; + } } diff --git a/app/design/frontend/base/default/layout/uol/pagseguro.xml b/app/design/frontend/base/default/layout/uol/pagseguro.xml index 4dad35c..613b252 100644 --- a/app/design/frontend/base/default/layout/uol/pagseguro.xml +++ b/app/design/frontend/base/default/layout/uol/pagseguro.xml @@ -168,6 +168,12 @@ limitations under the License. template="uol/pagseguro/loading.phtml"/> + + + + + + diff --git a/app/design/frontend/base/default/template/uol/pagseguro/form/boleto.phtml b/app/design/frontend/base/default/template/uol/pagseguro/form/boleto.phtml index 0c219f3..ce94764 100644 --- a/app/design/frontend/base/default/template/uol/pagseguro/form/boleto.phtml +++ b/app/design/frontend/base/default/template/uol/pagseguro/form/boleto.phtml @@ -1,16 +1,24 @@ @@ -42,7 +47,7 @@ var x = document.getElementsByTagName("script");
//getOnlineDebitSession();?>"); - assignOnlineDebitHash(); //]]>