Class: Cardgate::Gateway
- Inherits:
-
Object
- Object
- Cardgate::Gateway
- Defined in:
- lib/cardgate/gateway.rb
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.environment ⇒ Object
Returns the value of attribute environment.
-
.merchant ⇒ Object
Returns the value of attribute merchant.
-
.request_logger ⇒ Object
Returns the value of attribute request_logger.
Class Method Summary collapse
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/cardgate/gateway.rb', line 8 def api_key @api_key end |
.environment ⇒ Object
Returns the value of attribute environment.
8 9 10 |
# File 'lib/cardgate/gateway.rb', line 8 def environment @environment end |
.merchant ⇒ Object
Returns the value of attribute merchant.
8 9 10 |
# File 'lib/cardgate/gateway.rb', line 8 def merchant @merchant end |
.request_logger ⇒ Object
Returns the value of attribute request_logger.
8 9 10 |
# File 'lib/cardgate/gateway.rb', line 8 def request_logger @request_logger end |
Class Method Details
.connection ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cardgate/gateway.rb', line 23 def self.connection raise Cardgate::Exception, 'Merchant and/or API key not set' if !self.merchant || !self.api_key Faraday.new(url: self.request_url, ssl: { verify: !is_test_environment? } ) do |faraday| faraday.request :json faraday.response :json faraday.response :logger if request_logger == true faraday.adapter Faraday.default_adapter faraday.basic_auth self.merchant, self.api_key end end |
.is_test_environment? ⇒ Boolean
11 12 13 |
# File 'lib/cardgate/gateway.rb', line 11 def self.is_test_environment? self.environment == :test end |