Class: SagePay::Server::NotificationResponse
- Inherits:
-
Object
- Object
- SagePay::Server::NotificationResponse
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/sage_pay/server/notification_response.rb
Instance Attribute Summary collapse
-
#redirect_url ⇒ Object
Returns the value of attribute redirect_url.
-
#status ⇒ Object
Returns the value of attribute status.
-
#status_detail ⇒ Object
Returns the value of attribute status_detail.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ NotificationResponse
constructor
A new instance of NotificationResponse.
- #ok? ⇒ Boolean
- #response ⇒ Object
- #response_params ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ NotificationResponse
Returns a new instance of NotificationResponse.
16 17 18 19 20 |
# File 'lib/sage_pay/server/notification_response.rb', line 16 def initialize(attributes = {}) attributes.each do |k, v| send("#{k}=", v) end end |
Instance Attribute Details
#redirect_url ⇒ Object
Returns the value of attribute redirect_url.
6 7 8 |
# File 'lib/sage_pay/server/notification_response.rb', line 6 def redirect_url @redirect_url end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/sage_pay/server/notification_response.rb', line 6 def status @status end |
#status_detail ⇒ Object
Returns the value of attribute status_detail.
6 7 8 |
# File 'lib/sage_pay/server/notification_response.rb', line 6 def status_detail @status_detail end |
Instance Method Details
#ok? ⇒ Boolean
22 23 24 |
# File 'lib/sage_pay/server/notification_response.rb', line 22 def ok? status == :ok end |
#response ⇒ Object
26 27 28 29 30 31 |
# File 'lib/sage_pay/server/notification_response.rb', line 26 def response response_params.map do |tuple| key, value = tuple "#{key}=#{value}" end.join("\r\n") end |
#response_params ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sage_pay/server/notification_response.rb', line 34 def response_params raise ArgumentError, "Invalid transaction registration options (see errors hash for details)" unless valid? # Mandatory parameters that we've already validated are present. Note # that the order of parameters is important (Status must be first!) so # we're using a list of lists this time around... params = [ ["Status", status.to_s.upcase], ["RedirectURL", redirect_url] ] # Optional parameters that are only inserted if they are present params << ['StatusDetail', status_detail] if status_detail.present? # And return the completed hash params end |