Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
Merge pull request #3839 from magento-mpi/PR-2.3-develop
Browse files Browse the repository at this point in the history
[MPI] Bug fixes
  • Loading branch information
viktym authored Mar 5, 2019
2 parents c0a3931 + abb7a6b commit 74ebef8
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
*/
namespace Magento\Paypal\Controller\Express\AbstractExpress;

class ShippingOptionsCallback extends \Magento\Paypal\Controller\Express\AbstractExpress
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Paypal\Controller\Express\AbstractExpress;
use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Framework\App\RequestInterface;

/**
* Returns shipping rates by server-to-server request from PayPal.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ShippingOptionsCallback extends AbstractExpress implements CsrfAwareActionInterface
{
/**
* @var \Magento\Quote\Api\CartRepositoryInterface
Expand Down Expand Up @@ -65,4 +75,21 @@ public function execute()
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
}
}

/**
* @inheritDoc
*/
public function createCsrfValidationException(
RequestInterface $request
): ?InvalidRequestException {
return null;
}

/**
* @inheritDoc
*/
public function validateForCsrf(RequestInterface $request): ?bool
{
return true;
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Paypal/Model/Express/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ protected static function cmpShippingOptions(DataObject $option1, DataObject $op
*/
protected function _matchShippingMethodCode(Address $address, $selectedCode)
{
$address->collectShippingRates();
$options = $this->_prepareShippingOptions($address, false);
foreach ($options as $option) {
if ($selectedCode === $option['code'] // the proper case as outlined in documentation
Expand Down
22 changes: 7 additions & 15 deletions app/code/Magento/SalesRule/Model/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ protected function _getRules(Address $address = null)
}

/**
* Address id getter.
*
* @param Address $address
* @return string
*/
Expand Down Expand Up @@ -327,21 +329,7 @@ public function processShippingAmount(Address $address)
$baseDiscountAmount = $rule->getDiscountAmount();
break;
case \Magento\SalesRule\Model\Rule::CART_FIXED_ACTION:
$cartRules = $address->getCartFixedRules();
if (!isset($cartRules[$rule->getId()])) {
$cartRules[$rule->getId()] = $rule->getDiscountAmount();
}
if ($cartRules[$rule->getId()] > 0) {
$quoteAmount = $this->priceCurrency->convert($cartRules[$rule->getId()], $quote->getStore());
$discountAmount = min($shippingAmount - $address->getShippingDiscountAmount(), $quoteAmount);
$baseDiscountAmount = min(
$baseShippingAmount - $address->getBaseShippingDiscountAmount(),
$cartRules[$rule->getId()]
);
$cartRules[$rule->getId()] -= $baseDiscountAmount;
}

$address->setCartFixedRules($cartRules);
// Shouldn't be proceed according to MAGETWO-96403
break;
}

Expand Down Expand Up @@ -519,6 +507,8 @@ public function sortItemsByPriority($items, Address $address = null)
}

/**
* Rule total items getter.
*
* @param int $key
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
Expand All @@ -533,6 +523,8 @@ public function getRuleItemTotalsInfo($key)
}

/**
* Decrease rule items count.
*
* @param int $key
* @return $this
*/
Expand Down
Loading

0 comments on commit 74ebef8

Please sign in to comment.