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\Braintree\Communication\Plugin\Oms\Command; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\TransactionMetaTransfer; |
|
|
|
|
11
|
|
|
use Orm\Zed\Sales\Persistence\SpySalesOrder; |
|
|
|
|
12
|
|
|
use Spryker\Zed\Kernel\Communication\AbstractPlugin; |
13
|
|
|
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject; |
14
|
|
|
use Spryker\Zed\Oms\Dependency\Plugin\Command\CommandByOrderInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @method \SprykerEco\Zed\Braintree\Business\BraintreeFacadeInterface getFacade() |
18
|
|
|
* @method \SprykerEco\Zed\Braintree\Communication\BraintreeCommunicationFactory getFactory() |
19
|
|
|
* @method \SprykerEco\Zed\Braintree\BraintreeConfig getConfig() |
20
|
|
|
* @method \SprykerEco\Zed\Braintree\Persistence\BraintreeQueryContainerInterface getQueryContainer() |
21
|
|
|
*/ |
22
|
|
|
class ItemsCapturePlugin extends AbstractPlugin implements CommandByOrderInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @api |
26
|
|
|
* |
27
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $orderItems |
28
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity |
29
|
|
|
* @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data |
30
|
|
|
* |
31
|
|
|
* @return array |
32
|
|
|
*/ |
33
|
|
|
public function run(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data): array |
34
|
|
|
{ |
35
|
|
|
$transactionMetaTransfer = new TransactionMetaTransfer(); |
36
|
|
|
$transactionMetaTransfer->setIdSalesOrder($orderEntity->getIdSalesOrder()); |
37
|
|
|
$transactionMetaTransfer->setCaptureAmount($this->getCaptureAmount($orderItems)); |
38
|
|
|
|
39
|
|
|
$this->getFacade()->captureItemsPayment($transactionMetaTransfer); |
40
|
|
|
|
41
|
|
|
return []; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $orderItems |
46
|
|
|
* |
47
|
|
|
* @return int |
48
|
|
|
*/ |
49
|
|
|
protected function getCaptureAmount(array $orderItems): int |
50
|
|
|
{ |
51
|
|
|
$amount = 0; |
52
|
|
|
|
53
|
|
|
foreach ($orderItems as $orderItem) { |
54
|
|
|
$amount += $orderItem->getPriceToPayAggregation(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $amount; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
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