code: protected function saleHasOutstandingPayments(SaleInterface $sale)
      {
          $allowedStates = [
              PaymentStates::STATE_CAPTURED,
              PaymentStates::STATE_AUTHORIZED,
              PaymentStates::STATE_EXPIRED,
          ];
          foreach ($sale->getPayments() as $payment) {
              if ($payment->getMethod()->isOutstanding() && in_array($payment->getState(), $allowedStates, true)) {
                  return true;
              }
          }
  
          return false;
      }
docs: Returns whether the sale has (accepted/expired) outstanding payments.
  
  @param SaleInterface $sale
  
  @return bool