Skip to content

Commit

Permalink
Removed secondary plugin function, changed exception type
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonchoate committed Jan 28, 2022
1 parent da5d851 commit b1399dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

## 1.1.0
* Added plugin for `savePaymentInformation` function as some customized checkouts make a call to this guest cart function as well
* Extracted call for checking cart to its own function
* Changed type of exception that is thrown to prevent redirects
21 changes: 2 additions & 19 deletions Plugin/Magento/Checkout/Model/CardingPreventionPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace PrestonChoate\CardingPrevention\Plugin\Magento\Checkout\Model;
use PrestonChoate\CardingPrevention\Model\Config;
use Magento\Checkout\Exception as CheckoutException;
use Magento\Checkout\Model\GuestPaymentInformationManagement;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Quote\Api\Data\AddressInterface;
use Magento\Quote\Api\Data\PaymentInterface;

Expand Down Expand Up @@ -52,23 +52,6 @@ public function beforeSavePaymentInformationAndPlaceOrder(
$this->checkCartId($cartId);
}

/**
* @param GuestPaymentInformationManagement $subject
* @param $cartId
* @param $email
* @param PaymentInterface $paymentMethod
* @param AddressInterface|null $billingAddress
*/
public function beforeSavePaymentInformation(
GuestPaymentInformationManagement $subject,
$cartId,
$email,
PaymentInterface $paymentMethod,
AddressInterface $billingAddress = null)
{
$this->checkCartId($cartId);
}

/**
* Checks cart ID and throws exception if it has been used too frequently
*
Expand All @@ -88,7 +71,7 @@ protected function checkCartId($cartId)
$value = $this->cache->load($cartId);
$this->cache->save($data, $cartId, $tags, $lifetime);
if ($value) {
throw new AuthorizationException(__('Too many requests'));
throw new CheckoutException(__('Too many requests'));
}

}
Expand Down

0 comments on commit b1399dc

Please sign in to comment.