Class: Transbank::Onepay::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/transbank/sdk/onepay/base.rb

Constant Summary collapse

DEFAULT_CALLBACK =

The base class for Transbank Onepay

"http://no.callback.has/been.set".freeze
DEFAULT_API_KEY =
'dKVhq1WGt_XapIYirTXNyUKoWTDFfxaEV63-O5jcsdw'.freeze
DEFAULT_SHARED_SECRET =
'?XW#WOLG##FBAGEAYSNQ5APD#JF@$AYZ'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject



96
97
98
99
# File 'lib/transbank/sdk/onepay/base.rb', line 96

def api_key
  return ENV['ONEPAY_API_KEY'] if @api_key.nil?
  @api_key
end

.app_schemeString

Returns the app_scheme failing that, the value of ENV (your env variable)

Returns:

  • (String)

    the app scheme, either the one set on @app_scheme or,



91
92
93
94
# File 'lib/transbank/sdk/onepay/base.rb', line 91

def app_scheme
  return ENV['ONEPAY_APP_SCHEME'] unless @app_scheme
  @app_scheme
end

.callback_urlString

Your callback URL, used to resume the payment process after validating with Transbank when paying on Channel::MOBILE

Parameters:

  • (String)

Returns:

  • (String)


36
37
38
# File 'lib/transbank/sdk/onepay/base.rb', line 36

def callback_url
  @callback_url
end

.commerce_logo_urlString

The url of the commerce logo to be displayed in the Onepay mobile app.

Parameters:

  • (String)

Returns:

  • (String)


66
67
68
# File 'lib/transbank/sdk/onepay/base.rb', line 66

def commerce_logo_url
  @commerce_logo_url
end

.default_channelString (readonly)

The default channel. Value must be in Channel.values

Returns:

  • (String)

    One of the values from Channel.values



56
57
58
# File 'lib/transbank/sdk/onepay/base.rb', line 56

def default_channel
  @default_channel
end

.integration_typeSymbol

The current integration type

Parameters:

  • (String, Symbol)

Returns:

  • (Symbol)


46
47
48
# File 'lib/transbank/sdk/onepay/base.rb', line 46

def integration_type
  @integration_type
end

.integration_typesHash<String, String> (readonly)

Contains all valid integration types

Returns:

  • (Hash<String, String>)


26
27
28
# File 'lib/transbank/sdk/onepay/base.rb', line 26

def integration_types
  @integration_types
end

.qr_width_heightInteger

The width and height in pixels for the returned QR.

Parameters:

  • (Integer)

Returns:

  • (Integer)


61
62
63
# File 'lib/transbank/sdk/onepay/base.rb', line 61

def qr_width_height
  @qr_width_height
end

.shared_secretObject



109
110
111
112
# File 'lib/transbank/sdk/onepay/base.rb', line 109

def shared_secret
  return ENV['ONEPAY_SHARED_SECRET'] if @shared_secret.nil?
  @shared_secret
end

Class Method Details

.current_integration_type_app_keyString

Returns the app key used by the current integration type.

Returns:

  • (String)

    the app key used by the current integration type



74
75
76
# File 'lib/transbank/sdk/onepay/base.rb', line 74

def current_integration_type_app_key
  @app_keys[@integration_type]
end

.current_integration_type_urlString

Returns the URL that is used by the current integration type.

Returns:

  • (String)

    the URL that is used by the current integration type



69
70
71
# File 'lib/transbank/sdk/onepay/base.rb', line 69

def current_integration_type_url
  @integration_types[@integration_type]
end

.default_api_keyString

Returns the ‘ONEPAY_API_KEY’ env variable, or, if ONEPAY_API_KEY doesn’t exist, returns a default api key

Returns:

  • (String)

    ENV or DEFAULT_API_KEY



104
105
106
107
# File 'lib/transbank/sdk/onepay/base.rb', line 104

def default_api_key
  env_api_key = ENV['ONEPAY_API_KEY']
  env_api_key.nil? ? DEFAULT_API_KEY : env_api_key
end

.default_shared_secretString

Returns the ‘ONEPAY_SHARED_SECRET’ env variable, or, if ONEPAY_SHARED_SECRET doesn’t exist, returns a default shared secret

Returns:

  • (String)

    ENV or DEFAULT_SHARED_SECRET



117
118
119
120
# File 'lib/transbank/sdk/onepay/base.rb', line 117

def default_shared_secret
  env_shared_secret = ENV['ONEPAY_SHARED_SECRET']
  env_shared_secret.nil? ? DEFAULT_SHARED_SECRET : env_shared_secret
end