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\Checkout\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
|
|
|
use SprykerEco\Shared\Afterpay\AfterpayConstants; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @method \SprykerEco\Zed\Afterpay\Business\AfterpayFacadeInterface getFacade() |
19
|
|
|
* @method \SprykerEco\Zed\Afterpay\Persistence\AfterpayQueryContainer getQueryContainer() |
20
|
|
|
* @method \SprykerEco\Zed\Afterpay\Communication\AfterpayCommunicationFactory getFactory() |
21
|
|
|
* @method \SprykerEco\Zed\Afterpay\AfterpayConfig getConfig() |
22
|
|
|
*/ |
23
|
|
|
class IsCaptureCompletedPlugin extends AbstractPlugin implements ConditionInterface |
24
|
|
|
{ |
25
|
|
|
public const CAPTURE_TRANSACTION_ACCEPTED = AfterpayConfig::API_TRANSACTION_OUTCOME_ACCEPTED; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @api |
29
|
|
|
* |
30
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem |
31
|
|
|
* |
32
|
|
|
* @return bool |
33
|
|
|
*/ |
34
|
|
|
public function check(SpySalesOrderItem $orderItem): bool |
35
|
|
|
{ |
36
|
|
|
return $this->isCaptureTransactionSuccessful($orderItem->getFkSalesOrder()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param int $idSalesOrder |
41
|
|
|
* |
42
|
|
|
* @return bool |
43
|
|
|
*/ |
44
|
|
|
protected function isCaptureTransactionSuccessful(int $idSalesOrder): bool |
45
|
|
|
{ |
46
|
|
|
$captureTransactionLog = $this->getFullCaptureTransactionLogEntry($idSalesOrder); |
47
|
|
|
if ($captureTransactionLog === null) { |
48
|
|
|
return false; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return $this->isTransactionSuccessful($captureTransactionLog); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param int $idSalesOrder |
56
|
|
|
* |
57
|
|
|
* @return \Orm\Zed\Afterpay\Persistence\SpyPaymentAfterpayTransactionLog|null |
58
|
|
|
*/ |
59
|
|
|
protected function getFullCaptureTransactionLogEntry(int $idSalesOrder): ?SpyPaymentAfterpayTransactionLog |
60
|
|
|
{ |
61
|
|
|
$transactionLogQuery = $this->getQueryContainer()->queryCaptureTransactionLog($idSalesOrder); |
62
|
|
|
|
63
|
|
|
return $transactionLogQuery->findOne(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param \Orm\Zed\Afterpay\Persistence\SpyPaymentAfterpayTransactionLog $captureTransactionLog |
68
|
|
|
* |
69
|
|
|
* @return bool |
70
|
|
|
*/ |
71
|
|
|
protected function isTransactionSuccessful(SpyPaymentAfterpayTransactionLog $captureTransactionLog): bool |
72
|
|
|
{ |
73
|
|
|
return $captureTransactionLog->getOutcome() === static::CAPTURE_TRANSACTION_ACCEPTED; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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