Commit 24f6d702 authored by Andy Fowlston's avatar Andy Fowlston
Browse files

Issue #3254344 by AndyF: Exclude Afterpay from orders with a different currency

parent ccbf5960
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Exclude Afterpay from orders with a different currency [#3254344].

### Changed

- Support PHP 8.x [#3301307].
@@ -60,6 +64,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

[#3231706]: https://www.drupal.org/project/commerce_afterpay/issues/3231706

[#3254344]: https://www.drupal.org/project/commerce_afterpay/issues/3254344

[#3301307]: https://www.drupal.org/project/commerce_afterpay/issues/3301307

######
+5 −0
Original line number Diff line number Diff line
@@ -49,6 +49,11 @@ class FilterAfterpayGatewaySubscriber implements EventSubscriberInterface {
      $min = $config->getMinimumAmount();
      $max = $config->getMaximumAmount();
      $total = $order->getTotalPrice();
      // Only allow the gateway if the order's using the Afterpay store
      // currency.
      if ($max->getCurrencyCode() !== $total->getCurrencyCode()) {
        return FALSE;
      }
      return $min->lessThanOrEqual($total) && $total->lessThanOrEqual($max);
    });
    $event->setPaymentGateways($gateways);