Skip to content

Commit

Permalink
Fix/iframe issue for partpay (#26)
Browse files Browse the repository at this point in the history
* Fixing code style requirements and refactor some code and allow iframe checkout from settings

* fixing more code style for SDK

* adding more code style fix in the SDK

* unit test code style fix

* refactoring httpParseHeaders function where we removed array_merge from for loop

* refactor checkStoreSSLSettings function where replace parse_url by zenduri parse function

* fxing some default setting and more code style

* fixing the last bit of code style issue

* resolved iframe issue for partpay and quadpay

* Fixing the iframe for other region issue

* update the package version for release

Co-authored-by: ben.zhang <[email protected]>
  • Loading branch information
mahbub-zip and benzhangzip authored Jan 12, 2021
1 parent a1bbad9 commit 024b125
Show file tree
Hide file tree
Showing 118 changed files with 2,027 additions and 1,670 deletions.
49 changes: 24 additions & 25 deletions Block/Advert/AbstractAdvert.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

namespace Zip\ZipPayment\Block\Advert;

use Magento\Catalog\Block as CatalogBlock;
use Magento\Paypal\Helper\Shortcut\ValidatorInterface;
use \Zip\ZipPayment\Model\Config;
use Zip\ZipPayment\Model\Config;
use Magento\Framework\Pricing\PriceCurrencyInterface;

/**
* @category Zipmoney
* @package Zipmoney_ZipPayment
* @category Zip
* @package ZipPayment
* @author Zip Plugin Team <[email protected]>
* @copyright 2020 Zip Co Limited
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.zipmoney.com.au/
* @link https://zip.co
*/
abstract class AbstractAdvert extends \Magento\Framework\View\Element\Template
{
Expand All @@ -40,7 +37,7 @@ abstract class AbstractAdvert extends \Magento\Framework\View\Element\Template
protected $_checkoutSession;

/**
*
* @var PriceCurrencyInterface
*/
protected $_priceCurrency;

Expand All @@ -49,17 +46,21 @@ abstract class AbstractAdvert extends \Magento\Framework\View\Element\Template
*/
protected $_alias = '';

protected $_supportedWidgetTypes = array('widget', 'banner', 'tagline');
/**
* @var array
*/
protected $_supportedWidgetTypes = ['widget', 'banner', 'tagline'];

/**
* @var array
*/
protected $_configConstants = ['widget' => [
'product' => Config::ADVERTS_PRODUCT_IMAGE_ACTIVE,
'product_selector' => Config::ADVERTS_PRODUCT_IMAGE_SELECTOR,
'cart' => Config::ADVERTS_CART_IMAGE_ACTIVE,
'cart_selector' => Config::ADVERTS_CART_IMAGE_SELECTOR
],
protected $_configConstants = [
'widget' => [
'product' => Config::ADVERTS_PRODUCT_IMAGE_ACTIVE,
'product_selector' => Config::ADVERTS_PRODUCT_IMAGE_SELECTOR,
'cart' => Config::ADVERTS_CART_IMAGE_ACTIVE,
'cart_selector' => Config::ADVERTS_CART_IMAGE_SELECTOR
],
'tagline' => [
'product' => Config::ADVERTS_PRODUCT_TAGLINE_ACTIVE,
'product_selector' => Config::ADVERTS_PRODUCT_TAGLINE_SELECTOR,
Expand All @@ -86,16 +87,14 @@ public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
PriceCurrencyInterface $priceCurrency,
array $data = []
)
{
) {
parent::__construct($context, $data);

$this->_config = $config;
$this->_registry = $registry;
$this->_logger = $logger;
$this->_checkoutSession = $checkoutSession;
$this->_priceCurrency = $priceCurrency;

}

public function getProductPrice()
Expand All @@ -118,7 +117,7 @@ public function getCartTotal()
public function getCurrencyFormat($price)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$currency = $objectManager->get('Magento\Directory\Model\Currency');
$currency = $objectManager->get(\Magento\Directory\Model\Currency::class);
return $currency->format($price, ['display' => \Zend_Currency::NO_SYMBOL], false);
}

Expand All @@ -134,7 +133,6 @@ public function getCurrencySymbol()
*/
protected function _configShow($widget, $page)
{

$configPath = $this->_getConfigPath($widget, $page);
return $this->_config->getConfigData($configPath);
}
Expand All @@ -146,7 +144,7 @@ protected function _configShow($widget, $page)
*/
protected function _isSelectorExist($widget, $page)
{
$selectorConfigPath =$this->_getConfigPath($widget,$page.'_selector');
$selectorConfigPath = $this->_getConfigPath($widget, $page . '_selector');
return empty($this->_config->getValue($selectorConfigPath)) ? false : true ;
}

Expand All @@ -157,25 +155,26 @@ protected function _isSelectorExist($widget, $page)
*/
protected function _getConfigPath($widget, $page)
{
if ($widget && $page)
if ($widget && $page) {
return isset($this->_configConstants[$widget][$page]) ? $this->_configConstants[$widget][$page] : null;
else
} else {
return null;
}
}

/**
* get element selectors for current widgets
*/
public function getElementSelectors()
{
$selectors = array();
$selectors = [];

foreach ($this->_supportedWidgetTypes as $widgetType) {
$pageType = $this->getPageType();
$enabled = $this->_configShow($widgetType, $pageType);

if ($enabled !== null && $enabled) {
$configPath =$this->_getConfigPath($widgetType,$pageType.'_selector') ;
$configPath = $this->_getConfigPath($widgetType, $pageType . '_selector') ;
$widgetType = $widgetType == 'widget' ? $pageType . '_' . $widgetType : $widgetType;
$selectors[$widgetType] = $this->_config->getValue($configPath);
}
Expand Down
12 changes: 3 additions & 9 deletions Block/Advert/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
namespace Zip\ZipPayment\Block\Advert;

use Magento\Catalog\Block as CatalogBlock;
use Magento\Paypal\Helper\Shortcut\ValidatorInterface;
use \Zip\ZipPayment\Model\Config;

/**
* @category Zipmoney
* @package Zipmoney_ZipPayment
* @author Zip Plugin Team <[email protected]>
* @copyright 2020 Zip Co Limited
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.zipmoney.com.au/
* @link https://zip.co
*/
class Banner extends AbstractAdvert implements CatalogBlock\ShortcutInterface
{

/**
* @const string
*/
Expand All @@ -39,11 +33,11 @@ public function getAlias()
*/
protected function _toHtml()
{
if ($this->_configShow(self::ADVERT_TYPE, $this->getPageType()) && !$this->_isSelectorExist(self::ADVERT_TYPE, $this->getPageType())) {
if ($this->_configShow(self::ADVERT_TYPE, $this->getPageType())
&& !$this->_isSelectorExist(self::ADVERT_TYPE, $this->getPageType())) {
return parent::_toHtml();
}

return '';
}

}
21 changes: 1 addition & 20 deletions Block/Advert/RootEl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

namespace Zip\ZipPayment\Block\Advert;

use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Zip\ZipPayment\MerchantApi\Lib\Model\CommonUtil;
use Magento\Catalog\Block as CatalogBlock;


/**
* @category Zipmoney
* @package Zipmoney_ZipPayment
* @author Zip Plugin Team <[email protected]>
* @copyright 2020 Zip Co Limited
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.zipmoney.com.au/
* @link https://zip.co
*/
class RootEl extends AbstractAdvert implements CatalogBlock\ShortcutInterface
{

/**
* Get country path
*/
Expand Down Expand Up @@ -85,16 +78,4 @@ public function getAlias()
{
return $this->_alias;
}

/**
* Render the block if needed
*
* @return string
*/
protected function _toHtml()
{

return parent::_toHtml();

}
}
11 changes: 3 additions & 8 deletions Block/Advert/Tagline.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
namespace Zip\ZipPayment\Block\Advert;

use Magento\Catalog\Block as CatalogBlock;
use Magento\Paypal\Helper\Shortcut\ValidatorInterface;
use \Zip\ZipPayment\Model\Config;

/**
* @category Zipmoney
* @package Zipmoney_ZipPayment
* @author Zip Plugin Team <[email protected]>
* @copyright 2020 Zip Co Limited
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.zipmoney.com.au/
* @link https://zip.co
*/
class Tagline extends AbstractAdvert implements CatalogBlock\ShortcutInterface
{
Expand All @@ -39,10 +34,10 @@ public function getAlias()
protected function _toHtml()
{

if ($this->_configShow(self::WIDGET_TYPE, $this->getPageType()) && !$this->_isSelectorExist(self::WIDGET_TYPE, $this->getPageType())) {
if ($this->_configShow(self::WIDGET_TYPE, $this->getPageType())
&& !$this->_isSelectorExist(self::WIDGET_TYPE, $this->getPageType())) {
return parent::_toHtml();
}
return '';
}

}
5 changes: 2 additions & 3 deletions Block/Advert/Widget.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

namespace Zip\ZipPayment\Block\Advert;

use Magento\Catalog\Block as CatalogBlock;
Expand All @@ -22,7 +21,6 @@ public function getPrice()
}

return $this->getCurrencyFormat($price);

}

/**
Expand All @@ -43,7 +41,8 @@ public function getAlias()
protected function _toHtml()
{

if ($this->_configShow(self::ADVERT_TYPE, $this->getPageType()) && !$this->_isSelectorExist(self::ADVERT_TYPE, $this->getPageType())) {
if ($this->_configShow(self::ADVERT_TYPE, $this->getPageType())
&& !$this->_isSelectorExist(self::ADVERT_TYPE, $this->getPageType())) {
return parent::_toHtml();
}

Expand Down
13 changes: 6 additions & 7 deletions Block/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
use Magento\Framework\View\Element\Template;

/**
* @category Zipmoney
* @package Zipmoney_ZipPayment
* @author Zip Plugin Team <[email protected]>
* @copyright 2020 Zip Co Limited
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.zipmoney.com.au/
* @link https://zip.co
*/
class Error extends Template
{
Expand All @@ -23,15 +20,18 @@ class Error extends Template
*/
const ERROR_HEADER = 'payment/zippayment/zip_messages/error_header';

/**
* @var Magento\Framework\Message\ManagerInterface
*/
protected $_messageManager;
protected $_config;

public function __construct(
Template\Context $context,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Zip\ZipPayment\Model\Config $config,
array $data = [])
{
array $data = []
) {
$this->_messageManager = $messageManager;
$this->_config = $config;
parent::__construct($context, $data);
Expand Down Expand Up @@ -112,6 +112,5 @@ protected function _prepareLayout()
$this->pageConfig->getTitle()->set(__($text));

return parent::_prepareLayout();

}
}
10 changes: 3 additions & 7 deletions Block/Info.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Zip\ZipPayment\Block;

use Magento\Framework\Phrase;
use Magento\Payment\Block\ConfigurableInfo;

/**
* Class Info
* @author Zip Plugin Team <[email protected]>
* @copyright 2020 Zip Co Limited
* @link https://zip.co
*/
class Info extends ConfigurableInfo
{
Expand All @@ -28,5 +25,4 @@ protected function getLabel($field)

return __($field);
}

}
15 changes: 7 additions & 8 deletions Block/Referred.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
use Magento\Framework\View\Element\Template;

/**
* @category Zipmoney
* @package Zipmoney_ZipPayment
* @author Zip Plugin Team <[email protected]>
* @copyright 2020 Zip Co Limited
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.zipmoney.com.au/
* @link https://zip.co
*/
class Referred extends Template
{
Expand All @@ -30,8 +27,8 @@ public function __construct(
Template\Context $context,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Zip\ZipPayment\Model\Config $config,
array $data = [])
{
array $data = []
) {
$this->_messageManager = $messageManager;
$this->_config = $config;
parent::__construct($context, $data);
Expand All @@ -46,7 +43,10 @@ public function getBodyText()
{
$text = $this->_config->getStoreConfig(self::REFERRED_BODY);
if (!$text) {
$text = __('Your application is currently under review by zipMoney and will be processed very shortly. You can contact the customer care at [email protected] for any enquiries');
$text = __(
'Your application is currently under review by zipMoney and will be processed very shortly. '
. 'You can contact the customer care at [email protected] for any enquiries'
);
}
return $text;
}
Expand All @@ -68,5 +68,4 @@ protected function _prepareLayout()

return parent::_prepareLayout();
}

}
Loading

0 comments on commit 024b125

Please sign in to comment.