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