Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit aa9f2af

Browse files
author
Vasiliev.A
committed
merge upstream/2.3-develop into work branch
2 parents 2f8cb97 + 168ecf4 commit aa9f2af

File tree

1,179 files changed

+26302
-37298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,179 files changed

+26302
-37298
lines changed

.github/CONTRIBUTING.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
# Contributing to Magento 2 code
22

33
Contributions to the Magento 2 codebase are done using the fork & pull model.
4-
This contribution model has contributors maintaining their own copy of the forked codebase (which can easily be synced with the main copy). The forked repository is then used to submit a request to the base repository to “pull” a set of changes (hence the phrase “pull request”).
4+
This contribution model has contributors maintaining their own copy of the forked codebase (which can easily be synced with the main copy). The forked repository is then used to submit a request to the base repository to “pull” a set of changes. For more information on pull requests please refer to [GitHub Help](https://help.github.com/articles/about-pull-requests/).
55

6-
Contributions can take the form of new components/features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations or just good suggestions.
6+
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes or optimizations.
77

8-
The Magento 2 development team will review all issues and contributions submitted by the community of developers in the first in, first out order. During the review we might require clarifications from the contributor. If there is no response from the contributor for two weeks, the issue is closed.
8+
The Magento 2 development team will review all issues and contributions submitted by the community of developers in the first in, first out order. During the review we might require clarifications from the contributor. If there is no response from the contributor within two weeks, the pull request will be closed.
99

1010

1111
## Contribution requirements
1212

13-
1. Contributions must adhere to [Magento coding standards](http://devdocs.magento.com/guides/v2.0/coding-standards/bk-coding-standards.html).
14-
2. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances of a pull request to be merged quickly and without additional clarification requests.
15-
3. Commits must be accompanied by meaningful commit messages.
16-
4. PRs which include bug fixing, must be accompanied with step-by-step description of how to reproduce the bug.
13+
1. Contributions must adhere to the [Magento coding standards](https://devdocs.magento.com/guides/v2.2/coding-standards/bk-coding-standards.html).
14+
2. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances of a pull request being merged quickly and without additional clarification requests.
15+
3. Commits must be accompanied by meaningful commit messages. Please see the [Magento Pull Request Template](https://github.com/magento/magento2/blob/2.2-develop/.github/PULL_REQUEST_TEMPLATE.md) for more information.
16+
4. PRs which include bug fixes must be accompanied with a step-by-step description of how to reproduce the bug.
1717
3. PRs which include new logic or new features must be submitted along with:
18-
* Unit/integration test coverage (we will be releasing more information on writing test coverage in the near future).
19-
* Proposed [documentation](http://devdocs.magento.com) update. Documentation contributions can be submitted [here](https://github.com/magento/devdocs).
20-
4. For large features or changes, please [open an issue](https://github.com/magento/magento2/issues) and discuss first. This may prevent duplicate or unnecessary effort, and it may gain you some additional contributors.
21-
5. All automated tests are passed successfully (all builds on [Travis CI](https://travis-ci.org/magento/magento2) must be green).
18+
* Unit/integration test coverage
19+
* Proposed [documentation](http://devdocs.magento.com) updates. Documentation contributions can be submitted via the [devdocs GitHub](https://github.com/magento/devdocs).
20+
4. For larger features or changes, please [open an issue](https://github.com/magento/magento2/issues) to discuss the proposed changes prior to development. This may prevent duplicate or unnecessary effort and allow other contributors to provide input.
21+
5. All automated tests must pass (all builds on [Travis CI](https://travis-ci.org/magento/magento2) must be green).
2222

2323
## Contribution process
2424

25-
If you are a new GitHub user, we recommend that you create your own [free github account](https://github.com/signup/free). By doing that, you will be able to collaborate with the Magento 2 development team, fork the Magento 2 project and be able to easily send pull requests.
25+
If you are a new GitHub user, we recommend that you create your own [free github account](https://github.com/signup/free). This will allow you to collaborate with the Magento 2 development team, fork the Magento 2 project and send pull requests.
2626

2727
1. Search current [listed issues](https://github.com/magento/magento2/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
2828
2. Review the [Contributor License Agreement](https://magento.com/legaldocuments/mca) if this is your first time contributing.
2929
3. Create and test your work.
30-
4. Fork the Magento 2 repository according to [Fork a repository instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow [Create a pull request instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#pull_request).
31-
5. Once your contribution is received, Magento 2 development team will review the contribution and collaborate with you as needed to improve the quality of the contribution.
30+
4. Fork the Magento 2 repository according to the [Fork A Repository instructions](http://devdocs.magento.com/guides/v2.2/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow the [Create A Pull Request instructions](http://devdocs.magento.com/guides/v2.2/contributor-guide/contributing.html#pull_request).
31+
5. Once your contribution is received the Magento 2 development team will review the contribution and collaborate with you as needed.
3232

3333
## Code of Conduct
3434

.github/ISSUE_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
### Expected result
3030
<!--- Tell us what should happen -->
31-
1. [Screenshot, logs]
31+
1. [Screenshots, logs or description]
3232

3333
### Actual result
3434
<!--- Tell us what happens instead -->
35-
1. [Screenshot, logs]
35+
1. [Screenshots, logs or description]

app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ public function execute()
6262
if (empty($result)) {
6363
$result[] = [
6464
'severity' => (string)\Magento\Framework\Notification\MessageInterface::SEVERITY_NOTICE,
65-
'text' => 'You have viewed and resolved all recent system notices. '
66-
. 'Please refresh the web page to clear the notice alert.',
65+
'text' => __(
66+
'You have viewed and resolved all recent system notices. '
67+
. 'Please refresh the web page to clear the notice alert.'
68+
)
6769
];
6870
}
6971
/** @var \Magento\Framework\Controller\Result\Json $resultJson */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ Severity,Severity
4848
"Date Added","Date Added"
4949
Message,Message
5050
Actions,Actions
51+
"You have viewed and resolved all recent system notices. Please refresh the web page to clear the notice alert.","You have viewed and resolved all recent system notices. Please refresh the web page to clear the notice alert."

app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,12 @@
1919
</ul>
2020
</div>
2121

22-
<script>
23-
require([
24-
"jquery",
25-
"Magento_Ui/js/modal/modal"
26-
], function($){
27-
if (this.modal) {
28-
this.modal.html($('[data-role="system_messages_list"]').html());
29-
} else {
30-
this.modal = $('[data-role="system_messages_list"]').modal({
31-
modalClass: 'modal-system-messages ui-popup-message',
32-
type: 'popup',
33-
buttons: []
34-
});
22+
<script type="text/x-magento-init">
23+
{
24+
"[data-role=system_messages_list]": {
25+
"Magento_AdminNotification/js/system/messages/popup": {
26+
class: 'modal-system-messages ui-popup-message'
27+
}
28+
}
3529
}
36-
this.modal.modal('openModal');
37-
});
38-
</script>
30+
</script>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'Magento_Ui/js/modal/modal'
9+
], function ($) {
10+
'use strict';
11+
12+
return function (data, element) {
13+
if (this.modal) {
14+
this.modal.html($(element).html());
15+
} else {
16+
this.modal = $(element).modal({
17+
modalClass: data.class,
18+
type: 'popup',
19+
buttons: []
20+
});
21+
}
22+
this.modal.modal('openModal');
23+
};
24+
});

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
*/
66
namespace Magento\Authorizenet\Model;
77

8-
use Magento\Framework\HTTP\ZendClientFactory;
8+
use Magento\Framework\App\ObjectManager;
99
use Magento\Payment\Model\Method\ConfigInterface;
1010
use Magento\Payment\Model\Method\TransparentInterface;
11-
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
1211

1312
/**
1413
* Authorize.net DirectPost payment method model.
@@ -102,7 +101,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
102101
protected $response;
103102

104103
/**
105-
* @var OrderSender
104+
* @var \Magento\Sales\Model\Order\Email\Sender\OrderSender
106105
*/
107106
protected $orderSender;
108107

@@ -123,6 +122,16 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
123122
*/
124123
private $psrLogger;
125124

125+
/**
126+
* @var \Magento\Sales\Api\PaymentFailuresInterface
127+
*/
128+
private $paymentFailures;
129+
130+
/**
131+
* @var \Magento\Sales\Model\Order
132+
*/
133+
private $order;
134+
126135
/**
127136
* @param \Magento\Framework\Model\Context $context
128137
* @param \Magento\Framework\Registry $registry
@@ -134,18 +143,19 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
134143
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
135144
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
136145
* @param \Magento\Authorizenet\Helper\Data $dataHelper
137-
* @param Directpost\Request\Factory $requestFactory
138-
* @param Directpost\Response\Factory $responseFactory
146+
* @param \Magento\Authorizenet\Model\Directpost\Request\Factory $requestFactory
147+
* @param \Magento\Authorizenet\Model\Directpost\Response\Factory $responseFactory
139148
* @param \Magento\Authorizenet\Model\TransactionService $transactionService
140149
* @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
141150
* @param \Magento\Sales\Model\OrderFactory $orderFactory
142151
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
143152
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
144-
* @param OrderSender $orderSender
153+
* @param \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender
145154
* @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository
146155
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
147156
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
148157
* @param array $data
158+
* @param \Magento\Sales\Api\PaymentFailuresInterface|null $paymentFailures
149159
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
150160
*/
151161
public function __construct(
@@ -161,16 +171,17 @@ public function __construct(
161171
\Magento\Authorizenet\Helper\Data $dataHelper,
162172
\Magento\Authorizenet\Model\Directpost\Request\Factory $requestFactory,
163173
\Magento\Authorizenet\Model\Directpost\Response\Factory $responseFactory,
164-
TransactionService $transactionService,
165-
ZendClientFactory $httpClientFactory,
174+
\Magento\Authorizenet\Model\TransactionService $transactionService,
175+
\Magento\Framework\HTTP\ZendClientFactory $httpClientFactory,
166176
\Magento\Sales\Model\OrderFactory $orderFactory,
167177
\Magento\Store\Model\StoreManagerInterface $storeManager,
168178
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
169179
\Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender,
170180
\Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository,
171181
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
172182
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
173-
array $data = []
183+
array $data = [],
184+
\Magento\Sales\Api\PaymentFailuresInterface $paymentFailures = null
174185
) {
175186
$this->orderFactory = $orderFactory;
176187
$this->storeManager = $storeManager;
@@ -179,6 +190,8 @@ public function __construct(
179190
$this->orderSender = $orderSender;
180191
$this->transactionRepository = $transactionRepository;
181192
$this->_code = static::METHOD_CODE;
193+
$this->paymentFailures = $paymentFailures ? : ObjectManager::getInstance()
194+
->get(\Magento\Sales\Api\PaymentFailuresInterface::class);
182195

183196
parent::__construct(
184197
$context,
@@ -561,13 +574,10 @@ public function process(array $responseData)
561574
$this->validateResponse();
562575

563576
$response = $this->getResponse();
564-
//operate with order
565-
$orderIncrementId = $response->getXInvoiceNum();
566577
$responseText = $this->dataHelper->wrapGatewayError($response->getXResponseReasonText());
567578
$isError = false;
568-
if ($orderIncrementId) {
569-
/* @var $order \Magento\Sales\Model\Order */
570-
$order = $this->orderFactory->create()->loadByIncrementId($orderIncrementId);
579+
if ($this->getOrderIncrementId()) {
580+
$order = $this->getOrderFromResponse();
571581
//check payment method
572582
$payment = $order->getPayment();
573583
if (!$payment || $payment->getMethod() != $this->getCode()) {
@@ -632,9 +642,10 @@ public function checkResponseCode()
632642
return true;
633643
case self::RESPONSE_CODE_DECLINED:
634644
case self::RESPONSE_CODE_ERROR:
635-
throw new \Magento\Framework\Exception\LocalizedException(
636-
$this->dataHelper->wrapGatewayError($this->getResponse()->getXResponseReasonText())
637-
);
645+
$errorMessage = $this->dataHelper->wrapGatewayError($this->getResponse()->getXResponseReasonText());
646+
$order = $this->getOrderFromResponse();
647+
$this->paymentFailures->handle((int)$order->getQuoteId(), $errorMessage);
648+
throw new \Magento\Framework\Exception\LocalizedException($errorMessage);
638649
default:
639650
throw new \Magento\Framework\Exception\LocalizedException(
640651
__('There was a payment authorization error.')
@@ -988,12 +999,40 @@ protected function getTransactionResponse($transactionId)
988999
private function getPsrLogger()
9891000
{
9901001
if (null === $this->psrLogger) {
991-
$this->psrLogger = \Magento\Framework\App\ObjectManager::getInstance()
1002+
$this->psrLogger = ObjectManager::getInstance()
9921003
->get(\Psr\Log\LoggerInterface::class);
9931004
}
9941005
return $this->psrLogger;
9951006
}
9961007

1008+
/**
1009+
* Fetch order by increment id from response.
1010+
*
1011+
* @return \Magento\Sales\Model\Order
1012+
*/
1013+
private function getOrderFromResponse(): \Magento\Sales\Model\Order
1014+
{
1015+
if (!$this->order) {
1016+
$this->order = $this->orderFactory->create();
1017+
1018+
if ($incrementId = $this->getOrderIncrementId()) {
1019+
$this->order = $this->order->loadByIncrementId($incrementId);
1020+
}
1021+
}
1022+
1023+
return $this->order;
1024+
}
1025+
1026+
/**
1027+
* Fetch order increment id from response.
1028+
*
1029+
* @return string
1030+
*/
1031+
private function getOrderIncrementId(): string
1032+
{
1033+
return $this->getResponse()->getXInvoiceNum();
1034+
}
1035+
9971036
/**
9981037
* Checks if filter action is Report Only. Transactions that trigger this filter are processed as normal,
9991038
* but are also reported in the Merchant Interface as triggering this filter.

0 commit comments

Comments
 (0)