Skip to content

Commit

Permalink
merge magento/2.4-develop into magento-tsg/2.4-develop-pr9
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-mts-svc authored Feb 14, 2020
2 parents 8b4054a + 5c5b60c commit f4bd829
Show file tree
Hide file tree
Showing 16 changed files with 1,125 additions and 489 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;

/**
* Class CaptureStrategyCommand
* Braintree capture implementation.
*
* @SuppressWarnings(PHPMD)
*/
class CaptureStrategyCommand implements CommandInterface
Expand Down Expand Up @@ -84,7 +85,7 @@ class CaptureStrategyCommand implements CommandInterface
* @param FilterBuilder $filterBuilder
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param SubjectReader $subjectReader
* @param BraintreeAdapterFactory $braintreeAdapterFactory,
* @param BraintreeAdapterFactory $braintreeAdapterFactory
* @param BraintreeSearchAdapter $braintreeSearchAdapter
*/
public function __construct(
Expand Down Expand Up @@ -112,9 +113,9 @@ public function execute(array $commandSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObjectInterface $paymentDO */
$paymentDO = $this->subjectReader->readPayment($commandSubject);

$command = $this->getCommand($paymentDO);
$this->commandPool->get($command)->execute($commandSubject);

return $this->commandPool->get($command)->execute($commandSubject);
}

/**
Expand All @@ -128,11 +129,8 @@ private function getCommand(PaymentDataObjectInterface $paymentDO)
$payment = $paymentDO->getPayment();
ContextHelper::assertOrderPayment($payment);

// if auth transaction does not exist then execute authorize&capture command
// if capture transaction does not exist then execute capture command
$existsCapture = $this->isExistsCaptureTransaction($payment);
if (!$payment->getAuthorizationTransaction() && !$existsCapture) {
return self::SALE;
}

// do capture for authorization transaction
if (!$existsCapture && !$this->isExpiredAuthorization($payment, $paymentDO->getOrder())) {
Expand Down
Loading

0 comments on commit f4bd829

Please sign in to comment.