Class: Datatrans::Config
- Inherits:
-
Object
- Object
- Datatrans::Config
- Defined in:
- lib/datatrans/config.rb
Constant Summary collapse
- ENVIRONMENTS =
[:development, :production].freeze
- DEFAULT_ENVIRONMENT =
:development
- DEFAULT_SIGN_KEY =
false
- BASE_URL_PRODUCTION =
'https://payment.datatrans.biz'.freeze
- BASE_URL_DEVELOPMENT =
'https://pilot.datatrans.biz'.freeze
- URLS =
{ :development => { :web_authorize_url => "#{BASE_URL_DEVELOPMENT}/upp/jsp/upStart.jsp".freeze, :xml_authorize_url => "#{BASE_URL_DEVELOPMENT}/upp/jsp/XML_authorize.jsp".freeze, :xml_settlement_url => "#{BASE_URL_DEVELOPMENT}/upp/jsp/XML_processor.jsp".freeze, :xml_status_url => "#{BASE_URL_DEVELOPMENT}/upp/jsp/XML_status.jsp".freeze, }, :production => { :web_authorize_url => "#{BASE_URL_PRODUCTION}/upp/jsp/upStart.jsp".freeze, :xml_authorize_url => "#{BASE_URL_PRODUCTION}/upp/jsp/XML_authorize.jsp".freeze, :xml_settlement_url => "#{BASE_URL_PRODUCTION}/upp/jsp/XML_processor.jsp".freeze, :xml_status_url => "#{BASE_URL_PRODUCTION}/upp/jsp/XML_status.jsp".freeze, }.freeze }.freeze
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#sign_key ⇒ Object
readonly
Returns the value of attribute sign_key.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
Configure with following options * :merchant_id (required) * :sign_key (defaults to false) * :environment (defaults to :development, available environments are defined in ENVIRONMENTS) * :proxy (a hash containing :http_proxyaddr, :http_proxyport, :http_proxyuser, :http_proxypass).
-
#url(what) ⇒ Object
Access a url, is automatically scoped to environment.
- #web_transaction(*args) ⇒ Object
- #xml_transaction(*args) ⇒ Object
Constructor Details
permalink #initialize(options = {}) ⇒ Config
Configure with following options
-
:merchant_id (required)
-
:sign_key (defaults to false)
-
:environment (defaults to :development, available environments are defined in ENVIRONMENTS)
-
:proxy (a hash containing :http_proxyaddr, :http_proxyport, :http_proxyuser, :http_proxypass)
33 34 35 36 37 38 39 |
# File 'lib/datatrans/config.rb', line 33 def initialize( = {}) @merchant_id = [:merchant_id] raise ArgumentError.new(":merchant_id is required") unless self.merchant_id self.environment = [:environment] || DEFAULT_ENVIRONMENT @sign_key = [:sign_key] || DEFAULT_SIGN_KEY @proxy = [:proxy] || {} end |
Instance Attribute Details
permalink #environment ⇒ Object
Returns the value of attribute environment.
26 27 28 |
# File 'lib/datatrans/config.rb', line 26 def environment @environment end |
permalink #merchant_id ⇒ Object (readonly)
Returns the value of attribute merchant_id.
26 27 28 |
# File 'lib/datatrans/config.rb', line 26 def merchant_id @merchant_id end |
permalink #proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
26 27 28 |
# File 'lib/datatrans/config.rb', line 26 def proxy @proxy end |
permalink #sign_key ⇒ Object (readonly)
Returns the value of attribute sign_key.
26 27 28 |
# File 'lib/datatrans/config.rb', line 26 def sign_key @sign_key end |
Instance Method Details
permalink #url(what) ⇒ Object
Access a url, is automatically scoped to environment
51 52 53 |
# File 'lib/datatrans/config.rb', line 51 def url(what) URLS[self.environment][what] end |
permalink #web_transaction(*args) ⇒ Object
[View source]
55 56 57 |
# File 'lib/datatrans/config.rb', line 55 def web_transaction(*args) Web::Transaction.new(self, *args) end |
permalink #xml_transaction(*args) ⇒ Object
[View source]
59 60 61 |
# File 'lib/datatrans/config.rb', line 59 def xml_transaction(*args) XML::Transaction.new(self, *args) end |