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

Returns a new instance of Configuration.



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.

Returns:

  • (String)


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]+’

Returns:

  • (String)


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.

Returns:

  • (String)


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'

Returns:

  • (Hash)


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'

Returns:

  • (Hash)


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.

Returns:

  • (String)


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.

Returns:

  • (Hash)

    The hash of registered skins.



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.

Returns:

  • (String)


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.

Returns:

  • (String)


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

Returns:

  • (String)


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

Returns:

  • (String)


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.

Returns:

  • ('test', 'live')

    The Adyen environment that corresponds to the Rails environment



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.

Parameters:

  • override ('test', 'live') (defaults to: nil)

    An environment to override the default with.

Returns:

  • ('test', 'live')

    The Adyen environment that is currently being used.



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.

Parameters:

  • env ('test', 'live')

    The Adyen environment to use



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.

Parameters:

  • skin_code (String)

    The code of the skin.

Returns:

  • (Hash, nil)

    A hash with the skin information, or nil if not found.



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.

Parameters:

  • skin_name (Symbol)

    The name of the skin

Returns:

  • (Hash, nil)

    A hash with the skin information, or nil if not found.



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.

Parameters:

  • skin_code (String)

    The skin code of the skin

Returns:

  • (String, nil)

    The shared secret for the skin, or nil if not found.



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')

Parameters:

  • name (Symbol)

    The name of the skin.

  • skin_code (String)

    The skin code for this skin, as defined by Adyen.

  • shared_secret (String)

    The shared secret used for signature calculation.



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