Class: SpreedlyCore::TestGateway

Inherits:
Gateway show all
Defined in:
lib/spreedly-core-ruby/test_gateway.rb

Instance Attribute Summary

Attributes inherited from Gateway

#auth_modes, #gateway_type, #name, #redacted, #supports_authorize, #supports_capture, #supports_credit, #supports_purchase, #supports_void, #token

Class Method Summary collapse

Methods inherited from Gateway

#==, all, create, #initialize, supported_gateways, #use!

Methods inherited from Base

configure, environment_key, gateway_token, gateway_token=, #initialize, verify_get, verify_options, verify_post, verify_put, verify_request

Constructor Details

This class inherits a constructor from SpreedlyCore::Gateway

Class Method Details

.get_or_createObject

gets a test gateway, creates if necessary



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/spreedly-core-ruby/test_gateway.rb', line 4

def self.get_or_create
  # get the list of gateways and return the first test gateway
  # if none exist, create one
  gateways = Gateway.all
  gateways.each do |g|
    return g if g.gateway_type == "test" && g.redacted == false
  end

  # no test gateway yet, let's create one
  return Gateway.create(:gateway_type => "test")
end