Created
November 6, 2018 03:34
-
-
Save ProxiBlue/56ecbc262f61eff9e171893f08abb378 to your computer and use it in GitHub Desktop.
Count Declined Payments From exception.log per day
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
<?php | |
/** | |
* Just a rough script to parse the exception log, find all entries that match the Declined string, and group | |
* them by day. | |
* This effectively shows a major increase in a sites number of declind transactions, for which scripting was the cause | |
* Setup of reCapctha at checkout stopped this issue | |
* | |
* Log example: | |
* 2017-06-22T15:17:06+00:00 ERR (3): | |
* exception 'Mage_Core_Exception' with message 'Declined: 15005-This transaction cannot be processed.' in public_html/app/Mage.php:603 | |
* Stack trace: | |
* | |
* | |
**/ | |
$log = file("./var/log/exception.log"); | |
$instances = []; | |
$prevLine = ''; | |
foreach ($log as $line) { | |
if(strpos($line,'with message \'Declined')) { | |
$dateParts = explode('T', $prevLine); | |
if(isset($instances[$dateParts[0]])) { | |
$instances[$dateParts[0]] = $instances[$dateParts[0]] + 1; | |
} else { | |
$instances[$dateParts[0]] = 1; | |
} | |
} | |
$prevLine = $line; | |
} | |
?> | |
<ul> | |
<?php foreach($instances as $instanceKey => $instanceValue): ?> | |
<li><?php echo (string)$instanceKey?>:<?php echo $instanceValue?></li> | |
<?php endforeach; ?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment