docs: private UUID retrievePaymentId(@Nullable final String paymentExternalKey, @Nullable final String paymentTransactionExternalKey, final InternalCallContext internalCallContext) throws PaymentApiException {
          if (paymentExternalKey != null) {
              final PaymentModelDao payment = paymentDao.getPaymentByExternalKey(paymentExternalKey, internalCallContext);
              if (payment != null) {
                  return payment.getId();
              }
          }
  
          if (paymentTransactionExternalKey == null) {
              return null;
          }
  
          final List<PaymentTransactionModelDao> paymentTransactionModelDaos = paymentDao.getPaymentTransactionsByExternalKey(paymentTransactionExternalKey, internalCallContext);
          for (final PaymentTransactionModelDao paymentTransactionModelDao : paymentTransactionModelDaos) {
              if (paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.SUCCESS ||
                  paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.PENDING ||
                  paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.UNKNOWN) {
                  return paymentTransactionModelDao.getPaymentId();
              }
          }
  
          UUID paymentIdCandidate = null;
          for (final PaymentTransactionModelDao paymentTransactionModelDao : paymentTransactionModelDaos) {
              if (paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.PAYMENT_FAILURE ||
                  paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.PLUGIN_FAILURE) {
                  if (paymentIdCandidate == null) {
                      paymentIdCandidate = paymentTransactionModelDao.getPaymentId();
                  } else if (!paymentIdCandidate.equals(paymentTransactionModelDao.getPaymentId())) {
                      throw new PaymentApiException(ErrorCode.PAYMENT_INTERNAL_ERROR, "Multiple failed payments sharing the same transaction external key - this should never happen");
                  }
              }
          }
  
          return paymentIdCandidate;
      }