-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/2.3-develop' into 2.3-develop
- Loading branch information
Showing
279 changed files
with
9,186 additions
and
1,964 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
app/code/Magento/Braintree/Model/Paypal/OrderCancellationService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.