|
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\Business\Order; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\AmazonpayCallTransfer; |
|
|
|
|
|
|
11
|
|
|
use Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay; |
|
|
|
|
|
|
12
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
|
13
|
|
|
use SprykerEco\Shared\AmazonPay\AmazonPayConfig; |
|
14
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayTransferToEntityConverterInterface; |
|
15
|
|
|
use SprykerEco\Zed\AmazonPay\Persistence\AmazonPayQueryContainerInterface; |
|
16
|
|
|
|
|
17
|
|
|
class PaymentProcessorModel implements PaymentProcessorInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var \SprykerEco\Zed\AmazonPay\Persistence\AmazonPayQueryContainerInterface |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $queryContainer; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var \SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayTransferToEntityConverterInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $converter; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param \SprykerEco\Zed\AmazonPay\Persistence\AmazonPayQueryContainerInterface $queryContainer |
|
31
|
|
|
* @param \SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayTransferToEntityConverterInterface $converter |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct( |
|
34
|
|
|
AmazonPayQueryContainerInterface $queryContainer, |
|
35
|
|
|
AmazonPayTransferToEntityConverterInterface $converter |
|
36
|
|
|
) { |
|
37
|
|
|
$this->queryContainer = $queryContainer; |
|
38
|
|
|
$this->converter = $converter; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param string $orderReferenceId |
|
43
|
|
|
* @param string $status |
|
44
|
|
|
* |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
public function updateStatus($orderReferenceId, $status) |
|
48
|
|
|
{ |
|
49
|
|
|
$payments = $this->getPayments($orderReferenceId); |
|
50
|
|
|
foreach ($payments as $payment) { |
|
51
|
|
|
$payment->setStatus($status); |
|
52
|
|
|
$payment->save(); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param string $orderReferenceId |
|
58
|
|
|
* |
|
59
|
|
|
* @return \Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay[]|\Propel\Runtime\Collection\ObjectCollection |
|
60
|
|
|
*/ |
|
61
|
|
|
protected function getPayments($orderReferenceId) |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->queryContainer->queryPaymentByOrderReferenceId($orderReferenceId) |
|
64
|
|
|
->filterByStatus(AmazonPayConfig::STATUS_CLOSED, Criteria::NOT_EQUAL) |
|
65
|
|
|
->find(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param \Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay $paymentAmazonPayEntity |
|
70
|
|
|
* |
|
71
|
|
|
* @return \Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay |
|
72
|
|
|
*/ |
|
73
|
|
|
public function duplicatePaymentEntity(SpyPaymentAmazonpay $paymentAmazonPayEntity) |
|
74
|
|
|
{ |
|
75
|
|
|
$newPaymentAmazonpay = new SpyPaymentAmazonpay(); |
|
76
|
|
|
|
|
77
|
|
|
$paymentAmazonPayEntity->setAuthorizationReferenceId(null); |
|
78
|
|
|
$newPaymentAmazonpay->fromArray($paymentAmazonPayEntity->toArray()); |
|
79
|
|
|
$paymentAmazonPayEntity->setAmazonAuthorizationId(null); |
|
80
|
|
|
$paymentAmazonPayEntity->save(); |
|
81
|
|
|
|
|
82
|
|
|
$newPaymentAmazonpay->setIdPaymentAmazonpay(null); |
|
83
|
|
|
|
|
84
|
|
|
return $newPaymentAmazonpay; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonPayCallTransfer |
|
89
|
|
|
* |
|
90
|
|
|
* @return \Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay |
|
91
|
|
|
*/ |
|
92
|
|
|
public function createPaymentEntity(AmazonpayCallTransfer $amazonPayCallTransfer) |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->converter->mapTransferToEntity($amazonPayCallTransfer->getAmazonpayPayment()); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonPayCallTransfer |
|
99
|
|
|
* |
|
100
|
|
|
* @return \Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay|null |
|
101
|
|
|
*/ |
|
102
|
|
|
public function loadPaymentEntity(AmazonpayCallTransfer $amazonPayCallTransfer) |
|
103
|
|
|
{ |
|
104
|
|
|
$paymentEntity = null; |
|
105
|
|
|
|
|
106
|
|
|
if ($amazonPayCallTransfer->getItems()->count()) { |
|
107
|
|
|
$paymentEntity = $this->queryContainer->queryPaymentBySalesOrderItemId( |
|
108
|
|
|
$amazonPayCallTransfer->getItems()[0]->getIdSalesOrderItem() |
|
109
|
|
|
) |
|
110
|
|
|
->findOne(); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
if ($paymentEntity === null) { |
|
114
|
|
|
$paymentEntity = $this->queryContainer->queryPaymentByOrderReferenceId( |
|
115
|
|
|
$amazonPayCallTransfer->getAmazonpayPayment()->getOrderReferenceId() |
|
116
|
|
|
) |
|
117
|
|
|
->findOne(); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
return $paymentEntity; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @param \Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay $paymentEntity |
|
125
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonPayCallTransfer |
|
126
|
|
|
* |
|
127
|
|
|
* @return void |
|
128
|
|
|
*/ |
|
129
|
|
|
public function assignAmazonpayPaymentToItems(SpyPaymentAmazonpay $paymentEntity, AmazonpayCallTransfer $amazonPayCallTransfer) |
|
130
|
|
|
{ |
|
131
|
|
|
foreach ($amazonPayCallTransfer->getItems() as $itemTransfer) { |
|
132
|
|
|
$paymentForItemEntity = $this->queryContainer->queryBySalesOrderItemId($itemTransfer->getIdSalesOrderItem()) |
|
133
|
|
|
->findOneOrCreate(); |
|
134
|
|
|
$paymentForItemEntity->setSpyPaymentAmazonpay($paymentEntity); |
|
135
|
|
|
$paymentForItemEntity->save(); |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
} |
|
139
|
|
|
|
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