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
7e9369cf
Commit
7e9369cf
authored
Jun 10, 2020
by
attilak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delay OFFER_CLOSED notifications processing by 10 minutes
parent
1f0bd282
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
Model/Cron.php
Model/Cron.php
+21
-4
No files found.
Model/Cron.php
View file @
7e9369cf
...
...
@@ -355,7 +355,27 @@ class Cron
$notifications
->
addFieldToFilter
(
'created_at'
,
$dateRange
);
$notifications
->
addFieldToFilter
(
'error_count'
,
[
'lt'
=>
Notification
::
MAX_ERROR_COUNT
]);
// Process the notifications in ascending order by creation date and event_code
$notifications
->
getSelect
()
->
order
(
'created_at ASC'
)
->
order
(
'event_code ASC'
);
// OFFER_CLOSED notifications needs to be at least 10 minutes old to be processed
$offerClosedMinDate
=
new
\DateTime
();
$offerClosedMinDate
->
modify
(
'-10 minutes'
);
foreach
(
$notifications
as
$notification
)
{
// Remove OFFER_CLOSED notifications arrived in the last 10 minutes from the list to process to ensure it
// won't close any order which has an AUTHOIRSED notification arrived a bit later than the OFFER_CLOSED one.
$createdAt
=
\DateTime
::
createFromFormat
(
'Y-m-d H:i:s'
,
$notification
[
'created_at'
]);
$minutesUntilProcessing
=
$offerClosedMinDate
->
diff
(
$createdAt
)
->
i
;
if
(
$notification
[
'event_code'
]
==
Notification
::
OFFER_CLOSED
&&
$minutesUntilProcessing
>
0
)
{
$this
->
_adyenLogger
->
addAdyenNotificationCronjob
(
sprintf
(
'OFFER_CLOSED notification %s skipped! Wait %s minute(s) before processing.'
,
$notification
->
getEntityId
(),
$minutesUntilProcessing
)
);
$notifications
->
removeItemByKey
(
$notification
->
getId
());
continue
;
}
// set Cron processing to true
$this
->
_updateNotification
(
$notification
,
true
,
false
);
}
...
...
@@ -459,7 +479,7 @@ class Cron
);
}
//Trigger admin notice for unsuccessful REFUND notifications
if
(
$this
->
_eventCode
==
Notification
::
REFUND
){
if
(
$this
->
_eventCode
==
Notification
::
REFUND
)
{
$this
->
addRefundFailedNotice
();
}
}
else
{
...
...
@@ -882,7 +902,6 @@ class Cron
*/
protected
function
_processNotification
()
{
$this
->
_adyenLogger
->
addAdyenNotificationCronjob
(
'Processing the notification'
);
$_paymentCode
=
$this
->
_paymentMethodCode
();
...
...
@@ -1143,10 +1162,8 @@ class Cron
// Populate billing agreement data
$billingAgreement
->
parseRecurringContractData
(
$contractDetail
);
if
(
$billingAgreement
->
isValid
())
{
if
(
!
$this
->
agreementResourceModel
->
getOrderRelation
(
$billingAgreement
->
getAgreementId
(),
$this
->
_order
->
getId
()))
{
// save into sales_billing_agreement_order
$billingAgreement
->
addOrderRelation
(
$this
->
_order
);
...
...
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