28
28
use Buckaroo \Magento2 \Model \Config \Source \InvoiceHandlingOptions ;
29
29
use Buckaroo \Magento2 \Model \ConfigProvider \Account ;
30
30
use Buckaroo \Magento2 \Model \ConfigProvider \Method \Factory ;
31
+ use Buckaroo \Magento2 \Model \LockManagerWrapper ;
31
32
use Buckaroo \Magento2 \Model \Method \AbstractMethod ;
32
33
use Buckaroo \Magento2 \Model \Method \Afterpay ;
33
- use Buckaroo \Magento2 \Model \LockManagerWrapper ;
34
34
use Buckaroo \Magento2 \Model \Method \Afterpay2 ;
35
35
use Buckaroo \Magento2 \Model \Method \Afterpay20 ;
36
36
use Buckaroo \Magento2 \Model \Method \Creditcards ;
44
44
use Buckaroo \Magento2 \Model \Refund \Push as RefundPush ;
45
45
use Buckaroo \Magento2 \Model \Validator \Push as ValidatorPush ;
46
46
use Magento \Framework \App \ResourceConnection ;
47
- use Magento \Framework \Exception \LocalizedException ;
48
47
use Magento \Framework \Filesystem \DirectoryList ;
49
48
use Magento \Framework \ObjectManagerInterface ;
50
49
use Magento \Framework \Webapi \Rest \Request ;
54
53
use Magento \Sales \Model \Order \Email \Sender \OrderSender ;
55
54
use Magento \Sales \Model \Order \Payment \Transaction ;
56
55
use Magento \Framework \Filesystem \Driver \File ;
57
- use Magento \Sales \Api \TransactionRepositoryInterface ;
58
- use Magento \Sales \Model \ResourceModel \Order \Payment \Transaction \CollectionFactory ;
56
+
59
57
60
58
class Push implements PushInterface
61
59
{
@@ -162,17 +160,12 @@ class Push implements PushInterface
162
160
163
161
private $ fileSystemDriver ;
164
162
165
- protected $ transactionRepository ;
166
- protected $ transactionCollectionFactory ;
167
-
168
163
/**
169
164
* @var LockManagerWrapper
170
165
*/
171
166
protected LockManagerWrapper $ lockManager ;
172
167
173
168
/**
174
- * @param TransactionRepositoryInterface $transactionRepository
175
- * @param CollectionFactory $transactionCollectionFactory
176
169
* @param Order $order
177
170
* @param TransactionInterface $transaction
178
171
* @param Request $request
@@ -195,18 +188,16 @@ class Push implements PushInterface
195
188
* @param LockManagerWrapper $lockManager
196
189
*/
197
190
public function __construct (
198
- TransactionRepositoryInterface $ transactionRepository ,
199
- CollectionFactory $ transactionCollectionFactory ,
200
- Order $ order ,
201
- TransactionInterface $ transaction ,
202
- Request $ request ,
203
- ValidatorPush $ validator ,
204
- OrderSender $ orderSender ,
205
- InvoiceSender $ invoiceSender ,
206
- Data $ helper ,
207
- Account $ configAccount ,
208
- RefundPush $ refundPush ,
209
- Log $ logging ,
191
+ Order $ order ,
192
+ TransactionInterface $ transaction ,
193
+ Request $ request ,
194
+ ValidatorPush $ validator ,
195
+ OrderSender $ orderSender ,
196
+ InvoiceSender $ invoiceSender ,
197
+ Data $ helper ,
198
+ Account $ configAccount ,
199
+ RefundPush $ refundPush ,
200
+ Log $ logging ,
210
201
Factory $ configProviderMethodFactory ,
211
202
OrderStatusFactory $ orderStatusFactory ,
212
203
PaymentGroupTransaction $ groupTransaction ,
@@ -218,8 +209,6 @@ public function __construct(
218
209
File $ fileSystemDriver ,
219
210
LockManagerWrapper $ lockManager
220
211
) {
221
- $ this ->transactionRepository = $ transactionRepository ;
222
- $ this ->transactionCollectionFactory = $ transactionCollectionFactory ;
223
212
$ this ->order = $ order ;
224
213
$ this ->transaction = $ transaction ;
225
214
$ this ->request = $ request ;
@@ -1064,7 +1053,7 @@ private function sendCm3ConfirmationMail()
1064
1053
/** @var \Magento\Payment\Model\MethodInterface $paymentMethod */
1065
1054
$ paymentMethod = $ this ->order ->getPayment ()->getMethodInstance ();
1066
1055
$ configOrderMail = $ this ->configAccount ->getOrderConfirmationEmail ($ store )
1067
- || $ paymentMethod ->getConfigData ('order_email ' , $ store );
1056
+ || $ paymentMethod ->getConfigData ('order_email ' , $ store );
1068
1057
1069
1058
if (!$ this ->order ->getEmailSent () && $ cm3StatusCode == 10 && $ configOrderMail ) {
1070
1059
$ this ->orderSender ->send ($ this ->order );
@@ -1604,54 +1593,16 @@ public function processSucceededPush($newStatus, $message)
1604
1593
return true ;
1605
1594
}
1606
1595
1607
- /**
1608
- * Updates the 'is_closed' status of all payment transactions for a given order to 0 (open).
1609
- *
1610
- * @param Order $order The order whose transactions need to be updated.
1611
- * @throws LocalizedException If an error occurs during the update.
1612
- */
1613
1596
protected function updateTransactionIsClosed ($ order )
1614
1597
{
1615
- $ this ->logging ->addDebug (sprintf ('Starting updateTransactionIsClosed for order ID %d ' , $ order ->getId ()));
1616
-
1617
- $ transactions = $ this ->transactionCollectionFactory ->create ()
1618
- ->addFieldToFilter ('order_id ' , $ order ->getId ());
1619
-
1620
- if ($ transactions ->getSize () === 0 ) {
1621
- $ this ->logging ->addDebug (sprintf ('No transactions found for order ID %d ' , $ order ->getId ()));
1622
- return ;
1623
- }
1624
-
1625
1598
$ connection = $ this ->resourceConnection ->getConnection ();
1626
- $ connection ->beginTransaction ();
1627
-
1628
- try {
1629
- foreach ($ transactions as $ transaction ) {
1630
- $ transaction ->setIsClosed (0 );
1631
- $ this ->transactionRepository ->save ($ transaction );
1632
- }
1633
-
1634
- $ connection ->commit ();
1599
+ $ transactionTable = $ connection ->getTableName ('sales_payment_transaction ' );
1635
1600
1636
- $ this ->logging ->addDebug (sprintf (
1637
- 'Successfully updated is_closed status for %d transactions of order ID %d ' ,
1638
- $ transactions ->getSize (),
1639
- $ order ->getId ()
1640
- ));
1641
-
1642
- } catch (\Exception $ e ) {
1643
- $ connection ->rollBack ();
1644
-
1645
- $ this ->logging ->addError (sprintf (
1646
- 'Failed to update transactions for order ID %d: %s ' ,
1647
- $ order ->getId (),
1648
- $ e ->getMessage ()
1649
- ));
1650
-
1651
- throw new LocalizedException (
1652
- __ ('Failed to update transaction status: %1 ' , $ e ->getMessage ())
1653
- );
1654
- }
1601
+ $ connection ->update (
1602
+ $ transactionTable ,
1603
+ ['is_closed ' => 0 ],
1604
+ ['order_id = ? ' => $ order ->getId ()]
1605
+ );
1655
1606
}
1656
1607
1657
1608
/**
@@ -1866,7 +1817,7 @@ protected function saveInvoice()
1866
1817
1867
1818
/**
1868
1819
* @return Order\Payment
1869
- * @throws LocalizedException
1820
+ * @throws \Magento\Framework\Exception\ LocalizedException
1870
1821
*/
1871
1822
public function addTransactionData ($ transactionKey = false , $ datas = false )
1872
1823
{
@@ -2176,13 +2127,13 @@ protected function handleGroupTransactionFailed()
2176
2127
protected function isFailedGroupTransaction ()
2177
2128
{
2178
2129
return $ this ->hasPostData (
2179
- 'brq_transaction_type ' ,
2180
- self ::BUCK_PUSH_GROUPTRANSACTION_TYPE
2181
- ) &&
2182
- $ this ->hasPostData (
2183
- 'brq_statuscode ' ,
2184
- $ this ->helper ->getStatusCode ('BUCKAROO_MAGENTO2_STATUSCODE_FAILED ' )
2185
- );
2130
+ 'brq_transaction_type ' ,
2131
+ self ::BUCK_PUSH_GROUPTRANSACTION_TYPE
2132
+ ) &&
2133
+ $ this ->hasPostData (
2134
+ 'brq_statuscode ' ,
2135
+ $ this ->helper ->getStatusCode ('BUCKAROO_MAGENTO2_STATUSCODE_FAILED ' )
2136
+ );
2186
2137
}
2187
2138
2188
2139
@@ -2242,7 +2193,7 @@ protected function getQuoteByReservedOrderId(string $reservedOrderId)
2242
2193
*
2243
2194
* @return \Magento\Framework\Model\AbstractExtensibleModel|\Magento\Sales\Api\Data\OrderInterface|object|null
2244
2195
* @throws \Exception
2245
- * @throws LocalizedException
2196
+ * @throws \Magento\Framework\Exception\ LocalizedException
2246
2197
*/
2247
2198
protected function createOrder (\Magento \Quote \Model \Quote $ quote )
2248
2199
{
@@ -2280,9 +2231,9 @@ protected function cancelOrder(string $reservedOrderId, $historyComment = 'Giftc
2280
2231
$ order ->addCommentToStatusHistory (
2281
2232
__ ($ historyComment )
2282
2233
)
2283
- ->setIsCustomerNotified (false )
2284
- ->setEntityName ('invoice ' )
2285
- ->save ();
2234
+ ->setIsCustomerNotified (false )
2235
+ ->setEntityName ('invoice ' )
2236
+ ->save ();
2286
2237
}
2287
2238
}
2288
2239
@@ -2292,7 +2243,7 @@ protected function cancelOrder(string $reservedOrderId, $historyComment = 'Giftc
2292
2243
* @param string $reservedOrderId
2293
2244
* @return \Magento\Framework\Model\AbstractExtensibleModel|\Magento\Sales\Api\Data\OrderInterface|object|null
2294
2245
* @throws \Exception
2295
- * @throws LocalizedException
2246
+ * @throws \Magento\Framework\Exception\ LocalizedException
2296
2247
*/
2297
2248
protected function createOrderFromQuote (string $ reservedOrderId )
2298
2249
{
@@ -2347,12 +2298,12 @@ public function cancelGroupTransactionOrder()
2347
2298
public function isCanceledGroupTransaction ()
2348
2299
{
2349
2300
return $ this ->hasPostData (
2350
- 'brq_transaction_type ' ,
2351
- self ::BUCK_PUSH_GROUPTRANSACTION_TYPE
2352
- ) &&
2353
- $ this ->hasPostData (
2354
- 'brq_statuscode ' ,
2355
- $ this ->helper ->getStatusCode ('BUCKAROO_MAGENTO2_STATUSCODE_CANCELLED_BY_USER ' )
2356
- );
2301
+ 'brq_transaction_type ' ,
2302
+ self ::BUCK_PUSH_GROUPTRANSACTION_TYPE
2303
+ ) &&
2304
+ $ this ->hasPostData (
2305
+ 'brq_statuscode ' ,
2306
+ $ this ->helper ->getStatusCode ('BUCKAROO_MAGENTO2_STATUSCODE_CANCELLED_BY_USER ' )
2307
+ );
2357
2308
}
2358
2309
}
0 commit comments