Skip to content

Commit

Permalink
update settings for fast payments
Browse files Browse the repository at this point in the history
  • Loading branch information
vegimcarkaxhija committed Oct 24, 2024
1 parent 866c37b commit a8241b2
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 97 deletions.
42 changes: 10 additions & 32 deletions Block/Catalog/Product/View/Applepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,52 +60,30 @@ public function __construct(
/**
* @return bool
*/
public function canShowButton()
public function canShowButton($page)
{
$result = false;

if ($this->cart->getSummaryQty()
&&
($this->applepayConfigProvider->getActive() != 0)
&&
($this->applepayConfigProvider->getAvailableButtons())
&&
(in_array('Cart', $this->applepayConfigProvider->getAvailableButtons()))
) {
$result = true;
}

return $result;
return $this->cart->getSummaryQty() &&
$this->isModuleActive() &&
in_array($page, $this->applepayConfigProvider->getAvailableButtons()) &&
$this->applepayConfigProvider->isApplePayEnabled($this->_storeManager->getStore());
}

/**
* Check if Buckaroo module is active
*
* @return bool
*/
public function canShowProductButton()
public function isModuleActive()
{
$result = false;

if (($this->applepayConfigProvider->getActive() != 0)
&&
($this->applepayConfigProvider->getAvailableButtons())
&&
(in_array('Product', $this->applepayConfigProvider->getAvailableButtons()))
) {
$result = true;
}

return $result;
$status = $this->applepayConfigProvider->getActive();
return $status == 1 || $status == 2;
}

/**
* @return false|string
*/
public function getCheckoutConfig()
{
if (!$this->canShowButton()) {
return null;
}

return json_encode($this->compositeConfigProvider->getConfig(), JSON_HEX_TAG);
}

Expand Down
42 changes: 5 additions & 37 deletions Block/Catalog/Product/View/IdealFastCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,12 @@ public function __construct(
*
* @return bool
*/
public function canShowProductButton()
public function canShowButton($page)
{
if ($this->isModuleActive() && $this->isButtonEnabled()){
return $this->idealConfig->canShowButtonForPage(
'Product',
$this->_storeManager->getStore()
);
}
return false;
}

/**
* Determine if the cart button can be shown
*
* @return bool
*/
public function canShowCartButton()
{
if ($this->isModuleActive() && $this->isButtonEnabled()){
return $this->idealConfig->canShowButtonForPage(
'Cart',
$this->_storeManager->getStore()
);
}
return false;
return ($this->isModuleActive() &&
$this->idealConfig->isFastCheckoutEnabled($this->_storeManager->getStore()) &&
$this->idealConfig->canShowButtonForPage($page, $this->_storeManager->getStore()) &&
$this->idealConfig->isIDealEnabled($this->_storeManager->getStore()));
}

/**
Expand All @@ -107,19 +88,6 @@ public function isModuleActive()
return $status == 1 || $status == 2;
}

/**
* Check if ideal fast checkout button is enabled
*
* @return mixed
*/
public function isButtonEnabled()
{
return $this->idealConfig->isFastCheckoutEnabled(
$this->_storeManager->getStore()
);
}


/**
* Get logo based on chosen color setting
*
Expand Down
24 changes: 5 additions & 19 deletions Block/Catalog/Product/View/PaypalExpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,11 @@ public function __construct(
$this->encryptor = $encryptor;
$this->paypalConfig = $paypalConfig;
}
public function canShowProductButton()
public function canShowButton($page)
{
if ($this->isModuleActive()){
return $this->paypalConfig->canShowButtonForPage(
'Product',
$this->_storeManager->getStore()
);
}
return false;
}

public function canShowCartButton()
{
if ($this->isModuleActive()){
return $this->paypalConfig->canShowButtonForPage(
'Cart',
$this->_storeManager->getStore()
);
}
return false;
return $this->isModuleActive() &&
$this->paypalConfig->canShowButtonForPage($page, $this->_storeManager->getStore()) &&
$this->paypalConfig->isPayPalEnabled($this->_storeManager->getStore());
}

/**
Expand All @@ -88,6 +73,7 @@ public function isModuleActive()
$status = $this->configProviderAccount->getActive();
return $status == 1 || $status == 2;
}

/**
* Get all data required
*
Expand Down
4 changes: 4 additions & 0 deletions Model/ConfigProvider/Method/Applepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,8 @@ public function getBaseAllowedCurrencies()
];
}

public function isApplePayEnabled($store = null)
{
return $this->getConfigFromXpath(self::XPATH_APPLEPAY_ACTIVE, $store);
}
}
5 changes: 5 additions & 0 deletions Model/ConfigProvider/Method/Ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public function isFastCheckoutEnabled($store = null)
return $this->getConfigFromXpath(self::XPATH_IDEAL_FAST_CHECKOUT_ENABLE, $store);
}

public function isIDealEnabled($store = null)
{
return $this->getConfigFromXpath(self::XPATH_IDEAL_ACTIVE, $store);
}

public function getLogoColor($store = null)
{
return $this->getConfigFromXpath(self::XPATH_IDEAL_FAST_CHECKOUT_LOGO, $store);
Expand Down
6 changes: 5 additions & 1 deletion Model/ConfigProvider/Method/Paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getExpressMerchantId($store = null)
return $this->getConfigFromXpath(self::XPATH_PAYPAL_EXPRESS_MERCHANT_ID, $store);
}
/**
* Test if express button is enabled for the $page
* Test if express button is enabled for the $page
*
* @param string $page
*
Expand All @@ -124,4 +124,8 @@ public function canShowButtonForPage($page, $store = null)
$pages = explode(",", $buttons);
return in_array($page, $pages);
}
public function isPayPalEnabled($store = null)
{
return $this->getConfigFromXpath(self::XPATH_PAYPAL_ACTIVE, $store);
}
}
4 changes: 2 additions & 2 deletions view/frontend/templates/catalog/product/view/applepay.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @license https://tldrlegal.com/license/mit-license
*/
?>
<?php if ($block->canShowProductButton()): ?>
<?php if ($block->canShowButton('Product')): ?>
<div id="apple-pay-catalog-product-view-component" data-bind="scope:'applepayproductcomponent'">
<!-- ko template: getTemplate() --><!-- /ko -->

Expand Down Expand Up @@ -47,4 +47,4 @@
}
</script>
</div>
<?php endif; ?>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @license https://tldrlegal.com/license/mit-license
*/

if ($block->canShowProductButton()): ?>
if ($block->canShowButton('Product')): ?>

<div id="fast-checkout-ideal-btn-component" data-bind="scope: 'fastCheckoutIdeal'">
<button id="fast-checkout-ideal-btn" type="button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @license https://tldrlegal.com/license/mit-license
*/
?>
<?php if ($block->canShowProductButton()): ?>
<?php if ($block->canShowButton('Product')): ?>
<div id="paypal-express-button-component" data-bind="scope:'paypalExpress'">
<!-- ko template: getTemplate() --><!-- /ko -->
<div class="buckaroo-paypal-express"></div>
Expand All @@ -38,4 +38,4 @@
}
</script>
</div>
<?php endif; ?>
<?php endif; ?>
2 changes: 1 addition & 1 deletion view/frontend/templates/checkout/cart/applepay.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @license https://tldrlegal.com/license/mit-license
*/
?>
<?php if ($block->canShowButton()): ?>
<?php if ($block->canShowButton('Cart')): ?>
<div class="box-tocart">
<div class="fieldset">
<div class="actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @license https://tldrlegal.com/license/mit-license
*/

if ($block->canShowCartButton()): ?>
if ($block->canShowButton('Cart')): ?>

<div id="fast-checkout-ideal-btn-component" data-bind="scope: 'fastCheckoutIdeal'">
<button id="fast-checkout-ideal-btn" type="button">
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/templates/checkout/cart/paypal-express.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @license https://tldrlegal.com/license/mit-license
*/
?>
<?php if ($block->canShowCartButton()) : ?>
<?php if ($block->canShowButton('Cart')) : ?>
<div class="box-tocart">
<div class="fieldset">
<div class="actions">
Expand Down

0 comments on commit a8241b2

Please sign in to comment.