Class: Adyen::Configuration

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

Constant Summary

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
# File 'lib/adyen/configuration.rb', line 3

def initialize
  @default_api_params  = {}
  @default_form_params = {}
  @form_skins          = {}
  @payment_flow        = :select
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)


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

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 ‘+ws@AndyInc.SuperShop+’

Returns:

  • (String)


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

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)


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

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)


80
81
82
# File 'lib/adyen/configuration.rb', line 80

def default_api_params
  @default_api_params
end

#default_form_paramsHash

Default arguments that will be used for in every HTML form.

Examples:

Adyen.configuration.default_form_params[:shared_secret] = 'secret'

Returns:

  • (Hash)


94
95
96
# File 'lib/adyen/configuration.rb', line 94

def default_form_params
  @default_form_params
end

#form_skinsHash

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

Returns:

  • (Hash)

    The hash of registered skins.



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

def form_skins
  @form_skins
end

#ipn_passwordString

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

Returns:

  • (String)


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

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)


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

def ipn_username
  @ipn_username
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)


51
52
53
# File 'lib/adyen/configuration.rb', line 51

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)


59
60
61
# File 'lib/adyen/configuration.rb', line 59

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



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

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.



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

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



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

def environment=(env)
  @environment = env
end

#form_skin_by_code(skin_code) ⇒ Hash?

Returns skin information by code code.

Parameters:

  • skin_code (String)

    The code of the skin.

Returns:

  • (Hash, nil)

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



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

def form_skin_by_code(skin_code)
  if skin = @form_skins.detect { |(name, skin)| skin[:skin_code] == skin_code }
    skin.last
  end
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.



150
151
152
# File 'lib/adyen/configuration.rb', line 150

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.



170
171
172
173
174
# File 'lib/adyen/configuration.rb', line 170

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.



142
143
144
# File 'lib/adyen/configuration.rb', line 142

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