|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Apache OSL-2 |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Amazonpay\Business\Payment\Handler\Transaction\Logger; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\AmazonpayResponseHeaderTransfer; |
|
11
|
|
|
use Orm\Zed\Amazonpay\Persistence\SpyPaymentAmazonpayApiLog; |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class TransactionLogger implements TransactionLoggerInterface |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
const REPORT_LEVEL_ALL = 'ALL'; |
|
17
|
|
|
const REPORT_LEVEL_ERRORS_ONLY = 'ERRORS_ONLY'; |
|
18
|
|
|
const REPORT_LEVEL_DISABLED = 'DISABLED'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var int |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $reportLevel; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param string $reportLevel |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct($reportLevel) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->reportLevel = $reportLevel; |
|
|
|
|
|
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayResponseHeaderTransfer $headerTransfer |
|
35
|
|
|
* |
|
36
|
|
|
* @return bool |
|
37
|
|
|
*/ |
|
38
|
|
|
protected function isLoggingEnabled(AmazonpayResponseHeaderTransfer $headerTransfer) |
|
39
|
|
|
{ |
|
40
|
|
|
if ($this->reportLevel === self::REPORT_LEVEL_ALL) { |
|
41
|
|
|
return true; |
|
42
|
|
|
}; |
|
43
|
|
|
|
|
44
|
|
|
if ($this->reportLevel === self::REPORT_LEVEL_DISABLED) { |
|
45
|
|
|
return false; |
|
46
|
|
|
}; |
|
47
|
|
|
|
|
48
|
|
|
if ($this->reportLevel === self::REPORT_LEVEL_ERRORS_ONLY) { |
|
49
|
|
|
return !$headerTransfer->getIsSuccess(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return false; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param string $orderReferenceId |
|
57
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayResponseHeaderTransfer $headerTransfer |
|
58
|
|
|
* |
|
59
|
|
|
* @return void |
|
60
|
|
|
*/ |
|
61
|
|
|
public function log($orderReferenceId, AmazonpayResponseHeaderTransfer $headerTransfer) |
|
62
|
|
|
{ |
|
63
|
|
|
if (!$this->isLoggingEnabled($headerTransfer)) { |
|
64
|
|
|
return; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$logEntity = new SpyPaymentAmazonpayApiLog(); |
|
68
|
|
|
$logEntity->setOrderReferenceId($orderReferenceId); |
|
69
|
|
|
$logEntity->setStatusCode($headerTransfer->getStatusCode()); |
|
70
|
|
|
$logEntity->setRequestId($headerTransfer->getRequestId()); |
|
71
|
|
|
$logEntity->setErrorMessage($headerTransfer->getErrorMessage()); |
|
72
|
|
|
$logEntity->setErrorCode($headerTransfer->getErrorCode()); |
|
73
|
|
|
$logEntity->save(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths