/**
  * Saves a payment-gateway mapping
  * 
  * @param  Payment          $payment The payment
  * @param  GatewayInterface $gateway The gateway
  */
 public function save(Payment $payment, GatewayInterface $gateway)
 {
     if (!$payment->id) {
         throw new \LogicException("Payment ID must be set before saving payment gateway record.");
     }
     $this->_query->run("REPLACE INTO \n\t\t\t\t`payment_gateway`\n\t\t\tVALUES\n\t\t\t\t(?i, ?s)\n\t\t", [$payment->id, $gateway->getName()]);
 }
 /**
  * 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());
 }