We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 28277d69 authored by alexandros's avatar alexandros

Replace isPaymentMethodOpenInvoiceMethod with isOpenInvoicePaymentMethod from the library

parent 9efc5be7
......@@ -35,14 +35,21 @@ class CaptureDataBuilder implements BuilderInterface
*/
private $adyenHelper;
/*
* @var \Adyen\Util\OpenInvoice;
*/
private $openInvoice;
/**
* CaptureDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param Adyen\Util\OpenInvoice;
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Util\OpenInvoice $openInvoice)
{
$this->adyenHelper = $adyenHelper;
$this->openInvoice = $openInvoice;
}
/**
......@@ -75,7 +82,7 @@ class CaptureDataBuilder implements BuilderInterface
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
);
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
if ($this->openInvoice->isOpenInvoicePaymentMethod($brandCode)) {
$openInvoiceFields = $this->getOpenInvoiceData($payment);
$requestBody["additionalData"] = $openInvoiceFields;
}
......
......@@ -48,22 +48,31 @@ class CheckoutDataBuilder implements BuilderInterface
*/
private $gender;
/**
* @var \Adyen\Util\OpenInvoice
*/
private $openInvoice;
/**
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Quote\Api\CartRepositoryInterface $cartRepository
* @param \Adyen\Payment\Model\Gender $gender
* @param \Adyen\Util\OpenInvoice $openInvoice
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Quote\Api\CartRepositoryInterface $cartRepository,
\Adyen\Payment\Model\Gender $gender
\Adyen\Payment\Model\Gender $gender,
\Adyen\Util\OpenInvoice $openInvoice
) {
$this->adyenHelper = $adyenHelper;
$this->storeManager = $storeManager;
$this->cartRepository = $cartRepository;
$this->gender = $gender;
$this->openInvoice = $openInvoice;
}
/**
......@@ -150,7 +159,7 @@ class CheckoutDataBuilder implements BuilderInterface
$requestBodyPaymentMethod['sepa.ibanNumber'] = $payment->getAdditionalInformation("ibanNumber");
}
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod(
if ($this->openInvoice->isOpenInvoicePaymentMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
) || $this->adyenHelper->isPaymentMethodAfterpayTouchMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
......
......@@ -45,20 +45,27 @@ class RefundDataBuilder implements BuilderInterface
*/
protected $adyenInvoiceCollectionFactory;
/*
* @var \Adyen\Util\OpenInvoice
*/
private $openInvoice;
/**
* RefundDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $orderPaymentCollectionFactory
* @param \Adyen\Util\OpenInvoice $openInvoice
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $orderPaymentCollectionFactory,
\Adyen\Payment\Model\ResourceModel\Invoice\CollectionFactory $adyenInvoiceCollectionFactory
\Adyen\Payment\Model\ResourceModel\Invoice\CollectionFactory $adyenInvoiceCollectionFactory,
\Adyen\Util\OpenInvoice $openInvoice
) {
$this->adyenHelper = $adyenHelper;
$this->orderPaymentCollectionFactory = $orderPaymentCollectionFactory;
$this->adyenInvoiceCollectionFactory = $adyenInvoiceCollectionFactory;
$this->openInvoice = $openInvoice;
}
/**
......@@ -165,7 +172,7 @@ class RefundDataBuilder implements BuilderInterface
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
);
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
if ( $this->openInvoice->isOpenInvoicePaymentMethod($brandCode)) {
$openInvoiceFields = $this->getOpenInvoiceData($payment);
//There is only one payment, so we add the fields to the first(and only) result
......
......@@ -144,6 +144,11 @@ class Data extends AbstractHelper
*/
private $componentRegistrar;
/**
* @var \Adyen\Util\OpenInvoice
*/
private $openInvoice;
/**
* Data constructor.
*
......@@ -168,6 +173,7 @@ class Data extends AbstractHelper
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Backend\Helper\Data $helperBackend
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
* @param \Adyen\Util\OpenInvoice $openInvoice
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
......@@ -191,7 +197,8 @@ class Data extends AbstractHelper
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Backend\Helper\Data $helperBackend,
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar
\Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar,
\Adyen\Util\OpenInvoice $openInvoice
) {
parent::__construct($context);
$this->_encryptor = $encryptor;
......@@ -215,6 +222,7 @@ class Data extends AbstractHelper
$this->helperBackend = $helperBackend;
$this->serializer = $serializer;
$this->componentRegistrar = $componentRegistrar;
$this->openInvoice = $openInvoice;
}
/**
......@@ -1061,6 +1069,7 @@ class Data extends AbstractHelper
/**
* @param $paymentMethod
* @return bool
* @depecated
*/
public function isPaymentMethodOpenInvoiceMethod($paymentMethod)
{
......@@ -1133,7 +1142,7 @@ class Data extends AbstractHelper
*/
public function doesPaymentMethodSkipDetails($paymentMethod)
{
if ($this->isPaymentMethodOpenInvoiceMethod($paymentMethod) ||
if ($this->openInvoice->isOpenInvoicePaymentMethod($paymentMethod) ||
$this->isPaymentMethodMolpayMethod($paymentMethod) ||
$this->isPaymentMethodOneyMethod($paymentMethod)
) {
......
......@@ -90,6 +90,11 @@ class PaymentMethods extends AbstractHelper
*/
protected $quote;
/**
* @var \Adyen\Util\OpenInvoice
*/
private $openInvoice;
/**
* PaymentMethods constructor.
*
......@@ -104,6 +109,7 @@ class PaymentMethods extends AbstractHelper
* @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Magento\Framework\View\DesignInterface $design
* @param \Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider
* @param \Adyen\Util\OpenInvoice $openInvoice
*/
public function __construct(
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
......@@ -116,7 +122,8 @@ class PaymentMethods extends AbstractHelper
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\View\Asset\Source $assetSource,
\Magento\Framework\View\DesignInterface $design,
\Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider
\Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider,
\Adyen\Util\OpenInvoice $openInvoice
) {
$this->quoteRepository = $quoteRepository;
$this->config = $config;
......@@ -129,6 +136,7 @@ class PaymentMethods extends AbstractHelper
$this->assetSource = $assetSource;
$this->design = $design;
$this->themeProvider = $themeProvider;
$this->openInvoice = $openInvoice;
}
/**
......@@ -199,8 +207,8 @@ class PaymentMethods extends AbstractHelper
$paymentMethod = $this->fieldMapPaymentMethod($paymentMethod);
// check if payment method is an openinvoice method
$paymentMethod['isPaymentMethodOpenInvoiceMethod'] =
$this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethodCode);
$paymentMethod['isOpenInvoicePaymentMethod'] =
$this->openInvoice->isOpenInvoicePaymentMethod($paymentMethodCode);
// add icon location in result
if ($this->adyenHelper->showLogos()) {
......
......@@ -49,21 +49,29 @@ class Requests extends AbstractHelper
*/
private $urlBuilder;
/*
* @var \Adyen\Util\OpenInvoice
*/
private $openInvoice;
/**
* Requests constructor.
*
* @param Data $adyenHelper
* @param Config $adyenConfig
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Adyen\Util\OpenInvoice
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Helper\Config $adyenConfig,
\Magento\Framework\UrlInterface $urlBuilder
\Magento\Framework\UrlInterface $urlBuilder,
\Adyen\Util\OpenInvoice $openInvoice
) {
$this->adyenHelper = $adyenHelper;
$this->adyenConfig = $adyenConfig;
$this->urlBuilder = $urlBuilder;
$this->openInvoice = $openInvoice;
}
/**
......@@ -116,8 +124,8 @@ class Requests extends AbstractHelper
// In case of virtual product and guest checkout there is a workaround to get the guest's email address
if (!empty($additionalData['guestEmail'])) {
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
!$this->adyenHelper->isPaymentMethodAfterpayTouchMethod($paymentMethod)
if ($this->openInvoice->isOpenInvoicePaymentMethod($paymentMethod) &&
!$this->openInvoice->isAfterPayTouchPaymentMethod($paymentMethod)
) {
$request['paymentMethod']['personalDetails']['shopperEmail'] = $additionalData['guestEmail'];
} else {
......@@ -127,8 +135,8 @@ class Requests extends AbstractHelper
if (!empty($billingAddress)) {
// Openinvoice (klarna and afterpay BUT not afterpay touch) methods requires different request format
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
!$this->adyenHelper->isPaymentMethodAfterpayTouchMethod($paymentMethod)
if ($this->openInvoice->isOpenInvoicePaymentMethod($paymentMethod)&&
!$this->openInvoice->isAfterPayTouchPaymentMethod($paymentMethod)
) {
if ($customerEmail = $billingAddress->getEmail()) {
$request['paymentMethod']['personalDetails']['shopperEmail'] = $customerEmail;
......
......@@ -269,6 +269,11 @@ class Cron
*/
protected $encryptor;
/**
* @var \Adyen\Util\OpenInvoice
*/
private $openInvoice;
/**
* Cron constructor.
*
......@@ -300,6 +305,7 @@ class Cron
* @param PaymentTokenFactoryInterface $paymentTokenFactory
* @param PaymentTokenRepositoryInterface $paymentTokenRepository
* @param EncryptorInterface $encryptor
* @param \Adyen\Util\OpenInvoice $openInvoice
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
......@@ -329,7 +335,8 @@ class Cron
PaymentTokenManagement $paymentTokenManagement,
PaymentTokenFactoryInterface $paymentTokenFactory,
PaymentTokenRepositoryInterface $paymentTokenRepository,
EncryptorInterface $encryptor
EncryptorInterface $encryptor,
\Adyen\Util\OpenInvoice $openInvoice
) {
$this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger;
......@@ -359,6 +366,7 @@ class Cron
$this->paymentTokenFactory = $paymentTokenFactory;
$this->paymentTokenRepository = $paymentTokenRepository;
$this->encryptor = $encryptor;
$this->openInvoice = $openInvoice;
}
/**
......@@ -752,7 +760,7 @@ class Cron
}
// if payment method is klarna, ratepay or openinvoice/afterpay show the reservartion number
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod(
if ($this->openInvoice->isOpenInvoicePaymentMethod(
$this->_paymentMethod) && !empty($this->_klarnaReservationNumber)) {
$klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber;
} else {
......@@ -1688,7 +1696,7 @@ class Cron
// if auto capture mode for openinvoice is turned on then use auto capture
if ($captureModeOpenInvoice == true &&
$this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_paymentMethod)
$this->openInvoice->isOpenInvoicePaymentMethod($this->_paymentMethod)
) {
$this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method is configured to be working as auto capture '
......@@ -1722,7 +1730,7 @@ class Cron
* online capture after delivery, use Magento backend to online invoice
* (if the option auto capture mode for openinvoice is not set)
*/
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_paymentMethod)) {
if ($this->openInvoice->isOpenInvoicePaymentMethod($this->_paymentMethod)) {
$this->_adyenLogger->addAdyenNotificationCronjob
(
'Capture mode for klarna is by default set to manual'
......@@ -1754,7 +1762,7 @@ class Cron
$paymentMethod = $this->_paymentMethod;
// For all openinvoice methods manual capture is the default
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod)) {
if ($this->openInvoice->isOpenInvoicePaymentMethod($paymentMethod)) {
return true;
}
......
......@@ -49,21 +49,28 @@ class BeforeShipmentObserver extends AbstractDataAssignObserver
*/
private $invoiceRepository;
/**
* @var \Adyen\Util\OpenInvoice
*/
private $openInvoice;
/**
* BeforeShipmentObserver constructor.
*
* @param AdyenHelper $adyenHelper
* @param AdyenLogger $logger
* @param InvoiceRepository $invoiceRepository
* @param \Adyen\Util\OpenInvoice $openInvoice
*/
public function __construct(
AdyenHelper $adyenHelper,
AdyenLogger $logger,
InvoiceRepository $invoiceRepository
InvoiceRepository $invoiceRepository,
\Adyen\Util\OpenInvoice $openInvoice
) {
$this->adyenHelper = $adyenHelper;
$this->logger = $logger;
$this->invoiceRepository = $invoiceRepository;
$this->openInvoice = $openInvoice;
}
/**
......@@ -101,7 +108,7 @@ class BeforeShipmentObserver extends AbstractDataAssignObserver
$payment = $order->getPayment();
$brandCode = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE);
if (!$this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
if (!$this->openInvoice->isOpenInvoicePaymentMethod($brandCode)) {
$this->logger->info(
"Payment method is from Adyen but isn't OpenInvoice for order id {$order->getId()}",
['observer' => 'BeforeShipmentObserver']
......
......@@ -225,22 +225,22 @@ define(
};
/**
* Checks if payment method is open invoice
* @returns {*|isPaymentMethodOpenInvoiceMethod}
* @returns {*|isOpenInvoicePaymentMethod}
*/
result.isPaymentMethodOpenInvoiceMethod = function () {
return value.isPaymentMethodOpenInvoiceMethod;
result.isOpenInvoicePaymentMethod = function () {
return value.isOpenInvoicePaymentMethod;
};
/**
* Checks if payment method is open invoice but not in the list below
* [klarna, afterpay]
* @returns {boolean}
*/
result.isPaymentMethodOtherOpenInvoiceMethod = function () {
result.isOpenInvoicePaymentMethod = function () {
if (
!result.isPaymentMethodAfterPay() &&
!result.isPaymentMethodKlarna() &&
!result.isPaymentMethodAfterPayTouch() &&
value.isPaymentMethodOpenInvoiceMethod
value.isOpenInvoicePaymentMethod
) {
return true;
}
......@@ -500,7 +500,7 @@ define(
if (self.hasIssuersAvailable()) {
additionalData.issuer_id = this.issuer();
} else if (self.isPaymentMethodOpenInvoiceMethod()) {
} else if (self.isOpenInvoicePaymentMethod()) {
additionalData.gender = this.gender();
additionalData.dob = this.dob();
additionalData.telephone = this.telephone();
......@@ -532,7 +532,7 @@ define(
result.issuerIds = result.getIssuers();
result.issuer = ko.observable(null);
} else if (value.isPaymentMethodOpenInvoiceMethod) {
} else if (value.isOpenInvoicePaymentMethod) {
result.telephone = ko.observable(quote.shippingAddress().telephone);
result.gender = ko.observable(window.checkoutConfig.payment.adyenHpp.gender);
result.dob = ko.observable(window.checkoutConfig.payment.adyenHpp.dob);
......
......@@ -145,7 +145,7 @@
<div class="checkout-component-dock" afterRender="renderAfterPayComponent()" data-bind="attr: { id: 'afterPayContainer'}"></div>
<!--/ko-->
<!-- ko if: isPaymentMethodOtherOpenInvoiceMethod() -->
<!-- ko if: isOpenInvoicePaymentMethod() -->
<div class="field gender required">
<label data-bind="attr: {for: getCode() + '_gender_type_' + value}" class="label">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment