Skip to content

Commit

Permalink
chore: Customisations for ABN
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkwr committed Feb 28, 2025
1 parent 0b73873 commit eea5b7e
Show file tree
Hide file tree
Showing 88 changed files with 631 additions and 445 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/

- name: Install the extensions in Magento
run: docker exec magento-project-community-edition composer require two-inc/magento2:@dev --no-plugins
run: docker exec magento-project-community-edition composer require two-inc/magento-abn-plugin:@dev --no-plugins

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Two_Gateway && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable ABN_Gateway && php bin/magento setup:upgrade && php bin/magento setup:di:compile"

- name: Run PHPStan
run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions"
2 changes: 1 addition & 1 deletion .github/workflows/setup-di-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/

- name: Install the extension in Magento
run: docker exec magento-project-community-edition composer require two-inc/magento2:@dev --no-plugins
run: docker exec magento-project-community-edition composer require two-inc/magento-abn-plugin:@dev --no-plugins

- name: Run setup:di:compile
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
48 changes: 25 additions & 23 deletions Api/Config/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,40 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Api\Config;
namespace ABN\Gateway\Api\Config;

/**
* Config Repository Interface
*/
interface RepositoryInterface
{
/** Provider specific config */
public const CODE = 'two_payment';
public const PROVIDER = 'Two';
public const PAYMENT_TERMS_LINK = 'https://www.two.inc/terms-privacy';
public const URL_TEMPLATE = 'https://%s.two.inc';
public const CODE = 'abn_payment';
public const PROVIDER = 'ABN AMRO';
public const PROVIDER_FULL_NAME = 'ABN AMRO Asset Based Finance N.V.';
public const PRODUCT_NAME = 'Achteraf betalen van ABN AMRO';
public const PAYMENT_TERMS_EMAIL = 'achterafbetalen@nl.abnamro.com';
public const URL_TEMPLATE = 'https://%s.achterafbetalen.abnamro.nl';

/** Payment Group */
public const XML_PATH_ENABLED = 'payment/two_payment/active';
public const XML_PATH_TITLE = 'payment/two_payment/title';
public const XML_PATH_MODE = 'payment/two_payment/mode';
public const XML_PATH_API_KEY = 'payment/two_payment/api_key';
public const XML_PATH_DAYS_ON_INVOICE = 'payment/two_payment/days_on_invoice';
public const XML_PATH_FULFILL_TRIGGER = 'payment/two_payment/fulfill_trigger';
public const XML_PATH_FULFILL_ORDER_STATUS = 'payment/two_payment/fulfill_order_status';
public const XML_PATH_ENABLE_COMPANY_SEARCH = 'payment/two_payment/enable_company_search';
public const XML_PATH_ENABLE_ADDRESS_SEARCH = 'payment/two_payment/enable_address_search';
public const XML_PATH_ENABLE_TAX_SUBTOTALS = 'payment/two_payment/enable_tax_subtotals';
public const XML_PATH_ENABLE_ORDER_INTENT = 'payment/two_payment/enable_order_intent';
public const XML_PATH_ENABLE_INVOICE_EMAILS = 'payment/two_payment/enable_invoice_emails';
public const XML_PATH_ENABLE_DEPARTMENT_NAME = 'payment/two_payment/enable_department';
public const XML_PATH_ENABLE_PROJECT_NAME = 'payment/two_payment/enable_project';
public const XML_PATH_ENABLE_ORDER_NOTE = 'payment/two_payment/enable_order_note';
public const XML_PATH_ENABLE_PO_NUMBER = 'payment/two_payment/enable_po_number';
public const XML_PATH_VERSION = 'payment/two_payment/version';
public const XML_PATH_DEBUG = 'payment/two_payment/debug';
public const XML_PATH_ENABLED = 'payment/abn_payment/active';
public const XML_PATH_TITLE = 'payment/abn_payment/title';
public const XML_PATH_MODE = 'payment/abn_payment/mode';
public const XML_PATH_API_KEY = 'payment/abn_payment/api_key';
public const XML_PATH_DAYS_ON_INVOICE = 'payment/abn_payment/days_on_invoice';
public const XML_PATH_FULFILL_TRIGGER = 'payment/abn_payment/fulfill_trigger';
public const XML_PATH_FULFILL_ORDER_STATUS = 'payment/abn_payment/fulfill_order_status';
public const XML_PATH_ENABLE_COMPANY_SEARCH = 'payment/abn_payment/enable_company_search';
public const XML_PATH_ENABLE_ADDRESS_SEARCH = 'payment/abn_payment/enable_address_search';
public const XML_PATH_ENABLE_TAX_SUBTOTALS = 'payment/abn_payment/enable_tax_subtotals';
public const XML_PATH_ENABLE_ORDER_INTENT = 'payment/abn_payment/enable_order_intent';
public const XML_PATH_ENABLE_INVOICE_EMAILS = 'payment/abn_payment/enable_invoice_emails';
public const XML_PATH_ENABLE_DEPARTMENT_NAME = 'payment/abn_payment/enable_department';
public const XML_PATH_ENABLE_PROJECT_NAME = 'payment/abn_payment/enable_project';
public const XML_PATH_ENABLE_ORDER_NOTE = 'payment/abn_payment/enable_order_note';
public const XML_PATH_ENABLE_PO_NUMBER = 'payment/abn_payment/enable_po_number';
public const XML_PATH_VERSION = 'payment/abn_payment/version';
public const XML_PATH_DEBUG = 'payment/abn_payment/debug';

/** Weight unit */
public const XML_PATH_WEIGHT_UNIT = 'general/locale/weight_unit';
Expand Down
2 changes: 1 addition & 1 deletion Api/Log/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Api\Log;
namespace ABN\Gateway\Api\Log;

/**
* Log repository interface
Expand Down
2 changes: 1 addition & 1 deletion Api/Webapi/SoleTraderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Api\Webapi;
namespace ABN\Gateway\Api\Webapi;

interface SoleTraderInterface
{
Expand Down
6 changes: 3 additions & 3 deletions Block/Adminhtml/Order/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Block\Adminhtml\Order;
namespace ABN\Gateway\Block\Adminhtml\Order;

use Magento\Sales\Block\Adminhtml\Order\View as OrderView;
use Two\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use Two\Gateway\Service\Api\Adapter as Adapter;
use ABN\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use ABN\Gateway\Service\Api\Adapter as Adapter;

/**
* Order View Block
Expand Down
8 changes: 4 additions & 4 deletions Block/Adminhtml/System/Config/Button/DebugCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Block\Adminhtml\System\Config\Button;
namespace ABN\Gateway\Block\Adminhtml\System\Config\Button;

use Exception;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Two\Gateway\Api\Log\RepositoryInterface as LogRepository;
use ABN\Gateway\Api\Log\RepositoryInterface as LogRepository;

/**
* Debug log check button class
Expand All @@ -23,7 +23,7 @@ class DebugCheck extends Field
/**
* @var string
*/
protected $_template = 'Two_Gateway::system/config/button/debug.phtml';
protected $_template = 'ABN_Gateway::system/config/button/debug.phtml';

/**
* @var LogRepository
Expand Down Expand Up @@ -72,7 +72,7 @@ public function _getElementHtml(AbstractElement $element)
*/
public function getDebugCheckUrl()
{
return $this->getUrl('two/log/debug');
return $this->getUrl('abn/log/debug');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Block/Adminhtml/System/Config/Button/ErrorCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Block\Adminhtml\System\Config\Button;
namespace ABN\Gateway\Block\Adminhtml\System\Config\Button;

use Exception;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Two\Gateway\Api\Log\RepositoryInterface as LogRepository;
use ABN\Gateway\Api\Log\RepositoryInterface as LogRepository;

/**
* Error log check button class
Expand All @@ -24,7 +24,7 @@ class ErrorCheck extends Field
/**
* @var string
*/
protected $_template = 'Two_Gateway::system/config/button/error.phtml';
protected $_template = 'ABN_Gateway::system/config/button/error.phtml';

/**
* @var LogRepository
Expand Down Expand Up @@ -72,7 +72,7 @@ public function _getElementHtml(AbstractElement $element)
*/
public function getErrorCheckUrl()
{
return $this->getUrl('two/log/error');
return $this->getUrl('abn/log/error');
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Block/Adminhtml/System/Config/Field/ApiKeyCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Block\Adminhtml\System\Config\Field;
namespace ABN\Gateway\Block\Adminhtml\System\Config\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Two\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use Two\Gateway\Service\Api\Adapter;
use Two\Gateway\Model\Two;
use ABN\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use ABN\Gateway\Service\Api\Adapter;
use ABN\Gateway\Model\Two;

/**
* Render version field html element in Stores Configuration
Expand All @@ -22,7 +22,7 @@ class ApiKeyCheck extends Field
/**
* @var string
*/
protected $_template = 'Two_Gateway::system/config/field/apikey.phtml';
protected $_template = 'ABN_Gateway::system/config/field/apikey.phtml';

/**
* @var ConfigRepository
Expand Down
6 changes: 3 additions & 3 deletions Block/Adminhtml/System/Config/Field/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Block\Adminhtml\System\Config\Field;
namespace ABN\Gateway\Block\Adminhtml\System\Config\Field;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Backend\Block\Template\Context;

use Two\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use ABN\Gateway\Api\Config\RepositoryInterface as ConfigRepository;

/**
* Render module information html element in Stores Configuration
Expand All @@ -31,7 +31,7 @@ class Header extends Field
/**
* @var string
*/
protected $_template = 'Two_Gateway::system/config/field/header.phtml';
protected $_template = 'ABN_Gateway::system/config/field/header.phtml';

/**
* @param Context $context
Expand Down
6 changes: 3 additions & 3 deletions Block/Adminhtml/System/Config/Field/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Block\Adminhtml\System\Config\Field;
namespace ABN\Gateway\Block\Adminhtml\System\Config\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Two\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use ABN\Gateway\Api\Config\RepositoryInterface as ConfigRepository;

/**
* Render version field html element in Stores Configuration
Expand All @@ -21,7 +21,7 @@ class Version extends Field
/**
* @var string
*/
protected $_template = 'Two_Gateway::system/config/field/version.phtml';
protected $_template = 'ABN_Gateway::system/config/field/version.phtml';

/**
* @var ConfigRepository
Expand Down
4 changes: 2 additions & 2 deletions Controller/Adminhtml/Log/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Controller\Adminhtml\Log;
namespace ABN\Gateway\Controller\Adminhtml\Log;

use Exception;
use Magento\Backend\App\Action;
Expand All @@ -28,7 +28,7 @@ class Debug extends Action
/**
* Debug log file path pattern
*/
public const DEBUG_LOG_FILE = '%s/log/two/debug.log';
public const DEBUG_LOG_FILE = '%s/log/abn/debug.log';

/**
* @var JsonFactory
Expand Down
4 changes: 2 additions & 2 deletions Controller/Adminhtml/Log/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Controller\Adminhtml\Log;
namespace ABN\Gateway\Controller\Adminhtml\Log;

use Exception;
use Magento\Backend\App\Action;
Expand All @@ -28,7 +28,7 @@ class Error extends Action
/**
* Error log file path pattern
*/
public const ERROR_LOG_FILE = '%s/log/two/error.log';
public const ERROR_LOG_FILE = '%s/log/abn/error.log';

/**
* @var JsonFactory
Expand Down
8 changes: 4 additions & 4 deletions Controller/Payment/Cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Controller\Payment;
namespace ABN\Gateway\Controller\Payment;

use Exception;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Exception\LocalizedException;
use Two\Gateway\Service\Payment\OrderService;
use Two\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use ABN\Gateway\Service\Payment\OrderService;
use ABN\Gateway\Api\Config\RepositoryInterface as ConfigRepository;

/**
* Cancel Payment Controller
Expand Down Expand Up @@ -58,7 +58,7 @@ public function execute()
$this->orderService->cancelTwoOrder($order);
$message = __(
'Your invoice purchase with %1 has been cancelled. The cart will be restored.',
$this->configRepository::PROVIDER
$this->configRepository::PRODUCT_NAME
);
throw new LocalizedException($message);
} catch (Exception $exception) {
Expand Down
14 changes: 7 additions & 7 deletions Controller/Payment/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Two\Gateway\Controller\Payment;
namespace ABN\Gateway\Controller\Payment;

use Exception;
use Magento\Customer\Api\AddressRepositoryInterface;
Expand All @@ -15,8 +15,8 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Two\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use Two\Gateway\Service\Payment\OrderService;
use ABN\Gateway\Api\Config\RepositoryInterface as ConfigRepository;
use ABN\Gateway\Service\Payment\OrderService;

/**
* Payment confirm controller
Expand Down Expand Up @@ -84,7 +84,7 @@ public function execute()
} catch (Exception $exception) {
$message = __(
"Failed to update %1 customer address: %2",
$this->configRepository::PROVIDER,
$this->configRepository::PRODUCT_NAME,
$exception->getMessage()
);
$this->orderService->addOrderComment($order, $message);
Expand All @@ -94,13 +94,13 @@ public function execute()
} else {
$comment = __(
'Unable to confirm %1 order with %2 state.',
$this->configRepository::PROVIDER,
$this->configRepository::PRODUCT_NAME,
$twoOrder['state'] ?? 'undefined'
);
$this->orderService->addOrderComment($order, $comment);
$message = __(
'Your invoice purchase with %1 could not be processed. The cart will be restored.',
$this->configRepository::PROVIDER
$this->configRepository::PRODUCT_NAME
);
throw new LocalizedException($message);
}
Expand Down Expand Up @@ -179,7 +179,7 @@ private function updateCustomerAddress($order, $twoOrder)
$this->addressRepository->save($customerAddress);
$message = __(
"%1 customer address updated.",
$this->configRepository::PROVIDER,
$this->configRepository::PRODUCT_NAME,
);
$this->orderService->addOrderComment($order, $message);
}
Expand Down
Loading

0 comments on commit eea5b7e

Please sign in to comment.