Commit 60a9b1ec authored by Niels de Feyter's avatar Niels de Feyter
Browse files

#3318548 by casey: Return controller loads non-mollie payments

parent fdda3df8
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\commerce_mollie\Controller;

use Drupal\commerce_payment\Entity\PaymentInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Link;
use Drupal\Core\Routing\RouteMatchInterface;
@@ -27,8 +28,10 @@ class MollieReturnController extends ControllerBase {
    $order = $route_match->getParameter('commerce_order');
    /** @var \Drupal\commerce_payment\PaymentStorage $payment_storage */
    $payment_storage = \Drupal::entityTypeManager()->getStorage('commerce_payment');
    /** @var \Drupal\commerce_payment\Entity\Payment[] $payment */
    $order_payments = $payment_storage->loadMultipleByOrder($order);
    /** @var \Drupal\commerce_payment\Entity\Payment[] $order_payments */
    $order_payments = array_filter($payment_storage->loadMultipleByOrder($order), function (PaymentInterface $payment) {
      return $payment->getPaymentGateway() && $payment->getPaymentGateway()->getPluginId() === 'mollie';
    });
    /** @var \Drupal\commerce_payment\Entity\Payment $last_payment */
    $last_payment = end($order_payments);
    /** @var \Drupal\Core\Messenger\MessengerInterface $messenger */