Class: Payzilla::Gateways::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/payzilla/gateways.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, log = nil) ⇒ Gateway

Creates gateway instance

Parameters:

  • config (Config)

    the Payzilla::Config object

  • log (String) (defaults to: nil)

    path to config file



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/payzilla/gateways.rb', line 14

def initialize(config, log=nil)
  @config = config

  if defined?(Rails) && Rails.root.join('log/gateways').directory?
    log ||= Rails.root.join("log/gateways/#{@config.keyword}.log")
  end

  if !log.respond_to?(:info)
    @logger = Logger.new log.to_s, 2
    @logger.level = Logger::DEBUG
    @logger.level = @config.debug_level if @config.respond_to?(:debug_level)
    @logger.formatter = Logger::Formatter.new
  end

  @revision_page_size = 5000
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/payzilla/gateways.rb', line 6

def config
  @config
end

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/payzilla/gateways.rb', line 7

def logger
  @logger
end

#revision_page_sizeObject

Returns the value of attribute revision_page_size.



8
9
10
# File 'lib/payzilla/gateways.rb', line 8

def revision_page_size
  @revision_page_size
end

Class Method Details

.available_attachmentsArray

Show registered attachments

Returns:

  • (Array)

    an array with registered attachments



70
71
72
# File 'lib/payzilla/gateways.rb', line 70

def self.available_attachments
  @available_attachments || []
end

.available_settingsArray

Show registered settings

Returns:

  • (Array)

    an array with registered settings



63
64
65
# File 'lib/payzilla/gateways.rb', line 63

def self.available_settings
  @available_settings || []
end

.available_switchesArray

Show registered switches

Returns:

  • (Array)

    an array with registered switches



77
78
79
# File 'lib/payzilla/gateways.rb', line 77

def self.available_switches
  @available_switches || []
end

.can_list_providersObject

Set that Gateway can set providers



111
112
113
# File 'lib/payzilla/gateways.rb', line 111

def self.can_list_providers
  @can_list_providers = true
end

.can_list_providers?Boolean

Check if gateway can list providers

Returns:

  • (Boolean)


106
107
108
# File 'lib/payzilla/gateways.rb', line 106

def self.can_list_providers?
  @can_list_providers == true
end

.register_attachments(list) ⇒ Object

Register some attachments

Parameters:

  • list (Array)

    list of strings, which are attachments, defined in Payzilla::Config instance with appendix “attachment_”



41
42
43
# File 'lib/payzilla/gateways.rb', line 41

def self.register_attachments(list)
  @available_attachments = list
end

.register_settings(list) ⇒ Object

Register some settings

Parameters:

  • list (Array)

    list of strings, which are settings, defined in Payzilla::Config instance with appendix “setting_”



34
35
36
# File 'lib/payzilla/gateways.rb', line 34

def self.register_settings(list)
  @available_settings = list
end

.register_switches(list) ⇒ Object

Register some switches

Parameters:

  • list (Array)

    list of strings, which are switches, defined in Payzilla::Config instance with appendix “switch_”



48
49
50
# File 'lib/payzilla/gateways.rb', line 48

def self.register_switches(list)
  @available_switches = list
end

.require_payment_fields(list) ⇒ Object



52
53
54
# File 'lib/payzilla/gateways.rb', line 52

def self.require_payment_fields(list)
  @required_payment_fields = list
end

.required_payment_fieldsObject



56
57
58
# File 'lib/payzilla/gateways.rb', line 56

def self.required_payment_fields
  @required_payment_fields || []
end

.requires_revisionObject

Require gateway revision



96
97
98
# File 'lib/payzilla/gateways.rb', line 96

def self.requires_revision
  @requires_revision = true
end

.requires_revision?Boolean

Check if gateway requires revision

Returns:

  • (Boolean)


91
92
93
# File 'lib/payzilla/gateways.rb', line 91

def self.requires_revision?
  @requires_revision == true
end

Instance Method Details

#can_list_providers?Boolean

Check if gateway can list providers

Returns:

  • (Boolean)


101
102
103
# File 'lib/payzilla/gateways.rb', line 101

def can_list_providers?
  self.class.can_list_providers?
end

#requires_revision?Boolean

Check if gateway requires revision

Returns:

  • (Boolean)


84
85
86
# File 'lib/payzilla/gateways.rb', line 84

def requires_revision?
  self.class.requires_revision?
end

#revise(revision) ⇒ String

Send revision to carrier

Parameters:

  • revision (Revision)

    an object, created from Payzilla::Revision

Returns:

  • (String)

    error code



119
120
121
# File 'lib/payzilla/gateways.rb', line 119

def revise(revision)
  send_revision revision, generate_revision(revision)[1]
end