Skip to content

Commit e6348e7

Browse files
committed
Merge remote-tracking branch 'origin/MC-16590' into 2.2-develop-pr105
2 parents 9152449 + 86604b5 commit e6348e7

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

app/code/Magento/AuthorizenetAcceptjs/Gateway/Response/CloseTransactionHandler.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ class CloseTransactionHandler implements HandlerInterface
2222
*/
2323
private $subjectReader;
2424

25+
/**
26+
* @var bool
27+
*/
28+
private $closeTransaction;
29+
2530
/**
2631
* @param SubjectReader $subjectReader
32+
* @param bool $closeTransaction
2733
*/
28-
public function __construct(SubjectReader $subjectReader)
34+
public function __construct(SubjectReader $subjectReader, bool $closeTransaction = true)
2935
{
3036
$this->subjectReader = $subjectReader;
37+
$this->closeTransaction = $closeTransaction;
3138
}
3239

3340
/**
@@ -39,7 +46,7 @@ public function handle(array $handlingSubject, array $response)
3946
$payment = $paymentDO->getPayment();
4047

4148
if ($payment instanceof Payment) {
42-
$payment->setIsTransactionClosed(true);
49+
$payment->setIsTransactionClosed($this->closeTransaction);
4350
$payment->setShouldCloseParentTransaction(true);
4451
}
4552
}

app/code/Magento/AuthorizenetAcceptjs/etc/di.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,15 @@
188188
</argument>
189189
</arguments>
190190
</virtualType>
191+
<virtualType name="CloseCaptureTransactionHandler" type="Magento\AuthorizenetAcceptjs\Gateway\Response\CloseTransactionHandler">
192+
<arguments>
193+
<argument name="closeTransaction" xsi:type="boolean">false</argument>
194+
</arguments>
195+
</virtualType>
191196
<virtualType name="AuthorizenetAcceptjsCaptureTransactionHandler" type="Magento\Payment\Gateway\Response\HandlerChain">
192197
<arguments>
193198
<argument name="handlers" xsi:type="array">
194-
<item name="close_parent_transaction" xsi:type="string">Magento\AuthorizenetAcceptjs\Gateway\Response\CloseParentTransactionHandler</item>
199+
<item name="close_transaction" xsi:type="string">CloseCaptureTransactionHandler</item>
195200
</argument>
196201
</arguments>
197202
</virtualType>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AuthorizenetAcceptjs\Gateway\Response;
10+
11+
use Magento\AuthorizenetAcceptjs\Gateway\AbstractTest;
12+
13+
/**
14+
* Test for Magento\AuthorizenetAcceptjs\Gateway\Response\CloseTransactionHandler class.
15+
*/
16+
class CloseTransactionHandlerTest extends AbstractTest
17+
{
18+
/**
19+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/environment sandbox
20+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/login someusername
21+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_key somepassword
22+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_signature_key abc
23+
* @magentoDataFixture Magento/AuthorizenetAcceptjs/Fixture/order_auth_only.php
24+
*
25+
* @return void
26+
*/
27+
public function testTransactionCloseStatus()
28+
{
29+
$commandPool = $this->objectManager->get('AuthorizenetAcceptjsCommandPool');
30+
$command = $commandPool->get('settle');
31+
$order = $this->getOrderWithIncrementId('100000002');
32+
$payment = $order->getPayment();
33+
$paymentDO = $this->paymentFactory->create($payment);
34+
35+
$expectedRequest = include __DIR__ . '/../../_files/expected_request/settle.php';
36+
$response = include __DIR__ . '/../../_files/response/settle.php';
37+
38+
$this->clientMock->method('setRawData')
39+
->with(json_encode($expectedRequest), 'application/json');
40+
$this->responseMock->method('getBody')
41+
->willReturn(json_encode($response));
42+
43+
$command->execute(['payment' => $paymentDO]);
44+
45+
$this->assertFalse($payment->getIsTransactionClosed());
46+
}
47+
}

0 commit comments

Comments
 (0)