1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\CrefoPay\Processor\Notification; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\CrefoPayNotificationTransfer; |
|
|
|
|
11
|
|
|
use SprykerEco\Client\CrefoPay\CrefoPayClientInterface; |
12
|
|
|
use SprykerEco\Yves\CrefoPay\Dependency\Service\CrefoPayToCrefoPayApiServiceInterface; |
13
|
|
|
use SprykerEco\Yves\CrefoPay\Processor\Notification\Mapper\CrefoPayNotificationProcessorMapperInterface; |
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
15
|
|
|
|
16
|
|
|
class CrefoPayNotificationProcessor implements CrefoPayNotificationProcessorInterface |
17
|
|
|
{ |
18
|
|
|
protected const API_FIELD_MAC = 'mac'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var \SprykerEco\Yves\CrefoPay\Processor\Notification\Mapper\CrefoPayNotificationProcessorMapperInterface |
22
|
|
|
*/ |
23
|
|
|
protected $mapper; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var \SprykerEco\Client\CrefoPay\CrefoPayClientInterface |
27
|
|
|
*/ |
28
|
|
|
protected $crefoPayClient; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \SprykerEco\Yves\CrefoPay\Dependency\Service\CrefoPayToCrefoPayApiServiceInterface |
32
|
|
|
*/ |
33
|
|
|
protected $crefoPayApiService; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param \SprykerEco\Yves\CrefoPay\Processor\Notification\Mapper\CrefoPayNotificationProcessorMapperInterface $mapper |
37
|
|
|
* @param \SprykerEco\Client\CrefoPay\CrefoPayClientInterface $crefoPayClient |
38
|
|
|
* @param \SprykerEco\Yves\CrefoPay\Dependency\Service\CrefoPayToCrefoPayApiServiceInterface $crefoPayApiService |
39
|
|
|
*/ |
40
|
|
|
public function __construct( |
41
|
|
|
CrefoPayNotificationProcessorMapperInterface $mapper, |
42
|
|
|
CrefoPayClientInterface $crefoPayClient, |
43
|
|
|
CrefoPayToCrefoPayApiServiceInterface $crefoPayApiService |
44
|
|
|
) { |
45
|
|
|
$this->mapper = $mapper; |
46
|
|
|
$this->crefoPayClient = $crefoPayClient; |
47
|
|
|
$this->crefoPayApiService = $crefoPayApiService; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
52
|
|
|
* |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
public function processNotification(Request $request): void |
56
|
|
|
{ |
57
|
|
|
if (!$this->validateMac($request)) { |
58
|
|
|
return; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$notificationTransfer = $this->mapper |
62
|
|
|
->mapRequestToNotificationTransfer( |
63
|
|
|
$request, |
64
|
|
|
new CrefoPayNotificationTransfer() |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
$this->crefoPayClient->processNotification($notificationTransfer); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
72
|
|
|
* |
73
|
|
|
* @return bool |
74
|
|
|
*/ |
75
|
|
|
protected function validateMac(Request $request): bool |
76
|
|
|
{ |
77
|
|
|
$requestParams = $request->request->all(); |
78
|
|
|
$macString = $requestParams[static::API_FIELD_MAC]; |
79
|
|
|
unset($requestParams[static::API_FIELD_MAC]); |
80
|
|
|
|
81
|
|
|
return $this->crefoPayApiService->validateMac($requestParams, $macString); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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