|
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\Heidelpay\Communication\Oms\Condition; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\HeidelpayNotificationCollectionTransfer; |
|
|
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\OrderTransfer; |
|
|
|
|
|
|
12
|
|
|
use Orm\Zed\Sales\Persistence\SpySalesOrderItem; |
|
|
|
|
|
|
13
|
|
|
use SprykerEco\Zed\Heidelpay\Dependency\Facade\HeidelpayToSalesFacadeInterface; |
|
14
|
|
|
use SprykerEco\Zed\Heidelpay\Persistence\HeidelpayRepositoryInterface; |
|
15
|
|
|
|
|
16
|
|
|
class IsOrderPaidOmsCondition implements HeidelpayOmsConditionInterface |
|
17
|
|
|
{ |
|
18
|
|
|
protected const PAID_RECEIPT_PAYMENT_CODE = 'IV.RC'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayRepositoryInterface |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $repository; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var \SprykerEco\Zed\Heidelpay\Dependency\Facade\HeidelpayToSalesFacadeInterface |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $salesFacade; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayRepositoryInterface $repository |
|
32
|
|
|
* @param \SprykerEco\Zed\Heidelpay\Dependency\Facade\HeidelpayToSalesFacadeInterface $salesFacade |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct( |
|
35
|
|
|
HeidelpayRepositoryInterface $repository, |
|
36
|
|
|
HeidelpayToSalesFacadeInterface $salesFacade |
|
37
|
|
|
) { |
|
38
|
|
|
$this->repository = $repository; |
|
39
|
|
|
$this->salesFacade = $salesFacade; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem |
|
44
|
|
|
* |
|
45
|
|
|
* @return bool |
|
46
|
|
|
*/ |
|
47
|
|
|
public function check(SpySalesOrderItem $orderItem): bool |
|
48
|
|
|
{ |
|
49
|
|
|
$heidelpayNotificationCollection = $this->repository |
|
50
|
|
|
->getPaymentHeidelpayNotificationCollectionByTransactionIdAndPaymentCode( |
|
51
|
|
|
(string)$orderItem->getFkSalesOrder(), |
|
52
|
|
|
static::PAID_RECEIPT_PAYMENT_CODE |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
|
|
if ($heidelpayNotificationCollection->getNotifications()->count() === 0) { |
|
56
|
|
|
return false; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$orderTransfer = $this->salesFacade |
|
60
|
|
|
->getOrderByIdSalesOrder($orderItem->getFkSalesOrder()); |
|
61
|
|
|
|
|
62
|
|
|
return $this->isOrderPaid($heidelpayNotificationCollection, $orderTransfer); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param \Generated\Shared\Transfer\HeidelpayNotificationCollectionTransfer $heidelpayNotificationCollection |
|
67
|
|
|
* @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer |
|
68
|
|
|
* |
|
69
|
|
|
* @return bool |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function isOrderPaid( |
|
72
|
|
|
HeidelpayNotificationCollectionTransfer $heidelpayNotificationCollection, |
|
73
|
|
|
OrderTransfer $orderTransfer |
|
74
|
|
|
): bool { |
|
75
|
|
|
$paidAmount = 0; |
|
76
|
|
|
|
|
77
|
|
|
foreach ($heidelpayNotificationCollection->getNotifications() as $heidelpayNotificationTransfer) { |
|
78
|
|
|
$paidAmount += $heidelpayNotificationTransfer->getAmount(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
return $paidAmount === $orderTransfer->getTotals()->getPriceToPay(); |
|
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