-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42e268f
commit cc92076
Showing
10 changed files
with
231 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* @author Monei Team | ||
* @copyright Copyright © Monei (https://monei.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Monei\MoneiPayment\Model\Config\Backend; | ||
|
||
use Monei\MoneiPayment\Model\Payment\Monei; | ||
|
||
class EnableMultibanco extends Enable | ||
{ | ||
protected const PAYMENT_METHOD_CODE = Monei::MULTIBANCO_REDIRECT_CODE; | ||
|
||
/** | ||
* @return EnableBizum | ||
*/ | ||
public function beforeSave(): EnableMultibanco | ||
{ | ||
if (!$this->isPaymentAvailable() && $this->getValue()) { | ||
$this->setValue("0"); | ||
// phpcs:disable | ||
$this->messageManager->addNoticeMessage( | ||
__("Multibanco payment method is not available in your Monei account. Please enable it in your Monei account to use it.")); | ||
// phpcs:enable | ||
} | ||
|
||
return parent::beforeSave(); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
private function isPaymentAvailable(): bool | ||
{ | ||
$availablePaymentMethods = $this->getAvailablePaymentMethods(); | ||
$moneiPaymentCodes = $this->getMoneiPaymentCodesByMagentoPaymentCode(self::PAYMENT_METHOD_CODE); | ||
|
||
foreach ($moneiPaymentCodes as $moneiPaymentCode) { | ||
if (in_array($moneiPaymentCode, $availablePaymentMethods, true)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
Service/Shared/GetMoneiPaymentCodesByMagentoPaymentCodeRedirect.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/** | ||
* @author Monei Team | ||
* @copyright Copyright © Monei (https://monei.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Monei\MoneiPayment\Service\Shared; | ||
|
||
use Monei\MoneiPayment\Model\Payment\Monei; | ||
|
||
class GetMoneiPaymentCodesByMagentoPaymentCodeRedirect | ||
{ | ||
|
||
public function execute(string $magentoPaymentCode): array | ||
{ | ||
return Monei::MAPPER_MAGENTO_MONEI_PAYMENT_CODE_REDIRECT[$magentoPaymentCode] ?? []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
view/frontend/web/js/view/payment/monei-multibanco-redirect.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @author Monei Team | ||
* @copyright Copyright © Monei (https://monei.com) | ||
*/ | ||
define( | ||
[ | ||
'uiComponent', | ||
'Magento_Checkout/js/model/payment/renderer-list' | ||
], | ||
function ( | ||
Component, | ||
rendererList | ||
) { | ||
'use strict'; | ||
rendererList.push( | ||
{ | ||
type: 'monei_multibanco_redirect', | ||
component: 'Monei_MoneiPayment/js/view/payment/method-renderer/monei-redirect-method' | ||
} | ||
); | ||
return Component.extend({}); | ||
} | ||
); |