|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Apache OSL-2 |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\AmazonPay\Communication\Plugin\Oms\Command; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\AmazonpayCallTransfer; |
|
11
|
|
|
use Orm\Zed\Sales\Persistence\SpySalesOrder; |
|
|
|
|
|
|
12
|
|
|
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject; |
|
13
|
|
|
use SprykerEco\Shared\AmazonPay\AmazonPayConfig; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @method \SprykerEco\Zed\AmazonPay\Persistence\AmazonPayQueryContainerInterface getQueryContainer() |
|
17
|
|
|
* @method \SprykerEco\Zed\AmazonPay\Business\AmazonPayFacade getFacade |
|
18
|
|
|
*/ |
|
19
|
|
|
class UpdateAuthorizationStatusCommandPlugin extends AbstractAmazonpayCommandPlugin |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @param array $salesOrderItems |
|
23
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity |
|
24
|
|
|
* @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data |
|
25
|
|
|
* |
|
26
|
|
|
* @return array |
|
27
|
|
|
*/ |
|
28
|
|
|
public function run(array $salesOrderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data) |
|
29
|
|
|
{ |
|
30
|
|
|
$amazonpayCallTransfers = $this->groupSalesOrderItemsByAuthId($salesOrderItems); |
|
31
|
|
|
|
|
32
|
|
|
foreach ($amazonpayCallTransfers as $amazonpayCallTransfer) { |
|
33
|
|
|
$this->addAddresses($amazonpayCallTransfer, $orderEntity); |
|
34
|
|
|
$updatedStatus = $this->getFacade()->updateAuthorizationStatus($amazonpayCallTransfer); |
|
35
|
|
|
|
|
36
|
|
|
if ($this->isOrderClosed($updatedStatus)) { |
|
37
|
|
|
$this->getFacade()->authorizeOrderItems($amazonpayCallTransfer); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$this->getFacade()->triggerEventForRelatedItems( |
|
41
|
|
|
$amazonpayCallTransfer, |
|
42
|
|
|
$data->getArrayCopy(), |
|
43
|
|
|
AmazonPayConfig::OMS_EVENT_UPDATE_AUTH_STATUS |
|
44
|
|
|
); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return []; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $updatedStatus |
|
52
|
|
|
* |
|
53
|
|
|
* @return bool |
|
54
|
|
|
*/ |
|
55
|
|
|
protected function isOrderClosed(AmazonpayCallTransfer $updatedStatus) |
|
56
|
|
|
{ |
|
57
|
|
|
return $updatedStatus->getAmazonpayPayment() |
|
58
|
|
|
->getAuthorizationDetails() |
|
59
|
|
|
->getAuthorizationStatus() |
|
60
|
|
|
->getState() === AmazonPayConfig::STATUS_CLOSED; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer |
|
65
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity |
|
66
|
|
|
* |
|
67
|
|
|
* @return void |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function addAddresses(AmazonpayCallTransfer $amazonpayCallTransfer, SpySalesOrder $orderEntity) |
|
70
|
|
|
{ |
|
71
|
|
|
$amazonpayCallTransfer->setShippingAddress($this->buildAddressTransfer($orderEntity->getShippingAddress())) |
|
72
|
|
|
->setBillingAddress($this->buildAddressTransfer($orderEntity->getBillingAddress())); |
|
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