Class: ActivePayment::Gateway::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/activepayment/gateway_base.rb

Direct Known Subclasses

Paypal::Gateway, Wirecard::Gateway

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transaction_id, amount) ⇒ Base

Returns a new instance of Base.



9
10
11
12
# File 'lib/activepayment/gateway_base.rb', line 9

def initialize(transaction_id, amount)
  @transaction_id = transaction_id
  @amount = amount.kind_of?(Money) ? amount : Money.new(amount, default_currency.upcase)
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



7
8
9
# File 'lib/activepayment/gateway_base.rb', line 7

def amount
  @amount
end

#transaction_idObject

Returns the value of attribute transaction_id.



7
8
9
# File 'lib/activepayment/gateway_base.rb', line 7

def transaction_id
  @transaction_id
end

#transaction_paramsObject

Returns the value of attribute transaction_params.



7
8
9
# File 'lib/activepayment/gateway_base.rb', line 7

def transaction_params
  @transaction_params
end

Class Method Details

.build(name) ⇒ Object



14
15
16
# File 'lib/activepayment/gateway_base.rb', line 14

def self.build(name)
  "ActivePayment::#{name.to_s.classify}::Gateway".constantize
end

.config {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



23
24
25
# File 'lib/activepayment/gateway_base.rb', line 23

def self.config
  yield self
end

.config=(config) ⇒ Object



18
19
20
21
# File 'lib/activepayment/gateway_base.rb', line 18

def self.config=(config)
  config = config[self.gateway_name] if config.include?(self.gateway_name) && !config[self.gateway_name].blank?
  config.each { |method, value| self.send("#{method}=", value) }
end

Instance Method Details

#http_connectionObject



35
36
37
38
39
40
41
42
# File 'lib/activepayment/gateway_base.rb', line 35

def http_connection
  http = Net::HTTP.new(self.url.host, self.url.port)
  unless http.blank?
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    yield http
  end
end

#urlObject



27
28
29
30
31
32
33
# File 'lib/activepayment/gateway_base.rb', line 27

def url
  if  self.mode.blank? || self.mode.eql?('demo') || self.mode.eql?('test')
    URI.parse self.test_url
  else
    URI.parse self.live_url
  end
end