Class: Cybersourcery::Profile
- Inherits:
-
Object
- Object
- Cybersourcery::Profile
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/cybersourcery/profile.rb
Constant Summary collapse
- VALID_ENDPOINTS =
{ standard: '/silent/pay', create_payment_token: '/silent/token/create', update_payment_token: '/silent/token/update', iframe_standard: '/silent/embedded/pay', iframe_create_payment_token: 'silent/embedded/token/create', iframe_update_payment_token: '/silent/embedded/token/update' }
Instance Attribute Summary collapse
-
#access_key ⇒ Object
Returns the value of attribute access_key.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#endpoint_type ⇒ Object
Returns the value of attribute endpoint_type.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#name ⇒ Object
Returns the value of attribute name.
-
#payment_method ⇒ Object
Returns the value of attribute payment_method.
-
#profile_id ⇒ Object
Returns the value of attribute profile_id.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
-
#service ⇒ Object
Returns the value of attribute service.
-
#success_url ⇒ Object
Returns the value of attribute success_url.
-
#transaction_type ⇒ Object
Returns the value of attribute transaction_type.
-
#unsigned_field_names ⇒ Object
Returns the value of attribute unsigned_field_names.
Instance Method Summary collapse
-
#initialize(profile_id, profiles = Cybersourcery.configuration.profiles) ⇒ Profile
constructor
A new instance of Profile.
- #transaction_url(proxy_url = ENV['CYBERSOURCERY_SOP_PROXY_URL'], env = Rails.env) ⇒ Object
Constructor Details
#initialize(profile_id, profiles = Cybersourcery.configuration.profiles) ⇒ Profile
Returns a new instance of Profile.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cybersourcery/profile.rb', line 27 def initialize(profile_id, profiles = Cybersourcery.configuration.profiles) profiles[profile_id].each do |k,v| self.send "#{k}=", v end @profile_id = profile_id @endpoint_type = @endpoint_type.to_sym unless self.valid? raise Cybersourcery::CybersourceryError, self.errors..to_sentence end end |
Instance Attribute Details
#access_key ⇒ Object
Returns the value of attribute access_key.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def access_key @access_key end |
#currency ⇒ Object
Returns the value of attribute currency.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def currency @currency end |
#endpoint_type ⇒ Object
Returns the value of attribute endpoint_type.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def endpoint_type @endpoint_type end |
#locale ⇒ Object
Returns the value of attribute locale.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def locale @locale end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def name @name end |
#payment_method ⇒ Object
Returns the value of attribute payment_method.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def payment_method @payment_method end |
#profile_id ⇒ Object
Returns the value of attribute profile_id.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def profile_id @profile_id end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def secret_key @secret_key end |
#service ⇒ Object
Returns the value of attribute service.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def service @service end |
#success_url ⇒ Object
Returns the value of attribute success_url.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def success_url @success_url end |
#transaction_type ⇒ Object
Returns the value of attribute transaction_type.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def transaction_type @transaction_type end |
#unsigned_field_names ⇒ Object
Returns the value of attribute unsigned_field_names.
17 18 19 |
# File 'lib/cybersourcery/profile.rb', line 17 def unsigned_field_names @unsigned_field_names end |
Instance Method Details
#transaction_url(proxy_url = ENV['CYBERSOURCERY_SOP_PROXY_URL'], env = Rails.env) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cybersourcery/profile.rb', line 40 def transaction_url(proxy_url = ENV['CYBERSOURCERY_SOP_PROXY_URL'], env = Rails.env) if env == 'test' && proxy_url.present? "#{proxy_url}#{VALID_ENDPOINTS[@endpoint_type]}" elsif env == 'test' && proxy_url.blank? "#{Cybersourcery.configuration.sop_test_url}#{VALID_ENDPOINTS[@endpoint_type]}" elsif @service == 'test' "#{Cybersourcery.configuration.sop_test_url}#{VALID_ENDPOINTS[@endpoint_type]}" elsif @service == 'live' "#{Cybersourcery.configuration.sop_live_url}#{VALID_ENDPOINTS[@endpoint_type]}" else raise Cybersourcery::CybersourceryError, 'Invalid conditions for determining the transaction_url' end end |