Skip to content

Commit

Permalink
Merge branch '2.3-develop' into ENGCOM-3056-magento-magento2-18179
Browse files Browse the repository at this point in the history
  • Loading branch information
p-bystritsky committed Dec 14, 2018
2 parents 13e2cee + b8892f0 commit 8dd0fbb
Show file tree
Hide file tree
Showing 293 changed files with 9,819 additions and 2,049 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ Magento is thankful for any contribution that can improve our code base, documen
<img src="https://raw.githubusercontent.com/wiki/magento/magento2/images/contributors.png"/>
</a>

<h3>Labels applied by the Magento team</h3>
We apply labels to public Pull Requests and Issues to help other participants retrieve additional information about current progress, component assignments, Magento release lines, and much more.
Please review the <a href="https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#labels">Code Contributions guide</a> for detailed information on labels used in Magento 2 repositories.
### Labels applied by the Magento team
We apply labels to public Pull Requests and Issues to help other participants retrieve additional information about current progress, component assignments, Magento release lines, and much more.
Please review the [Code Contributions guide](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#labels) for detailed information on labels used in Magento 2 repositories.

<h2>Reporting security issues</h2>
## Reporting security issues

To report security vulnerabilities in Magento software or web sites, please create a Bugcrowd researcher account <a href="https://bugcrowd.com/magento">there</a> to submit and follow-up your issue. Learn more about reporting security issues <a href="https://magento.com/security/reporting-magento-security-issue">here</a>.
To report security vulnerabilities in Magento software or web sites, please create a Bugcrowd researcher account [there](https://bugcrowd.com/magento) to submit and follow-up your issue. Learn more about reporting security issues [here](https://magento.com/security/reporting-magento-security-issue).

Stay up-to-date on the latest security news and patches for Magento by signing up for <a href="https://magento.com/security/sign-up">Security Alert Notifications</a>.
Stay up-to-date on the latest security news and patches for Magento by signing up for [Security Alert Notifications](https://magento.com/security/sign-up).

<h2>License</h2>
## License

Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license.

Expand All @@ -59,3 +59,13 @@ Please see [LICENSE.txt](https://github.com/magento/magento2/blob/2.3-develop/LI
Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file.
Please see LICENSE_EE.txt for the full text of the MEE License or visit https://magento.com/legal/terms/enterprise.

## Community Engineering Slack

To connect with Magento and the Community, join us on the [Magento Community Engineering Slack](https://magentocommeng.slack.com). If you are interested in joining Slack, or a specific channel, send us request at [engcom@adobe.com](mailto:engcom@adobe.com) or [self signup](https://tinyurl.com/engcom-slack).


We have channels for each project. These channels are recommended for new members:

- [general](https://magentocommeng.slack.com/messages/C4YS78WE6): Open chat for introductions and Magento 2 questions
- [github](https://magentocommeng.slack.com/messages/C7KB93M32): Support for GitHub issues, pull requests, and processes
- [public-backlog](https://magentocommeng.slack.com/messages/CCV3J3RV5): Discussions of the Magento 2 backlog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
namespace Magento\AdminNotification\Model\ResourceModel;

/**
* Inbox resource model
*
* @api
* @since 100.0.2
*/
Expand Down Expand Up @@ -77,8 +79,7 @@ public function getNoticeStatus(\Magento\AdminNotification\Model\Inbox $object)
'is_read=?',
0
);
$return = $connection->fetchPairs($select);
return $return;
return $connection->fetchPairs($select);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Authorizenet\Block\Adminhtml\Order\View\Info;

use Magento\Framework\Phrase;
use Magento\Payment\Block\ConfigurableInfo;

/**
* Payment information block for Authorize.net payment method
*/
class PaymentDetails extends ConfigurableInfo
{
/**
* Returns localized label for payment info block
*
* @param string $field
* @return string | Phrase
*/
protected function getLabel($field)
{
return __($field);
}
}
27 changes: 20 additions & 7 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
/**
* @var string
*/
protected $_infoBlockType = \Magento\Payment\Block\Info::class;
protected $_infoBlockType = \Magento\Authorizenet\Block\Adminhtml\Order\View\Info\PaymentDetails::class;

/**
* Payment Method feature
Expand Down Expand Up @@ -371,8 +371,7 @@ public function void(\Magento\Payment\Model\InfoInterface $payment)
}

/**
* Refund the amount
* Need to decode last 4 digits for request.
* Refund the amount need to decode last 4 digits for request.
*
* @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface $payment
* @param float $amount
Expand Down Expand Up @@ -626,6 +625,14 @@ protected function fillPaymentByResponse(\Magento\Framework\DataObject $payment)
$payment->setIsTransactionPending(true)
->setIsFraudDetected(true);
}

$additionalInformationKeys = explode(',', $this->getValue('paymentInfoKeys'));
foreach ($additionalInformationKeys as $paymentInfoKey) {
$paymentInfoValue = $response->getDataByKey($paymentInfoKey);
if ($paymentInfoValue !== null) {
$payment->setAdditionalInformation($paymentInfoKey, $paymentInfoValue);
}
}
}

/**
Expand Down Expand Up @@ -682,6 +689,7 @@ protected function matchAmount($amount)

/**
* Operate with order using information from Authorize.net.
*
* Authorize order or authorize and capture it.
*
* @param \Magento\Sales\Model\Order $order
Expand Down Expand Up @@ -858,7 +866,7 @@ public function getConfigInterface()
* Getter for specified value according to set payment method code
*
* @param mixed $key
* @param null $storeId
* @param int|string|null|\Magento\Store\Model\Store $storeId
* @return mixed
*/
public function getValue($key, $storeId = null)
Expand Down Expand Up @@ -918,10 +926,12 @@ public function fetchTransactionInfo(\Magento\Payment\Model\InfoInterface $payme
$payment->setIsTransactionDenied(true);
}
$this->addStatusCommentOnUpdate($payment, $response, $transactionId);
return [];
return $response->getData();
}

/**
* Add statuc comment on update.
*
* @param \Magento\Sales\Model\Order\Payment $payment
* @param \Magento\Framework\DataObject $response
* @param string $transactionId
Expand Down Expand Up @@ -996,8 +1006,9 @@ protected function getTransactionResponse($transactionId)
}

/**
* @return \Psr\Log\LoggerInterface
* Get psr logger.
*
* @return \Psr\Log\LoggerInterface
* @deprecated 100.1.0
*/
private function getPsrLogger()
Expand Down Expand Up @@ -1038,7 +1049,9 @@ private function getOrderIncrementId(): string
}

/**
* Checks if filter action is Report Only. Transactions that trigger this filter are processed as normal,
* Checks if filter action is Report Only.
*
* Transactions that trigger this filter are processed as normal,
* but are also reported in the Merchant Interface as triggering this filter.
*
* @param string $fdsFilterAction
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Authorizenet/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<cgi_url>https://secure.authorize.net/gateway/transact.dll</cgi_url>
<cgi_url_td_test_mode>https://apitest.authorize.net/xml/v1/request.api</cgi_url_td_test_mode>
<cgi_url_td>https://api2.authorize.net/xml/v1/request.api</cgi_url_td>
<paymentInfoKeys>x_card_type,x_account_number,x_avs_code,x_auth_code,x_response_reason_text,x_cvv2_resp_code</paymentInfoKeys>
</authorizenet_directpost>
</payment>
</default>
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Authorizenet/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@
</argument>
</arguments>
</type>
<type name="Magento\Authorizenet\Block\Adminhtml\Order\View\Info\PaymentDetails">
<arguments>
<argument name="config" xsi:type="object">Magento\Authorizenet\Model\Directpost</argument>
</arguments>
</type>
</config>
6 changes: 6 additions & 0 deletions app/code/Magento/Authorizenet/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ Debug,Debug
"Minimum Order Total","Minimum Order Total"
"Maximum Order Total","Maximum Order Total"
"Sort Order","Sort Order"
"x_card_type","Credit Card Type"
"x_account_number", "Credit Card Number"
"x_avs_code","AVS Response Code"
"x_auth_code","Processor Authentication Code"
"x_response_reason_text","Processor Response Text"
"x_cvv2_resp_code","CVV2 Response Code"
9 changes: 7 additions & 2 deletions app/code/Magento/Braintree/Controller/Paypal/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Braintree\Model\Paypal\Helper;
use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\LocalizedException;
Expand All @@ -17,7 +18,7 @@
/**
* Class PlaceOrder
*/
class PlaceOrder extends AbstractAction
class PlaceOrder extends AbstractAction implements HttpPostActionInterface
{
/**
* @var Helper\OrderPlace
Expand Down Expand Up @@ -54,6 +55,7 @@ public function __construct(

/**
* @inheritdoc
*
* @throws LocalizedException
*/
public function execute()
Expand All @@ -71,7 +73,10 @@ public function execute()
return $resultRedirect->setPath('checkout/onepage/success', ['_secure' => true]);
} catch (\Exception $e) {
$this->logger->critical($e);
$this->messageManager->addExceptionMessage($e, $e->getMessage());
$this->messageManager->addExceptionMessage(
$e,
'The order #' . $quote->getReservedOrderId() . ' cannot be processed.'
);
}

return $resultRedirect->setPath('checkout/cart', ['_secure' => true]);
Expand Down
30 changes: 21 additions & 9 deletions app/code/Magento/Braintree/Model/Paypal/Helper/OrderPlace.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

namespace Magento\Braintree\Model\Paypal\Helper;

use Magento\Quote\Model\Quote;
use Magento\Braintree\Model\Paypal\OrderCancellationService;
use Magento\Checkout\Api\AgreementsValidatorInterface;
use Magento\Checkout\Helper\Data;
use Magento\Checkout\Model\Type\Onepage;
use Magento\Customer\Model\Group;
use Magento\Customer\Model\Session;
use Magento\Checkout\Model\Type\Onepage;
use Magento\Quote\Api\CartManagementInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Checkout\Api\AgreementsValidatorInterface;
use Magento\Quote\Api\CartManagementInterface;
use Magento\Quote\Model\Quote;

/**
* Class OrderPlace
Expand Down Expand Up @@ -42,23 +43,29 @@ class OrderPlace extends AbstractHelper
private $checkoutHelper;

/**
* Constructor
*
* @var OrderCancellationService
*/
private $orderCancellationService;

/**
* @param CartManagementInterface $cartManagement
* @param AgreementsValidatorInterface $agreementsValidator
* @param Session $customerSession
* @param Data $checkoutHelper
* @param OrderCancellationService $orderCancellationService
*/
public function __construct(
CartManagementInterface $cartManagement,
AgreementsValidatorInterface $agreementsValidator,
Session $customerSession,
Data $checkoutHelper
Data $checkoutHelper,
OrderCancellationService $orderCancellationService
) {
$this->cartManagement = $cartManagement;
$this->agreementsValidator = $agreementsValidator;
$this->customerSession = $customerSession;
$this->checkoutHelper = $checkoutHelper;
$this->orderCancellationService = $orderCancellationService;
}

/**
Expand All @@ -67,7 +74,7 @@ public function __construct(
* @param Quote $quote
* @param array $agreement
* @return void
* @throws LocalizedException
* @throws \Exception
*/
public function execute(Quote $quote, array $agreement)
{
Expand All @@ -84,7 +91,12 @@ public function execute(Quote $quote, array $agreement)
$this->disabledQuoteAddressValidation($quote);

$quote->collectTotals();
$this->cartManagement->placeOrder($quote->getId());
try {
$this->cartManagement->placeOrder($quote->getId());
} catch (\Exception $e) {
$this->orderCancellationService->execute($quote->getReservedOrderId());
throw $e;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Braintree\Model\Paypal;

use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;

/**
* The service to cancel an order and void authorization transaction.
*/
class OrderCancellationService
{
/**
* @var OrderRepositoryInterface
*/
private $orderRepository;

/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;

/**
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param OrderRepositoryInterface $orderRepository
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
OrderRepositoryInterface $orderRepository
) {
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->orderRepository = $orderRepository;
}

/**
* Cancels an order and authorization transaction.
*
* @param string $incrementId
* @return bool
*/
public function execute(string $incrementId): bool
{
$order = $this->getOrder($incrementId);
if ($order === null) {
return false;
}

// `\Magento\Sales\Model\Service\OrderService::cancel` cannot be used for cancellation as the service uses
// the order repository with outdated payment method instance (ex. contains Vault instead of Braintree)
$order->cancel();
$this->orderRepository->save($order);
return true;
}

/**
* Gets order by increment ID.
*
* @param string $incrementId
* @return OrderInterface|null
*/
private function getOrder(string $incrementId)
{
$searchCriteria = $this->searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, $incrementId)
->create();

$items = $this->orderRepository->getList($searchCriteria)
->getItems();

return array_pop($items);
}
}
Loading

0 comments on commit 8dd0fbb

Please sign in to comment.