Class: Braspag::Connection
- Inherits:
-
Object
- Object
- Braspag::Connection
- Includes:
- Singleton
- Defined in:
- lib/rbraspag/errors.rb,
lib/rbraspag/connection.rb
Defined Under Namespace
Classes: InvalidBraspagUrl, InvalidEnv, InvalidMerchantId
Constant Summary collapse
- PRODUCTION_URL =
"https://transaction.pagador.com.br"
- HOMOLOGATION_URL =
"https://homologacao.pagador.com.br"
Instance Attribute Summary collapse
-
#braspag_url ⇒ Object
readonly
Returns the value of attribute braspag_url.
-
#crypto_key ⇒ Object
readonly
Returns the value of attribute crypto_key.
-
#crypto_url ⇒ Object
readonly
Returns the value of attribute crypto_url.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #homologation? ⇒ Boolean
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
- #production? ⇒ Boolean
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rbraspag/connection.rb', line 10 def initialize raise InvalidEnv if ENV["RACK_ENV"].nil? || ENV["RACK_ENV"].empty? @options = YAML.load_file('config/braspag.yml')[ ENV['RACK_ENV'] ] @merchant_id = @options['merchant_id'] raise InvalidMerchantId unless @merchant_id =~ /\{[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}\}/i @crypto_key = @options["crypto_key"] @crypto_url = @options["crypto_url"] @environment = @options["environment"] == 'production' ? 'production' : 'homologation' @braspag_url = self.production? ? PRODUCTION_URL : HOMOLOGATION_URL end |
Instance Attribute Details
#braspag_url ⇒ Object (readonly)
Returns the value of attribute braspag_url.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def braspag_url @braspag_url end |
#crypto_key ⇒ Object (readonly)
Returns the value of attribute crypto_key.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def crypto_key @crypto_key end |
#crypto_url ⇒ Object (readonly)
Returns the value of attribute crypto_url.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def crypto_url @crypto_url end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def environment @environment end |
#merchant_id ⇒ Object (readonly)
Returns the value of attribute merchant_id.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def merchant_id @merchant_id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def @options end |
Instance Method Details
#homologation? ⇒ Boolean
29 30 31 |
# File 'lib/rbraspag/connection.rb', line 29 def homologation? @environment == 'homologation' end |
#production? ⇒ Boolean
25 26 27 |
# File 'lib/rbraspag/connection.rb', line 25 def production? @environment == 'production' end |