Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Adyen Magento2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared Libs
Adyen Magento2
Commits
28277d69
Commit
28277d69
authored
Dec 11, 2020
by
alexandros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace isPaymentMethodOpenInvoiceMethod with isOpenInvoicePaymentMethod from the library
parent
9efc5be7
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
94 additions
and
31 deletions
+94
-31
Gateway/Request/CaptureDataBuilder.php
Gateway/Request/CaptureDataBuilder.php
+9
-2
Gateway/Request/CheckoutDataBuilder.php
Gateway/Request/CheckoutDataBuilder.php
+11
-2
Gateway/Request/RefundDataBuilder.php
Gateway/Request/RefundDataBuilder.php
+9
-2
Helper/Data.php
Helper/Data.php
+11
-2
Helper/PaymentMethods.php
Helper/PaymentMethods.php
+11
-3
Helper/Requests.php
Helper/Requests.php
+13
-5
Model/Cron.php
Model/Cron.php
+13
-5
Observer/BeforeShipmentObserver.php
Observer/BeforeShipmentObserver.php
+9
-2
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
...d/web/js/view/payment/method-renderer/adyen-hpp-method.js
+7
-7
view/frontend/web/template/payment/hpp-form.html
view/frontend/web/template/payment/hpp-form.html
+1
-1
No files found.
Gateway/Request/CaptureDataBuilder.php
View file @
28277d69
...
...
@@ -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
->
isPaymentMethodOpenInvoice
Method
(
$brandCode
))
{
if
(
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$brandCode
))
{
$openInvoiceFields
=
$this
->
getOpenInvoiceData
(
$payment
);
$requestBody
[
"additionalData"
]
=
$openInvoiceFields
;
}
...
...
Gateway/Request/CheckoutDataBuilder.php
View file @
28277d69
...
...
@@ -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
->
isPaymentMethodOpenInvoice
Method
(
if
(
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$payment
->
getAdditionalInformation
(
AdyenHppDataAssignObserver
::
BRAND_CODE
)
)
||
$this
->
adyenHelper
->
isPaymentMethodAfterpayTouchMethod
(
$payment
->
getAdditionalInformation
(
AdyenHppDataAssignObserver
::
BRAND_CODE
)
...
...
Gateway/Request/RefundDataBuilder.php
View file @
28277d69
...
...
@@ -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
->
isPaymentMethodOpenInvoice
Method
(
$brandCode
))
{
if
(
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$brandCode
))
{
$openInvoiceFields
=
$this
->
getOpenInvoiceData
(
$payment
);
//There is only one payment, so we add the fields to the first(and only) result
...
...
Helper/Data.php
View file @
28277d69
...
...
@@ -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
->
isPaymentMethodOpenInvoice
Method
(
$paymentMethod
)
||
if
(
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$paymentMethod
)
||
$this
->
isPaymentMethodMolpayMethod
(
$paymentMethod
)
||
$this
->
isPaymentMethodOneyMethod
(
$paymentMethod
)
)
{
...
...
Helper/PaymentMethods.php
View file @
28277d69
...
...
@@ -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
[
'is
PaymentMethodOpenInvoice
Method'
]
=
$this
->
adyenHelper
->
isPaymentMethodOpenInvoice
Method
(
$paymentMethodCode
);
$paymentMethod
[
'is
OpenInvoicePayment
Method'
]
=
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$paymentMethodCode
);
// add icon location in result
if
(
$this
->
adyenHelper
->
showLogos
())
{
...
...
Helper/Requests.php
View file @
28277d69
...
...
@@ -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
->
isPaymentMethodOpenInvoice
Method
(
$paymentMethod
)
&&
!
$this
->
adyenHelper
->
isPaymentMethodAfterpayTouch
Method
(
$paymentMethod
)
if
(
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$paymentMethod
)
&&
!
$this
->
openInvoice
->
isAfterPayTouchPayment
Method
(
$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
->
isPaymentMethodAfterpayTouch
Method
(
$paymentMethod
)
if
(
$this
->
openInvoice
->
isOpenInvoicePaymentMethod
(
$paymentMethod
)
&&
!
$this
->
openInvoice
->
isAfterPayTouchPayment
Method
(
$paymentMethod
)
)
{
if
(
$customerEmail
=
$billingAddress
->
getEmail
())
{
$request
[
'paymentMethod'
][
'personalDetails'
][
'shopperEmail'
]
=
$customerEmail
;
...
...
Model/Cron.php
View file @
28277d69
...
...
@@ -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
->
isPaymentMethodOpenInvoice
Method
(
if
(
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$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
->
isPaymentMethodOpenInvoice
Method
(
$this
->
_paymentMethod
)
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$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
->
isPaymentMethodOpenInvoice
Method
(
$this
->
_paymentMethod
))
{
if
(
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$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
->
isPaymentMethodOpenInvoice
Method
(
$paymentMethod
))
{
if
(
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$paymentMethod
))
{
return
true
;
}
...
...
Observer/BeforeShipmentObserver.php
View file @
28277d69
...
...
@@ -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
->
isPaymentMethodOpenInvoice
Method
(
$brandCode
))
{
if
(
!
$this
->
openInvoice
->
isOpenInvoicePayment
Method
(
$brandCode
))
{
$this
->
logger
->
info
(
"Payment method is from Adyen but isn't OpenInvoice for order id
{
$order
->
getId
()
}
"
,
[
'observer'
=>
'BeforeShipmentObserver'
]
...
...
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
View file @
28277d69
...
...
@@ -225,22 +225,22 @@ define(
};
/**
* Checks if payment method is open invoice
* @returns {*|is
PaymentMethodOpenInvoice
Method}
* @returns {*|is
OpenInvoicePayment
Method}
*/
result
.
is
PaymentMethodOpenInvoice
Method
=
function
()
{
return
value
.
is
PaymentMethodOpenInvoice
Method
;
result
.
is
OpenInvoicePayment
Method
=
function
()
{
return
value
.
is
OpenInvoicePayment
Method
;
};
/**
* Checks if payment method is open invoice but not in the list below
* [klarna, afterpay]
* @returns {boolean}
*/
result
.
is
PaymentMethodOtherOpenInvoice
Method
=
function
()
{
result
.
is
OpenInvoicePayment
Method
=
function
()
{
if
(
!
result
.
isPaymentMethodAfterPay
()
&&
!
result
.
isPaymentMethodKlarna
()
&&
!
result
.
isPaymentMethodAfterPayTouch
()
&&
value
.
is
PaymentMethodOpenInvoice
Method
value
.
is
OpenInvoicePayment
Method
)
{
return
true
;
}
...
...
@@ -500,7 +500,7 @@ define(
if
(
self
.
hasIssuersAvailable
())
{
additionalData
.
issuer_id
=
this
.
issuer
();
}
else
if
(
self
.
is
PaymentMethodOpenInvoice
Method
())
{
}
else
if
(
self
.
is
OpenInvoicePayment
Method
())
{
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
.
is
PaymentMethodOpenInvoice
Method
)
{
}
else
if
(
value
.
is
OpenInvoicePayment
Method
)
{
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
);
...
...
view/frontend/web/template/payment/hpp-form.html
View file @
28277d69
...
...
@@ -145,7 +145,7 @@
<div
class=
"checkout-component-dock"
afterRender=
"renderAfterPayComponent()"
data-bind=
"attr: { id: 'afterPayContainer'}"
></div>
<!--/ko-->
<!-- ko if: is
PaymentMethodOtherOpenInvoice
Method() -->
<!-- ko if: is
OpenInvoicePayment
Method() -->
<div
class=
"field gender required"
>
<label
data-bind=
"attr: {for: getCode() + '_gender_type_' + value}"
class=
"label"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment