class Transbank::Onepay::Base

Constants

DEFAULT_API_KEY
DEFAULT_CALLBACK

The base class for Transbank Onepay

DEFAULT_SHARED_SECRET

Attributes

api_key[W]

Your Api key, given by Transbank @return [String]

app_scheme[W]

The URI for the app (eg the Android Intent that starts the app/the iOS equivalent) @param [String] @return [String]

callback_url[RW]

Your callback URL, used to resume the payment process after validating with Transbank when paying on Channel::MOBILE @param [String] @return [String]

commerce_logo_url[RW]

The url of the commerce logo to be displayed in the Onepay mobile app. @param [String] @return [String]

default_channel[R]

The default channel. Value must be in Channel.values @return [String] One of the values from Channel.values

integration_type[R]

The current integration type @param [String, Symbol] @return [Symbol]

integration_types[R]

Contains all valid integration types @return [Hash<String, String>]

qr_width_height[RW]

The width and height in pixels for the returned QR. @param [Integer] @return [Integer]

shared_secret[W]

Your shared secret, given by Transbank @param [String] @return [String]

Public Class Methods

api_key() click to toggle source
# 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_scheme() click to toggle source

Returns the app_scheme @return [String] the app scheme, either the one set on @app_scheme or, failing that, the value of ENV (your env variable)

# File lib/transbank/sdk/onepay/base.rb, line 91
def app_scheme
  return ENV['ONEPAY_APP_SCHEME'] unless @app_scheme
  @app_scheme
end
current_integration_type_app_key() click to toggle source

@return [String] the app key used by the current integration type

# File lib/transbank/sdk/onepay/base.rb, line 74
def current_integration_type_app_key
  @app_keys[@integration_type]
end
current_integration_type_url() click to toggle source

@return [String] the URL that is used by the current integration type

# File lib/transbank/sdk/onepay/base.rb, line 69
def current_integration_type_url
  @integration_types[@integration_type]
end
default_api_key() click to toggle source

Returns the 'ONEPAY_API_KEY' env variable, or, if ONEPAY_API_KEY doesn't exist, returns a default api key @return [String] ENV or DEFAULT_API_KEY

# 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_secret() click to toggle source

Returns the 'ONEPAY_SHARED_SECRET' env variable, or, if ONEPAY_SHARED_SECRET doesn't exist, returns a default shared secret @return [String] ENV or DEFAULT_SHARED_SECRET

# 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
integration_type=(type) click to toggle source

Sets the current integration type @param type [String] Type of integration to be set. Must be included one of the keys of self.integration_types @raise [IntegrationTypeError] if the given type is not valid

# File lib/transbank/sdk/onepay/base.rb, line 82
def integration_type=(type)
  return @integration_type = type.to_sym unless @integration_types[type.to_sym].nil?
  valid_values = @integration_types.keys.join(', ')
  raise Transbank::Onepay::Errors::IntegrationTypeError, "Invalid integration type, valid values are #{valid_values}"
end
shared_secret() click to toggle source
# File lib/transbank/sdk/onepay/base.rb, line 109
def shared_secret
  return ENV['ONEPAY_SHARED_SECRET'] if @shared_secret.nil?
  @shared_secret
end