/**
  * Return invoice model for transaction
  *
  * @param OrderInterface $order
  * @param string $transactionId
  * @return false|Invoice
  */
 protected function getInvoiceForTransactionId(OrderInterface $order, $transactionId)
 {
     foreach ($order->getInvoiceCollection() as $invoice) {
         if ($invoice->getTransactionId() == $transactionId) {
             $invoice->load($invoice->getId());
             // to make sure all data will properly load (maybe not required)
             return $invoice;
         }
     }
     foreach ($order->getInvoiceCollection() as $invoice) {
         if ($invoice->getState() == \Magento\Sales\Model\Order\Invoice::STATE_OPEN && $invoice->load($invoice->getId())) {
             $invoice->setTransactionId($transactionId);
             return $invoice;
         }
     }
     return false;
 }