Class: Adyen::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/adyen/configuration.rb

Constant Summary collapse

LIVE_RAILS_ENVIRONMENTS =

The Rails environment for which to use to Adyen “live” environment.

['production']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration



3
4
5
6
7
8
9
# File 'lib/adyen/configuration.rb', line 3

def initialize
  @default_api_params  = {}
  @default_form_params = {}
  @form_skins          = {}
  @payment_flow        = :select
  @environment         = nil
end

Instance Attribute Details

#api_passwordString

The password that’s used to authenticate for the Adyen SOAP services. You can configure it in the user management tool of the merchant area.



76
77
78
# File 'lib/adyen/configuration.rb', line 76

def api_password
  @api_password
end

#api_usernameString

The username that’s used to authenticate for the Adyen SOAP services. It should look something like ‘[email protected]+’



70
71
72
# File 'lib/adyen/configuration.rb', line 70

def api_username
  @api_username
end

#cse_public_keyString

The client-side encryption public key that is used to encrypt payment forms. You can find the key on the webservice user page in the Adyen settings.



91
92
93
# File 'lib/adyen/configuration.rb', line 91

def cse_public_key
  @cse_public_key
end

#default_api_paramsHash

Default arguments that will be used for every API call. You can override these default values by passing a diffferent value to the service class’s constructor.

Examples:

Adyen.configuration.default_api_params[:merchant_account] = 'SuperShop'


85
86
87
# File 'lib/adyen/configuration.rb', line 85

def default_api_params
  @default_api_params
end

#default_form_paramsHash

Default arguments that will be used in every HTML form.

Examples:

Adyen.configuration.default_form_params[:merchant_account] = 'SuperShop'


99
100
101
# File 'lib/adyen/configuration.rb', line 99

def default_form_params
  @default_form_params
end

#default_skinString

Name of the default skin for HPP requests.



104
105
106
# File 'lib/adyen/configuration.rb', line 104

def default_skin
  @default_skin
end

#form_skinsHash

Returns all registered skins and their accompanying skin code and shared secret.



124
125
126
# File 'lib/adyen/configuration.rb', line 124

def form_skins
  @form_skins
end

#ipn_passwordString

Password used to authenticate notification requests together with ‘ipn_username’ configuration attribute.



115
116
117
# File 'lib/adyen/configuration.rb', line 115

def ipn_password
  @ipn_password
end

#ipn_usernameString

Username that’s set in Notification settings screen in Adyen PSP system and used by notification service to authenticate instant payment notification requests.



110
111
112
# File 'lib/adyen/configuration.rb', line 110

def ipn_username
  @ipn_username
end

#merchant_specific_endpointObject

TODO



46
47
48
# File 'lib/adyen/configuration.rb', line 46

def merchant_specific_endpoint
  @merchant_specific_endpoint
end

#payment_flowString

The payment flow page type that’s used to choose the payment process

Examples:

Adyen.configuration.payment_flow = :select
Adyen.configuration.payment_flow = :pay
Adyen.configuration.payment_flow = :details


56
57
58
# File 'lib/adyen/configuration.rb', line 56

def payment_flow
  @payment_flow
end

#payment_flow_domainString

The payment flow domain that’s used to choose the payment process

Examples:

Adyen.configuration.payment_flow_domain = checkout.mydomain.com


64
65
66
# File 'lib/adyen/configuration.rb', line 64

def payment_flow_domain
  @payment_flow_domain
end

Instance Method Details

#autodetect_environment'test', 'live'

Autodetects the Adyen environment based on the RAILS_ENV constant.



34
35
36
37
38
39
40
41
42
# File 'lib/adyen/configuration.rb', line 34

def autodetect_environment
  rails_env = if defined?(::Rails) && ::Rails.respond_to?(:env)
    ::Rails.env.to_s
  elsif defined?(::RAILS_ENV)
    ::RAILS_ENV.to_s
  end

  LIVE_RAILS_ENVIRONMENTS.include?(rails_env) ? 'live' : 'test'
end

#environment(override = nil) ⇒ 'test', 'live'

Returns the current Adyen environment, either test or live.

It will return the override value if set, it will return the value set using Adyen.configuration.environment= otherwise. If this value also isn’t set, the environment is determined with autodetect_environment.



28
29
30
# File 'lib/adyen/configuration.rb', line 28

def environment(override = nil)
  override || @environment || autodetect_environment
end

#environment=(env) ⇒ Object

Setter voor the current Adyen environment.



16
17
18
# File 'lib/adyen/configuration.rb', line 16

def environment=(env)
  @environment = env
end

#form_skin_by_code(skin_code) ⇒ Hash?

Returns skin information by skin code.



169
170
171
# File 'lib/adyen/configuration.rb', line 169

def form_skin_by_code(skin_code)
  @form_skins.values.find { |skin| skin[:skin_code] == skin_code }
end

#form_skin_by_name(skin_name) ⇒ Hash?

Returns a skin information by name.



160
161
162
# File 'lib/adyen/configuration.rb', line 160

def form_skin_by_name(skin_name)
  @form_skins[skin_name.to_sym]
end

#form_skin_shared_secret_by_code(skin_code) ⇒ String?

Returns the shared secret belonging to a skin.



178
179
180
181
182
# File 'lib/adyen/configuration.rb', line 178

def form_skin_shared_secret_by_code(skin_code)
  if skin = form_skin_by_code(skin_code)
    skin[:shared_secret]
  end
end

#register_form_skin(name, skin_code, shared_secret, default_form_params = {}) ⇒ Object

Registers a skin for later use.

You can store a skin using a self defined symbol. Once the skin is registered, you can refer to it using this symbol instead of the hard-to-remember skin code. Moreover, the skin’s shared_secret will be looked up automatically for calculting signatures.

Examples:

Adyen::Configuration.register_form_skin(:my_skin, 'dsfH67PO', 'Dfs*7uUln9')


152
153
154
# File 'lib/adyen/configuration.rb', line 152

def register_form_skin(name, skin_code, shared_secret, default_form_params = {})
  @form_skins[name.to_sym] = { :name => name.to_sym, :skin_code => skin_code, :shared_secret => shared_secret, :default_form_params => default_form_params}
end