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\Business\AmazonPayFacadeInterface getFacade() |
17
|
|
|
*/ |
18
|
|
|
class AuthorizeOrderCommandPlugin extends AbstractAmazonpayCommandPlugin |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
* - Uses API adapter for sending a request to Amazon for order authorization operation. |
23
|
|
|
* |
24
|
|
|
* @api |
25
|
|
|
* |
26
|
|
|
* @param array $salesOrderItems |
27
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity |
28
|
|
|
* @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data |
29
|
|
|
* |
30
|
|
|
* @return array |
31
|
|
|
*/ |
32
|
|
|
public function run(array $salesOrderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data): array |
33
|
|
|
{ |
34
|
|
|
$amazonpayCallTransfers = $this->groupSalesOrderItemsByAuthId($salesOrderItems); |
35
|
|
|
$customerEmail = $orderEntity->getEmail() ?? $orderEntity->getCustomer()->getEmail(); |
36
|
|
|
|
37
|
|
|
foreach ($amazonpayCallTransfers as $amazonpayCallTransfer) { |
38
|
|
|
$this->updateCallTransfer($amazonpayCallTransfer, $orderEntity, $customerEmail); |
39
|
|
|
$this->getFacade()->authorizeOrderItems($amazonpayCallTransfer); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
return []; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer |
47
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity |
48
|
|
|
* @param string $customerEmail |
49
|
|
|
* |
50
|
|
|
* @return \Generated\Shared\Transfer\AmazonpayCallTransfer |
51
|
|
|
*/ |
52
|
|
|
protected function updateCallTransfer( |
53
|
|
|
AmazonpayCallTransfer $amazonpayCallTransfer, |
54
|
|
|
SpySalesOrder $orderEntity, |
55
|
|
|
string $customerEmail |
56
|
|
|
): AmazonpayCallTransfer { |
57
|
|
|
$amazonpayCallTransfer->setShippingAddress($this->buildAddressTransfer($orderEntity->getShippingAddress())) |
58
|
|
|
->setBillingAddress($this->buildAddressTransfer($orderEntity->getBillingAddress())); |
59
|
|
|
$amazonpayCallTransfer->setEmail($customerEmail); |
60
|
|
|
$amazonpayCallTransfer->setRequestedAmount( |
61
|
|
|
$this->getRequestedAmountByOrderAndItems($orderEntity, $amazonpayCallTransfer->getItems()) |
62
|
|
|
); |
63
|
|
|
|
64
|
|
|
return $amazonpayCallTransfer; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
protected function getAffectingRequestedAmountItemsStateFlag(): string |
71
|
|
|
{ |
72
|
|
|
return AmazonPayConfig::OMS_FLAG_NOT_AUTH; |
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