Whether or not the given gateway should allow partial capturing of payments
@param string $gateway the gateway name
@return bool
436321
public static function allowPartialCapture($gateway)
    {
        return (
            self::configToConstant($gateway, 'can_capture') === self::PARTIAL
            || self::configToConstant($gateway, 'can_capture') === self::MULTIPLE
        );
    }
6402
def authorize_and_capture
      
      resp = StdClass.new                        
      if self.financial_status == Invoice::FINANCIAL_STATUS_CAPTURED
        resp.error = "Funds for this invoice have already been captured."
      else
                        
        sc = self.site.store_config                
        case sc.pp_name                                    
          when StoreConfig::PAYMENT_PROCESSOR_STRIPE
                                                                              
            Stripe.api_key = sc.stripe_secret_key.strip
            bt = nil
            begin
              c = Stripe::Charge.create(
                :amount => (self.total * 100).to_i,
                :currency => 'usd',
                :customer => self.customer.stripe_customer_id,
                :capture => true,
                :metadata => { :invoice_id => self.id },
                :statement_descriptor => "#{self.site.description.truncate(22)}"
              )                        
            rescue Exception => ex
              resp.error = "Error during capture process\n#{ex.message}"                
            end            
            if resp.error.nil?
              InvoiceTransaction.create(
                :invoice_id => self.id,
                :transaction_id => c.id,
                :transaction_type => InvoiceTransaction::TYPE_AUTHCAP,
                :payment_processor => sc.pp_name,
                :amount => c.amount / 100.0,
                :captured => true,
                :date_processed => DateTime.now.utc,
                :success => c.status == 'succeeded'
              )
              if c.status == 'succeeded'
                self.financial_status = Invoice::FINANCIAL_STATUS_CAPTURED
                self.save
                resp.success = true
              else
                resp.error = "Error capturing funds."
              end
            end
                      
        end        
      end      
      return resp
    end
1058361
public static function getSupportedGateways($nice = true)
    {
        $allowed = Payment::config()->allowed_gateways;

        if (!is_array($allowed) || empty($allowed)) {
            throw new InvalidConfigurationException(
                'No allowed gateways configured. Use SilverStripe\Omnipay\Model\Payment.allowed_gateways config.'
            );
        }

        $allowed = array_combine($allowed, $allowed);

        if ($nice) {
            $allowed = array_map('SilverStripe\Omnipay\GatewayInfo::niceTitle', $allowed);
        }

        return $allowed;
    }
250313
public function paymentSuccessful() {
    if ($this->requestMethod->getTransactionSuccessfulCode() != NULL) {
      return $this->requestMethod->getTransactionSuccessfulCode() == $this->notifyParams['gcResultPayment'];
    }

    return FALSE;
  }
665871
public function serialize()
    {
        $this->transactionModifier = TransactionModifier::HOSTEDREQUEST;
        parent::execute();

        $client = ServicesContainer::instance()->getClient();

        if ($client->supportsHostedPayments()) {
            return $client->serializeRequest($this);
        }
        throw new UnsupportedTransactionException("Your current gateway does not support hosted payments.");
    }
941382
private function merchantPayload()
    {
        $partial = $this->partialPayments();
        if ($this->publicId() !== false && is_array($partial) === true) {
            $payload = array(
                "storeDomain" => getenv('SERVER_NAME')
            );
            return $this->payload($payload);
        }
        return false;
    }
308985
public function inTransaction(): bool
    {
        $status = pg_transaction_status($this->getResource());

        return PGSQL_TRANSACTION_INTRANS === $status || PGSQL_TRANSACTION_INERROR === $status;
    }
13344
public function isRefunded($allowPartialRefunds = true)
    {
        if ($this->data['paymentDetails']['stateName'] === 'REFUND') {
            return true;
        }

        if ($allowPartialRefunds && $this->data['paymentDetails']['stateName'] === 'PARTIAL_REFUND') {
            return true;
        }

        return false;
    }
257992
protected function redirectToCas($gateway = false)
    {
        $query['service'] = self::getDefaultService();
        if ($gateway) {
            $query['gateway'] = 'true';
        }
        self::http_redirect($this->server['login_url'] . '?' . http_build_query($query));
        // never reached
        return true;
    }
918342
public function passesAuthorization()
    {
        if ( ! $this->hasToBeAuthorized() ) return true;

        return $this->gate->allows($this->route->getName());
    }
624797
public static function requiredFields($gateway)
    {
        $fields = array();

        $requiredFields = self::getConfigSetting($gateway, 'required_fields');

        if (is_array($requiredFields)) {
            $fields = $requiredFields;
        }

        //always require the following for on-site gateways (and not manual)
        if (!self::isOffsite($gateway) && !self::isManual($gateway)) {
            $fields = array_merge(
                $fields,
                array('name', 'number', 'expiryMonth', 'expiryYear', 'cvv')
            );
        }

        return array_unique($fields);
    }
439053
def capture_funds
      
      resp = StdClass.new      
      it = InvoiceTransaction.where(:invoice_id => self.id, :success => true).first
            
      if self.financial_status == Invoice::FINANCIAL_STATUS_CAPTURED
        resp.error = "Funds for this invoice have already been captured."    
      elsif self.total > it.amount
        resp.error = "The invoice total exceeds the authorized amount."
      elsif it.nil?
        resp.error = "This invoice doesn't seem to be authorized."
      else
                        
        sc = self.site.store_config                
        case sc.pp_name
          
          #when 'authorize.net'
          #  transaction = AuthorizeNet::AIM::Transaction.new(sc.authnet_api_login_id, sc.authnet_api_transaction_key)
          #  response = transaction.prior_auth_capture(t.transaction_id, self.total)
          #  
          #  ot = Caboose::InvoiceTransaction.create(
          #    :invoice_id        => self.id,
          #    :date_processed    => DateTime.now.utc,
          #    :transaction_type  => InvoiceTransaction::TYPE_CAPTURE,
          #    :payment_processor => sc.pp_name,
          #    :amount            => self.total,        
          #    :success           => response.response_code && response.response_code == '1',            
          #    :transaction_id    => response.transaction_id,
          #    :auth_code         => response.authorization_code,
          #    :response_code     => response.response_code
          #  )
          #  if ot.success
          #    self.date_captured = DateTime.now.utc
          #    self.save              
          #  end                                    
          #  self.update_attribute(:financial_status, Invoice::FINANCIAL_STATUS_CAPTURED)
          #  resp.success = 'Captured funds successfully'
                                    
          when StoreConfig::PAYMENT_PROCESSOR_STRIPE
                                          
            it = Caboose::InvoiceTransaction.where(:invoice_id => self.id, :success => true).first
            if it.nil?
              resp.error = "Error capturing funds for invoice #{self.id}. No previous successful authorization for this invoice exists."
              return false
            else                        
              Stripe.api_key = sc.stripe_secret_key.strip
              bt = nil
              begin
                c = Stripe::Charge.retrieve(it.transaction_id)
                c = c.capture
                bt = Stripe::BalanceTransaction.retrieve(c.balance_transaction)
              rescue Exception => ex
                resp.error = "Error during capture process\n#{ex.message}"                
              end
              
              if resp.error.nil?
                InvoiceTransaction.create(
                  :invoice_id => self.id,
                  :transaction_id => bt.id,
                  :transaction_type => InvoiceTransaction::TYPE_CAPTURE,
                  :payment_processor => sc.pp_name,
                  :amount => bt.amount / 100,                
                  :date_processed => DateTime.strptime(bt.created.to_s, '%s'),
                  :success => bt.status == 'succeeded' || bt.status == 'pending'
                )
                if bt.status == 'succeeded' || bt.status == 'pending'
                  self.financial_status = Invoice::FINANCIAL_STATUS_CAPTURED
                  self.save
                  resp.success = true
                else
                  resp.error = "Error capturing funds."
                end
              end
            end
          
        end        
      end      
      return resp
    end
744341
function selectGateway( $event )
    {
        $selectedGatewaysTypes  = explode( ',', $event->attribute( 'data_text1' ) );

        if ( count( $selectedGatewaysTypes ) == 1 && $selectedGatewaysTypes[0] != -1 )
        {
            $event->setAttribute( 'data_text2', $selectedGatewaysTypes[0] );
            $event->store();

            $this->logger->writeTimedString( $selectedGatewaysTypes[0], 'selectGateway' );
            return true;
        }

        $this->logger->writeTimedString( 'selectGateways. multiple gateways, let user choose.' );
        return false;
    }
912936
public function isFullRank()
    {
        for ($j = 0; $j < $this->n; ++$j) {
            if ($this->Rdiag[$j] == 0) {
                return false;
            }
        }
        return true;
    }
224825
public function allowRequest()
    {
        if ($this->config->get('circuitBreaker')->get('forceOpen')) {
            return false;
        }
        if ($this->config->get('circuitBreaker')->get('forceClosed')) {
            return true;
        }

        return !$this->isOpen() || $this->allowSingleTest();
    }
538630
def capture(payment, creditcard, gateway_options)
      response = request(:capture_transaction, { 'Token' => security_token(gateway_options),
                                                 'RefNum' => payment.response_code,
                                                 'Amount' => payment.amount })
      billing_response response[:capture_transaction_response][:capture_transaction_return]
    end
662790
private function isRequestAcceptedForRoute($route)
    {
        $acceptedFormats = $route['acceptedRequestFormats'];
        if (is_null($acceptedFormats)) {
            return true;
        }
        if (is_array($acceptedFormats)) {
            foreach ($acceptedFormats as $format) {
                if (strpos($this->requestedRepresentation, $format) !== false) {
                    return true;
                }
            }
            return false;
        }
        return strpos($this->requestedRepresentation, $acceptedFormats) !== false;
    }