Skip to content

Commit 2b15be4

Browse files
author
Mark Berube
committed
Merge branch 'MC-4239' of https://github.com/magento-borg/magento2ce into MC-4239
2 parents b648b96 + 56adcba commit 2b15be4

27 files changed

+279
-196
lines changed

app/code/Magento/Authorizenet/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<system>
1010
<section id="payment">
1111
<group id="authorizenet_directpost" translate="label" type="text" sortOrder="34" showInDefault="1" showInWebsite="1" showInStore="1">
12-
<label>Authorize.net Direct Post (Deprecated)</label>
12+
<label>Authorize.Net Direct Post (Deprecated)</label>
1313
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
1414
<label>Enabled</label>
1515
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>

app/code/Magento/Authorizenet/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<order_status>processing</order_status>
2020
<payment_action>authorize</payment_action>
2121
<test>1</test>
22-
<title>Credit Card Direct Post (Authorize.net)</title>
22+
<title>Credit Card Direct Post (Authorize.Net)</title>
2323
<trans_key backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
2424
<trans_md5 backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
2525
<allowspecific>0</allowspecific>

app/code/Magento/Authorizenet/etc/payment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Payment:etc/payment.xsd">
1010
<groups>
1111
<group id="authorizenet">
12-
<label>Authorize.net</label>
12+
<label>Authorize.Net</label>
1313
</group>
1414
</groups>
1515
</payment>

app/code/Magento/Authorizenet/i18n/en_US.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void,void
4545
"Fraud Filters","Fraud Filters"
4646
"Place Order","Place Order"
4747
"Sorry, but something went wrong. Please contact the seller.","Sorry, but something went wrong. Please contact the seller."
48-
"Authorize.net Direct Post (Deprecated)","Authorize.net Direct Post (Deprecated)"
48+
"Authorize.Net Direct Post (Deprecated)","Authorize.Net Direct Post (Deprecated)"
4949
Enabled,Enabled
5050
"Payment Action","Payment Action"
5151
Title,Title

app/code/Magento/AuthorizenetAcceptjs/Gateway/Command/FetchTransactionInfoCommand.php

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,13 @@
1313
use Magento\Payment\Gateway\Command\CommandPool;
1414
use Magento\Payment\Gateway\Command\CommandPoolInterface;
1515
use Magento\Payment\Gateway\CommandInterface;
16-
use Magento\Sales\Model\Order\Payment;
16+
use Magento\Payment\Gateway\Response\HandlerInterface;
1717

1818
/**
1919
* Syncs the transaction status with authorize.net
2020
*/
2121
class FetchTransactionInfoCommand implements CommandInterface
2222
{
23-
private const REVIEW_PENDING_STATUSES = [
24-
'FDSPendingReview',
25-
'FDSAuthorizedPendingReview'
26-
];
27-
private const REVIEW_DECLINED_STATUSES = [
28-
'void',
29-
'declined'
30-
];
31-
3223
/**
3324
* @var CommandPool
3425
*/
@@ -44,19 +35,27 @@ class FetchTransactionInfoCommand implements CommandInterface
4435
*/
4536
private $config;
4637

38+
/**
39+
* @var HandlerInterface|null
40+
*/
41+
private $handler;
42+
4743
/**
4844
* @param CommandPoolInterface $commandPool
4945
* @param SubjectReader $subjectReader
5046
* @param Config $config
47+
* @param HandlerInterface|null $handler
5148
*/
5249
public function __construct(
5350
CommandPoolInterface $commandPool,
5451
SubjectReader $subjectReader,
55-
Config $config
52+
Config $config,
53+
HandlerInterface $handler = null
5654
) {
5755
$this->commandPool = $commandPool;
5856
$this->subjectReader = $subjectReader;
5957
$this->config = $config;
58+
$this->handler = $handler;
6059
}
6160

6261
/**
@@ -66,22 +65,13 @@ public function execute(array $commandSubject): array
6665
{
6766
$paymentDO = $this->subjectReader->readPayment($commandSubject);
6867
$order = $paymentDO->getOrder();
69-
$payment = $paymentDO->getPayment();
70-
71-
if (!$payment instanceof Payment) {
72-
return [];
73-
}
7468

7569
$command = $this->commandPool->get('get_transaction_details');
7670
$result = $command->execute($commandSubject);
7771
$response = $result->get();
78-
$status = $response['transaction']['transactionStatus'];
7972

80-
// This data is only used when updating the payment on the order
81-
if (!in_array($status, self::REVIEW_PENDING_STATUSES)) {
82-
$denied = in_array($status, self::REVIEW_DECLINED_STATUSES);
83-
$payment->setData('is_transaction_denied', $denied);
84-
$payment->setData('is_transaction_approved', !$denied);
73+
if ($this->handler) {
74+
$this->handler->handle($commandSubject, $response);
8575
}
8676

8777
$additionalInformationKeys = $this->config->getTransactionInfoSyncKeys($order->getStoreId());
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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\SubjectReader;
12+
use Magento\Payment\Gateway\Response\HandlerInterface;
13+
use Magento\Sales\Model\Order\Payment;
14+
15+
/**
16+
* Processes payment information from a void transaction response
17+
*/
18+
class PaymentReviewStatusHandler implements HandlerInterface
19+
{
20+
private const REVIEW_PENDING_STATUSES = [
21+
'FDSPendingReview',
22+
'FDSAuthorizedPendingReview'
23+
];
24+
private const REVIEW_DECLINED_STATUSES = [
25+
'void',
26+
'declined'
27+
];
28+
29+
/**
30+
* @var SubjectReader
31+
*/
32+
private $subjectReader;
33+
34+
/**
35+
* @param SubjectReader $subjectReader
36+
*/
37+
public function __construct(SubjectReader $subjectReader)
38+
{
39+
$this->subjectReader = $subjectReader;
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function handle(array $handlingSubject, array $response): void
46+
{
47+
$paymentDO = $this->subjectReader->readPayment($handlingSubject);
48+
$payment = $paymentDO->getPayment();
49+
50+
if ($payment instanceof Payment) {
51+
$paymentDO = $this->subjectReader->readPayment($handlingSubject);
52+
$payment = $paymentDO->getPayment();
53+
54+
$status = $response['transaction']['transactionStatus'];
55+
// This data is only used when updating the order payment via Get Payment Update
56+
if (!in_array($status, self::REVIEW_PENDING_STATUSES)) {
57+
$denied = in_array($status, self::REVIEW_DECLINED_STATUSES);
58+
$payment->setData('is_transaction_denied', $denied);
59+
$payment->setData('is_transaction_approved', !$denied);
60+
}
61+
}
62+
}
63+
}

app/code/Magento/AuthorizenetAcceptjs/Gateway/Validator/TransactionResponseValidator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ public function validate(array $validationSubject): ResultInterface
5959
$errorCodes[] = $message['code'];
6060
$errorMessages[] = $message['description'];
6161
}
62+
} elseif (isset($transactionResponse['errors'])) {
63+
foreach ($transactionResponse['errors'] as $message) {
64+
$errorCodes[] = $message['errorCode'];
65+
$errorMessages[] = $message['errorCode'];
66+
}
6267
}
6368

6469
return $this->createResult(false, $errorMessages, $errorCodes);
@@ -77,6 +82,7 @@ private function isResponseCodeAnError(array $transactionResponse): bool
7782
{
7883
$code = $transactionResponse['messages']['message']['code']
7984
?? $transactionResponse['messages']['message'][0]['code']
85+
?? $transactionResponse['errors'][0]['errorCode']
8086
?? null;
8187

8288
return in_array($transactionResponse['responseCode'], [self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_HELD])

app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ConfigureAuthorizenetAcceptjsActionGroup.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-->
88
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10-
1110
<actionGroup name="ConfigureAuthorizenetAcceptjs">
1211
<arguments>
1312
<argument name="paymentAction" type="string"/>
@@ -19,15 +18,14 @@
1918
<click stepKey="clickOnConfiguration" selector="{{StoresSubmenuSection.configuration}}"/>
2019
<waitForPageLoad stepKey="waitForSales"/>
2120
<waitForElementVisible stepKey="waitForVisibleHack" selector="{{AdminMenuSection.currencySetup}}"/>
22-
<scrollTo stepKey="scrollToSales" selector="{{ConfigurationListSection.sales}}"/>
23-
<click stepKey="clickOnSales" selector="{{ConfigurationListSection.sales}}" />
21+
<scrollTo stepKey="scrollToSales" selector="{{StoresConfigurationListSection.sales}}"/>
22+
<click stepKey="clickOnSales" selector="{{StoresConfigurationListSection.sales}}" />
2423
<waitForPageLoad stepKey="waitForPaymentMethods"/>
25-
<click stepKey="clickOnPaymentMethods" selector="{{ConfigurationListSection.salesPaymentMethods}}" />
24+
<click stepKey="clickOnPaymentMethods" selector="{{StoresConfigurationListSection.salesPaymentMethods}}" />
2625
<waitForPageLoad stepKey="waitForOpenConfiguration"/>
2726
<scrollTo stepKey="scrollToOpenConfig" selector="{{AuthorizenetAcceptjsConfigurationSection.openSectionToggle}}"/>
2827
<conditionalClick stepKey="openConfiguration" selector="{{AuthorizenetAcceptjsConfigurationSection.openSectionToggle}}" dependentSelector="{{AuthorizenetAcceptjsConfigurationSection.alreadyOpenSectionToggle}}" visible="false"/>
2928

30-
3129
<!-- Fill Auth.net fields and save -->
3230
<waitForPageLoad stepKey="waitToFillApiLogin"/>
3331
<conditionalClick selector="{{AuthorizenetAcceptjsConfigurationSection.paymentActionCheckbox}}" stepKey="uncheckPaymentActionDefault" dependentSelector="{{AuthorizenetAcceptjsConfigurationSection.paymentActionSelectDisabled}}" visible="true"/>
@@ -43,6 +41,6 @@
4341
</actionGroup>
4442

4543
<actionGroup name="DisableAuthorizenetAcceptjs">
46-
<magentoCLI stepKey="disableBrainTree" command="config:set payment/authorizenet_acceptjs/active 0"/>
44+
<magentoCLI stepKey="disableAuthorizenetAcceptjs" command="config:set payment/authorizenet_acceptjs/active 0"/>
4745
</actionGroup>
4846
</actionGroups>

app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/FillPaymentInformationActionGroup.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-->
88
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10-
1110
<actionGroup name="FillPaymentInformation">
1211
<click stepKey="clickOnAuthorizenetToggle" selector="{{AuthorizenetCheckoutSection.selectAuthorizenet}}"/>
1312
<waitForPageLoad stepKey="waitForCardDataSection"/>

app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ViewAndValidateOrderActionGroup.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
-->
88
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10-
1110
<actionGroup name="ViewAndValidateOrderActionGroup">
1211
<arguments>
1312
<argument name="amount" type="string"/>
1413
<argument name="status" type="string"/>
1514
<argument name="captureStatus" type="string"/>
1615
<argument name="closedStatus" type="string"/>
1716
</arguments>
18-
<amOnPage url="/admin" stepKey="navigateToAdmin"/>
17+
<amOnPage url="{{AdminLoginPage.url}}" stepKey="navigateToAdmin"/>
1918
<click selector="{{AdminMenuSection.sales}}" stepKey="clickSales"/>
2019
<waitForPageLoad stepKey="waitForSalesSubsection"/>
2120
<click selector="{{AdminMenuSection.orders}}" stepKey="clickOrders"/>
@@ -47,7 +46,7 @@
4746
<argument name="captureStatus" type="string"/>
4847
<argument name="closedStatus" type="string"/>
4948
</arguments>
50-
<amOnPage url="/admin" stepKey="navigateToAdmin"/>
49+
<amOnPage url="{{AdminLoginPage.url}}" stepKey="navigateToAdmin"/>
5150
<click selector="{{AdminMenuSection.sales}}" stepKey="clickSales"/>
5251
<waitForPageLoad stepKey="waitForSalesSubsection"/>
5352
<click selector="{{AdminMenuSection.orders}}" stepKey="clickOrders"/>

0 commit comments

Comments
 (0)