Class: Alma::PaymentResponse
- Inherits:
-
Object
- Object
- Alma::PaymentResponse
- Defined in:
- lib/alma/payment_response.rb
Instance Method Summary collapse
- #error_message ⇒ Object
- #has_payment_error? ⇒ Boolean
-
#initialize(response) ⇒ PaymentResponse
constructor
A new instance of PaymentResponse.
- #loggable ⇒ Object
- #paid? ⇒ Boolean
- #payment_message ⇒ Object
Constructor Details
#initialize(response) ⇒ PaymentResponse
Returns a new instance of PaymentResponse.
5 6 7 8 9 |
# File 'lib/alma/payment_response.rb', line 5 def initialize(response) @raw_response = response @response = response.parsed_response @success = response["total_sum"] == 0.0 end |
Instance Method Details
#error_message ⇒ Object
32 33 34 |
# File 'lib/alma/payment_response.rb', line 32 def @response unless paid? end |
#has_payment_error? ⇒ Boolean
20 21 22 |
# File 'lib/alma/payment_response.rb', line 20 def has_payment_error? !paid? end |
#loggable ⇒ Object
11 12 13 14 |
# File 'lib/alma/payment_response.rb', line 11 def loggable { uri: @raw_response&.request&.uri.to_s }.select { |k, v| !(v.nil? || v.empty?) } end |
#paid? ⇒ Boolean
16 17 18 |
# File 'lib/alma/payment_response.rb', line 16 def paid? @success end |
#payment_message ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/alma/payment_response.rb', line 24 def if paid? "Your balance has been paid." else "There was a problem processing your payment. Please contact the library for assistance." end end |