Module: OgoneRails

Extended by:
OgoneRails
Included in:
OgoneRails
Defined in:
lib/ogone-rails.rb,
lib/ogone-rails/form.rb,
lib/ogone-rails/config.rb,
lib/ogone-rails/helpers.rb,
lib/ogone-rails/check-auth.rb,
lib/ogone-rails/string-to-hash.rb

Defined Under Namespace

Modules: Helpers Classes: CheckAuth, Form, MissingConfiguration, StringToHash

Constant Summary collapse

ASSET_ROOT =
File.expand_path((defined?(Rails) && Rails.root.to_s.length > 0) ? Rails.root : ENV['RAILS_ROOT'] || '.')
DEFAULT_CONFIG =
File.join( ASSET_ROOT, 'config', 'ogone.yml')
TEST_SERVICE_URL =
'https://secure.ogone.com/ncol/test/orderstandard.asp'
LIVE_SERVICE_URL =
'https://secure.ogone.com/ncol/prod/orderstandard.asp'
STATUS_CODES =
{
  0   => "Incomplete or invalid",
  1	  => "Cancelled by client",
  2	  => "Authorization refused",
  4	  => "Order stored",
  40  => "Stored waitingexternal result",
  41  => "Waiting client payment",
  5	  => "Authorized",
  50  => "Authorized waiting external result",
  51  => "Authorization waiting",
  52  => "Authorization not known",
  55  => "Stand-by",
  56  => "OK with scheduled payments",
  57  => "Error in scheduled payments",
  59  => "Authoriz. to get manually",
  6   => "Authorized and cancelled",
  61  => "Author. deletion waiting",
  62  => "Author. deletion uncertain",
  63  => "Author. deletion refused",
  64  => "Authorized and cancelled",
  7   => "Payment deleted",
  71  => "Payment deletion pending",
  72  => "Payment deletion uncertain",
  73  => "Payment deletion refused",
  74  => "Payment deleted",
  75  => "Deletion processed by merchant",
  8   => "Refund",
  81  => "Refund pending",
  82  => "Refund uncertain",
  83  => "Refund refused",
  84  => "Payment declined by the acquirer",
  85  => "Refund processed by merchant",
  9   => "Payment requested",
  91  => "Payment processing",
  92  => "Payment uncertain",
  93  => "Payment refused",
  94  => "Refund declined by the acquirer",
  95  => "Payment processed by merchant",
  99  => "Being processed"
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.currencyObject



88
89
90
# File 'lib/ogone-rails/config.rb', line 88

def self.currency
  @currency
end

.languageObject



92
93
94
# File 'lib/ogone-rails/config.rb', line 92

def self.language
  @language
end

.load!Object



19
20
21
# File 'lib/ogone-rails.rb', line 19

def self.load!
	load_config DEFAULT_CONFIG
end

.load_config(config_path) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ogone-rails.rb', line 23

def self.load_config config_path	
	exists = config_path && File.exists?(config_path)
	raise  MissingConfiguration, "Could not find the #{ config_path } configuration file" unless exists

	# deprecated RAILS_ENV won't get hurt this way
	environment = Rails.env.split('=').last

	# load ogone configuration
	config = YAML.load_file(DEFAULT_CONFIG)[environment].symbolize_keys
	OgoneRails::config (config)
end

.modeObject



96
97
98
# File 'lib/ogone-rails/config.rb', line 96

def self.mode
  @mode
end

.pspidObject



84
85
86
# File 'lib/ogone-rails/config.rb', line 84

def self.pspid
  @pspid
end

.sha_inObject



76
77
78
# File 'lib/ogone-rails/config.rb', line 76

def self.sha_in
  @sha_in
end

.sha_outObject



80
81
82
# File 'lib/ogone-rails/config.rb', line 80

def self.sha_out
  @sha_out
end

Instance Method Details

#config(c) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ogone-rails/config.rb', line 55

def config c
  
  c.each do |key, value|
    case key
    when :pspid
      @pspid = value
    when :sha_in
      @sha_in = value
    when :sha_out
      @sha_out = value
    when :currency
      @currency = value unless value.nil?
    when :language
      @language = value unless value.nil?
    when :mode
      @mode = value unless value.nil?
    end
  end
end