Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.3-develop' into 2.3-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
suryakant-krish committed Dec 15, 2018
2 parents 485b89f + 619f2db commit 3a56397
Show file tree
Hide file tree
Showing 279 changed files with 9,186 additions and 1,964 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 [[email protected]](mailto:[email protected]) 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
Expand Up @@ -13,10 +13,9 @@
<argument name="adminUser" defaultValue="_ENV"/>
</arguments>
<amOnPage url="{{AdminLoginPage.url}}" stepKey="navigateToAdmin"/>
<waitForPageLoad stepKey="waitForAdminLoginPageLoad"/>
<fillField selector="{{AdminLoginFormSection.username}}" userInput="{{adminUser.MAGENTO_ADMIN_USERNAME}}" stepKey="fillUsername"/>
<fillField selector="{{AdminLoginFormSection.password}}" userInput="{{adminUser.MAGENTO_ADMIN_PASSWORD}}" stepKey="fillPassword"/>
<click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickLogin"/>
<closeAdminNotification stepKey="closeAdminNotification"/>
</actionGroup>
</actionGroups>
</actionGroups>
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);
}
}
81 changes: 81 additions & 0 deletions app/code/Magento/Braintree/Plugin/OrderCancellation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Braintree\Plugin;

use Magento\Braintree\Model\Paypal\OrderCancellationService;
use Magento\Braintree\Model\Ui\ConfigProvider;
use Magento\Braintree\Model\Ui\PayPal\ConfigProvider as PayPalConfigProvider;
use Magento\Framework\Exception\LocalizedException;
use Magento\Quote\Api\CartManagementInterface;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Api\Data\PaymentInterface;

/**
* Cancels an order and an authorization transaction.
*/
class OrderCancellation
{
/**
* @var OrderCancellationService
*/
private $orderCancellationService;

/**
* @var CartRepositoryInterface
*/
private $quoteRepository;

/**
* @param OrderCancellationService $orderCancellationService
* @param CartRepositoryInterface $quoteRepository
*/
public function __construct(
OrderCancellationService $orderCancellationService,
CartRepositoryInterface $quoteRepository
) {
$this->orderCancellationService = $orderCancellationService;
$this->quoteRepository = $quoteRepository;
}

/**
* Cancels an order if an exception occurs during the order creation.
*
* @param CartManagementInterface $subject
* @param \Closure $proceed
* @param int $cartId
* @param PaymentInterface $payment
* @return int
* @throws \Exception
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundPlaceOrder(
CartManagementInterface $subject,
\Closure $proceed,
$cartId,
PaymentInterface $payment = null
) {
try {
return $proceed($cartId, $payment);
} catch (\Exception $e) {
$quote = $this->quoteRepository->get((int) $cartId);
$payment = $quote->getPayment();
$paymentCodes = [
ConfigProvider::CODE,
ConfigProvider::CC_VAULT_CODE,
PayPalConfigProvider::PAYPAL_CODE,
PayPalConfigProvider::PAYPAL_VAULT_CODE
];
if (in_array($payment->getMethod(), $paymentCodes)) {
$incrementId = $quote->getReservedOrderId();
$this->orderCancellationService->execute($incrementId);
}

throw $e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="DeleteCustomerActionGroup">
<arguments>
<argument name="lastName" defaultValue=""/>
</arguments>
<click stepKey="openCustomers" selector="{{AdminMenuSection.customers}}"/>
<waitForPageLoad stepKey="waitForCatalogSubmenu" time="10"/>
<click stepKey="clickOnAllCustomers" selector="{{CustomersSubmenuSection.allCustomers}}"/>
<waitForPageLoad stepKey="waitForProductsPage" time="10"/>
<!--Clear filter if exist-->
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="navigateToCustomers"/>
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingCustomerFilters"/>

<click stepKey="chooseCustomer" selector="{{CustomersPageSection.customerCheckbox(lastName)}}"/>
<waitForAjaxLoad stepKey="waitForThick" time="2"/>
<click stepKey="OpenActions" selector="{{CustomersPageSection.actions}}"/>
Expand All @@ -23,6 +23,5 @@
<waitForPageLoad stepKey="waitForDeleteItemPopup" time="10"/>
<click stepKey="clickOnOk" selector="{{CustomersPageSection.ok}}"/>
<waitForElementVisible stepKey="waitForSuccessfullyDeletedMessage" selector="{{CustomersPageSection.deletedSuccessMessage}}" time="10"/>

</actionGroup>
</actionGroups>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<data key="City">Yerevan</data>
<data key="Zip">9999</data>
<data key="PhoneNumber">9999</data>
<data key="Country">Armenia</data>
</entity>

</entities>
Loading

0 comments on commit 3a56397

Please sign in to comment.