Class: Liqpay::Response
- Inherits:
-
SignedPayload
- Object
- SignedPayload
- Liqpay::Response
- Defined in:
- lib/liqpay/response.rb
Overview
Represents a response from the LiqPay API.
Constant Summary collapse
- SUCCESS_STATUSES =
%w[success wait_secure sandbox].freeze
- ATTRIBUTES =
%w[public_key order_id amount currency description type status transaction_id sender_phone].freeze
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Amount of payment.
-
#currency ⇒ Object
readonly
Currency of payment.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#sender_phone ⇒ Object
readonly
Payer’s phone.
-
#status ⇒ Object
readonly
Status of payment.
-
#transaction_id ⇒ Object
readonly
LiqPAY’s internal transaction ID.
Attributes inherited from SignedPayload
Instance Method Summary collapse
-
#initialize(params = {}, options = {}) ⇒ Response
constructor
A new instance of Response.
-
#success? ⇒ Boolean
Returns true, if the transaction was successful.
Methods inherited from SignedPayload
Constructor Details
#initialize(params = {}, options = {}) ⇒ Response
Returns a new instance of Response.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/liqpay/response.rb', line 33 def initialize(params = {}, = {}) super() @data = params['data'] parsed_data = JSON.parse(Base64.strict_decode64(data)) ATTRIBUTES.each do |attribute| instance_variable_set "@#{attribute}", parsed_data[attribute] end @request_signature = params['signature'] decode! end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Amount of payment. MUST match the requested amount
19 20 21 |
# File 'lib/liqpay/response.rb', line 19 def amount @amount end |
#currency ⇒ Object (readonly)
Currency of payment. MUST match the requested currency
21 22 23 |
# File 'lib/liqpay/response.rb', line 21 def currency @currency end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
16 17 18 |
# File 'lib/liqpay/response.rb', line 16 def data @data end |
#sender_phone ⇒ Object (readonly)
Payer’s phone
31 32 33 |
# File 'lib/liqpay/response.rb', line 31 def sender_phone @sender_phone end |
#status ⇒ Object (readonly)
Status of payment. One of ‘
failure
success
wait_secure - success, but the card wasn't known to the system
sandbox
27 28 29 |
# File 'lib/liqpay/response.rb', line 27 def status @status end |
#transaction_id ⇒ Object (readonly)
LiqPAY’s internal transaction ID
29 30 31 |
# File 'lib/liqpay/response.rb', line 29 def transaction_id @transaction_id end |
Instance Method Details
#success? ⇒ Boolean
Returns true, if the transaction was successful
48 49 50 |
# File 'lib/liqpay/response.rb', line 48 def success? SUCCESS_STATUSES.include? status end |