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\Zed\AfterPay\Communication\Plugin\Oms\Condition; |
9
|
|
|
|
10
|
|
|
use Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayTransactionLog; |
|
|
|
|
11
|
|
|
use Orm\Zed\Sales\Persistence\SpySalesOrderItem; |
|
|
|
|
12
|
|
|
use Spryker\Zed\Kernel\Communication\AbstractPlugin; |
13
|
|
|
use Spryker\Zed\Oms\Dependency\Plugin\Condition\ConditionInterface; |
14
|
|
|
use SprykerEco\Shared\AfterPay\AfterPayConfig; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @method \SprykerEco\Zed\AfterPay\Business\AfterPayFacadeInterface getFacade() |
18
|
|
|
* @method \SprykerEco\Zed\AfterPay\Persistence\AfterPayQueryContainerInterface getQueryContainer() |
19
|
|
|
* @method \SprykerEco\Zed\AfterPay\Communication\AfterPayCommunicationFactory getFactory() |
20
|
|
|
* @method \SprykerEco\Zed\AfterPay\AfterPayConfig getConfig() |
21
|
|
|
*/ |
22
|
|
|
class IsAuthorizationCompletedPlugin extends AbstractPlugin implements ConditionInterface |
23
|
|
|
{ |
24
|
|
|
public const AUTHORIZE_TRANSACTION_ACCEPTED = AfterPayConfig::API_TRANSACTION_OUTCOME_ACCEPTED; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @api |
28
|
|
|
* |
29
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem |
30
|
|
|
* |
31
|
|
|
* @return bool |
32
|
|
|
*/ |
33
|
|
|
public function check(SpySalesOrderItem $orderItem): bool |
34
|
|
|
{ |
35
|
|
|
return $this->isAuthorizationTransactionSuccessful($orderItem->getFkSalesOrder()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param int $idSalesOrder |
40
|
|
|
* |
41
|
|
|
* @return bool |
42
|
|
|
*/ |
43
|
|
|
protected function isAuthorizationTransactionSuccessful(int $idSalesOrder): bool |
44
|
|
|
{ |
45
|
|
|
$authorizeTransactionLog = $this->getAuthorizeTransactionLogEntry($idSalesOrder); |
46
|
|
|
if ($authorizeTransactionLog === null) { |
47
|
|
|
return false; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $this->isTransactionSuccessful($authorizeTransactionLog); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param int $idSalesOrder |
55
|
|
|
* |
56
|
|
|
* @return \Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayTransactionLog|null |
57
|
|
|
*/ |
58
|
|
|
protected function getAuthorizeTransactionLogEntry(int $idSalesOrder): ?SpyPaymentAfterPayTransactionLog |
59
|
|
|
{ |
60
|
|
|
$transactionLogQuery = $this->getQueryContainer()->queryAuthorizeTransactionLog($idSalesOrder); |
61
|
|
|
|
62
|
|
|
return $transactionLogQuery->findOne(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param \Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayTransactionLog $authorizeTransactionLog |
67
|
|
|
* |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
protected function isTransactionSuccessful(SpyPaymentAfterPayTransactionLog $authorizeTransactionLog): bool |
71
|
|
|
{ |
72
|
|
|
return $authorizeTransactionLog->getOutcome() === static::AUTHORIZE_TRANSACTION_ACCEPTED; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
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