public function _loadPayments($return)
 {
     $paymentIDs = $this->_query->run("\n\t\t\tSELECT\n\t\t\t\tpayment_id\n\t\t\tFROM\n\t\t\t\treturn_payment\n\t\t\tWHERE\n\t\t\t\treturn_id = :returnID?i\n\t\t", ['returnID' => $return->id]);
     $paymentIDs = $paymentIDs->flatten('payment_id');
     $payments = $this->_paymentLoader->getByID($paymentIDs) ?: [];
     if (!is_array($payments)) {
         $payments = [$payments];
     }
     return $payments;
 }
 /**
  * Gets the payments created through a gateway.
  * 
  * @param  GatewayInterface       $gateway The gateway
  * @return array[Payment\Payment]          The payments for the gateway
  */
 public function getPaymentsByGateway(GatewayInterface $gateway)
 {
     $result = $this->_queryBuilderFactory->getQueryBuilder()->select('`payment_id`')->from('`payment_gateway`')->where('`gateway` = ?s', [$gateway->getName()]);
     return $this->_paymentLoader->getByIDs($result->flatten());
 }