Skip to content

Commit

Permalink
Merge pull request #56 from macopedia/master
Browse files Browse the repository at this point in the history
Refactor PayU_Account magento plugin
  • Loading branch information
agnagna committed Sep 4, 2015
2 parents 7c956ee + 247457e commit 48fd372
Show file tree
Hide file tree
Showing 60 changed files with 2,306 additions and 2,491 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
<?php

/**
* ver. 1.8.1
* PayU Adminhtml Sales Order View
*
* @copyright Copyright (c) 2011-2014 PayU
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
* http://www.payu.com
* http://www.openpayu.com
* http://twitter.com/openpayu
*/

class PayU_Account_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {

* ver. 1.8.1
* PayU Adminhtml Sales Order View
*
* @copyright Copyright (c) 2011-2014 PayU
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
* http://www.payu.com
* http://www.openpayu.com
* http://twitter.com/openpayu
*/
class PayU_Account_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
{
// constructor
public function __construct() {

public function __construct()
{
parent::__construct();

if($this->_isAllowedAction('review_payment') && $this->getOrder()->getPayment()->getMethod() == 'payu_account' && $this->getOrder()->getStatus() == 'pending_payment' && (int)Mage::getStoreConfig('payment/payu_account/selfreturn') == 0){
if ($this->_isAllowedAction('review_payment') &&
$this->getOrder()->getPayment()->getMethod() == 'payu_account' &&
$this->getOrder()->getStatus() == 'pending_payment' &&
(int)Mage::getStoreConfig('payment/payu_account/selfreturn') == 0
) {
$this->_addButton('payu-complete', array(
'label' => Mage::helper('payu_account')->__('Complete PayU payment'),
'onclick' => 'setLocation(\'' . $this->getCompletePaymentUrl() . '\')',
'class' => ''
'label' => Mage::helper('payu_account')->__('Complete PayU payment'),
'onclick' => 'setLocation(\'' . $this->getCompletePaymentUrl() . '\')',
'class' => ''
), 0, 100, 'header', 'header');

$this->_addButton('payu-cancel', array(
'label' => Mage::helper('payu_account')->__('Cancel PayU payment'),
'onclick' => 'setLocation(\'' . $this->getCancelPaymentUrl() . '\')',
'class' => ''
'label' => Mage::helper('payu_account')->__('Cancel PayU payment'),
'onclick' => 'setLocation(\'' . $this->getCancelPaymentUrl() . '\')',
'class' => ''
), 0, 200, 'header', 'header');
}
}

// rejecting the PayU payment
public function getRejectPaymentUrl()
{
Expand Down
59 changes: 29 additions & 30 deletions app/code/community/PayU/Account/Block/Advertisement.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
<?php

/**
* ver. 1.9.0
* PayU Advertisement Block
* Payment
*
* @copyright Copyright (c) 2011-2014 PayU
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
* http://www.payu.com
* http://www.openpayu.com
* http://twitter.com/openpayu
*/

* ver. 1.9.0
* PayU Advertisement Block
* Payment
*
* @copyright Copyright (c) 2011-2014 PayU
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
* http://www.payu.com
* http://www.openpayu.com
* http://twitter.com/openpayu
*/
class PayU_Account_Block_Advertisement extends Mage_Core_Block_Template
{
/**
* Redirection after clicking the advertisement
*
* @var string
*/
protected $_redirectUrl = 'http://www.payu.pl';
/**
* Redirection after clicking the advertisement
*
* @var string
*/
protected $_redirectUrl = 'http://www.payu.pl';

/**
* (non-PHPdoc)
* @see magento/app/code/core/Mage/Core/Block/Mage_Core_Block_Template::_toHtml()
*/
/**
* (non-PHPdoc)
* @see magento/app/code/core/Mage/Core/Block/Mage_Core_Block_Template::_toHtml()
*/
protected function _toHtml()
{
/**
* setting the advertisement source url
*/
$this->setAdvertisementSrc(Mage::getModel('payu_account/config')->getAdvertisementSrc());
/**
* setting the redirect url
*/
$this->setRedirectUrl($this->_redirectUrl);
/**
* setting the advertisement source url
*/
$this->setAdvertisementSrc(Mage::getModel('payu_account/config')->getAdvertisementSrc());

/**
* setting the redirect url
*/
$this->setRedirectUrl($this->_redirectUrl);

return parent::_toHtml();
}
Expand Down
53 changes: 0 additions & 53 deletions app/code/community/PayU/Account/Block/BeforeSummary.php

This file was deleted.

17 changes: 0 additions & 17 deletions app/code/community/PayU/Account/Block/Button.php

This file was deleted.

40 changes: 24 additions & 16 deletions app/code/community/PayU/Account/Block/Form.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<?php

/**
* ver. 1.9.0
* PayU Form Block
* Payment
*
* @copyright Copyright (c) 2011-2014 PayU
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
* http://www.payu.com
* http://www.openpayu.com
* http://twitter.com/openpayu
*/


* ver. 1.9.0
* PayU Form Block
* Payment
*
* @copyright Copyright (c) 2011-2014 PayU
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
* http://www.payu.com
* http://www.openpayu.com
* http://twitter.com/openpayu
*/
class PayU_Account_Block_Form extends Mage_Payment_Block_Form
{
/**
Expand All @@ -21,16 +19,18 @@ class PayU_Account_Block_Form extends Mage_Payment_Block_Form
*/
protected $_methodCode = 'payu_account';


/**
* Set template and redirect message
*/
protected function _construct()
{
$this->setTemplate('payu_account/form.phtml');
$this->setMethodTitle('');
$this->setMethodLabelAfterHtml('<img src="'.Mage::getModel('payu_account/config')->getThumbnailSrc().'" height="20" alt="PayU"/> '.Mage::helper('payu_account')->__('PayU account'));

$this->setMethodLabelAfterHtml(
"<img src='{$this->getThumbnailSrc()}' height='20' alt='{$this->__('PayU account')}'/> {$this->__('PayU account')}"
);

return parent::_construct();
}

Expand All @@ -42,4 +42,12 @@ public function getMethodCode()
{
return $this->_methodCode;
}
}

/**
* @return string
*/
public function getThumbnailSrc()
{
return Mage::getModel('payu_account/config')->getThumbnailSrc();
}
}
73 changes: 30 additions & 43 deletions app/code/community/PayU/Account/Block/Onestep/Checkout.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,40 @@
<?php

/**
* ver. 1.9.0
* PayU One Step Checkout Block
* ver. 1.9.0
* PayU One Step Checkout Block
*
* @copyright Copyright (c) 2011-2014 PayU
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
* http://www.payu.com
* http://www.openpayu.com
* http://twitter.com/openpayu
* @copyright Copyright (c) 2011-2014 PayU
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
* http://www.payu.com
* http://www.openpayu.com
* http://twitter.com/openpayu
*/

class PayU_Account_Block_Onestep_Checkout extends Mage_Core_Block_Template
{
/** @var string Start One Step action */
protected $_startAction = 'newOneStep';

/** @var bool Whether the block should be eventually rendered */
protected $_shouldRender = true;

/**
* (non-PHPdoc)
* @see magento/app/code/core/Mage/Core/Block/Mage_Core_Block_Template::_toHtml()
*/
protected function _toHtml()
{
if ($this->getRequest()->getParam('submitCustomCheckout')) {
$billingAddress = $this->getRequest()->getParam('billing');
$billingAddress['use_for_shipping'] = 0;
}

/** @var PayU_Account_Model_Config $config */
$config = Mage::getModel('payu_account/config');
$this->setButtonSrc($config->getButtonSrc());
$this->setIsOneStepCheckoutEnabled($config->getIsOneStepCheckoutEnabled());
$this->setCheckoutUrl($config->getUrl($this->_startAction));

/** @var config variable */
protected $_config;

/** @var string Start One Step action */
protected $_startAction = 'newOneStep';

/** @var bool Whether the block should be eventually rendered */
protected $_shouldRender = true;

/** @var string Express checkout model factory name */
protected $_checkoutType = 'payu_account/express_checkout';

/**
* (non-PHPdoc)
* @see magento/app/code/core/Mage/Core/Block/Mage_Core_Block_Template::_toHtml()
*/
protected function _toHtml()
{


if($this->getRequest()->getParam('submitCustomCheckout'))
{
$billingAddress = $this->getRequest()->getParam('billing');
$billingAddress['use_for_shipping'] = 0;
$shippingAddress = $this->getRequest()->getParam('shipping');
}


$this->_config = Mage::getModel('payu_account/config');
$this->setButtonSrc($this->_config->getButtonSrc());
$this->setIsOneStepCheckoutEnabled($this->_config->getIsOneStepCheckoutEnabled());
$this->setIsOneStepCheckoutAvailable($this->_config->getIsOneStepCheckoutAvailable());
$this->setCheckoutUrl($this->_config->getBaseUrl().$this->_startAction);

return parent::_toHtml();
}
}
}

0 comments on commit 48fd372

Please sign in to comment.