Class: Liqpay::Response

Inherits:
BaseOperation show all
Defined in:
lib/liqpay/response.rb

Constant Summary collapse

SUCCESS_STATUSES =
%w(success wait_secure)
ATTRIBUTES =
%w(public_key order_id amount currency description type status transaction_id sender_phone)

Instance Attribute Summary collapse

Attributes inherited from BaseOperation

#private_key, #public_key

Instance Method Summary collapse

Methods inherited from BaseOperation

#signature

Constructor Details

#initialize(params = {}, options = {}) ⇒ Response

Returns a new instance of Response.



27
28
29
30
31
32
33
34
35
36
# File 'lib/liqpay/response.rb', line 27

def initialize(params = {}, options = {})
  super(options)

  ATTRIBUTES.each do |attribute|
    instance_variable_set "@#{attribute}", params[attribute]
  end
  @request_signature = params["signature"]

  decode!
end

Instance Attribute Details

#amountObject (readonly)

Amount of payment. MUST match the requested amount



14
15
16
# File 'lib/liqpay/response.rb', line 14

def amount
  @amount
end

#currencyObject (readonly)

Currency of payment. MUST match the requested currency



16
17
18
# File 'lib/liqpay/response.rb', line 16

def currency
  @currency
end

#sender_phoneObject (readonly)

Payer’s phone



25
26
27
# File 'lib/liqpay/response.rb', line 25

def sender_phone
  @sender_phone
end

#statusObject (readonly)

Status of payment. One of ‘

failure 
success
wait_secure - success, but the card wasn't known to the system


21
22
23
# File 'lib/liqpay/response.rb', line 21

def status
  @status
end

#transaction_idObject (readonly)

LiqPAY’s internal transaction ID



23
24
25
# File 'lib/liqpay/response.rb', line 23

def transaction_id
  @transaction_id
end

Instance Method Details

#signature_fieldsObject



43
44
45
# File 'lib/liqpay/response.rb', line 43

def signature_fields
  [amount, currency, public_key, order_id, type, description, status, transaction_id, sender_phone]
end

#success?Boolean

Returns true, if the transaction was successful

Returns:

  • (Boolean)


39
40
41
# File 'lib/liqpay/response.rb', line 39

def success?
  SUCCESS_STATUSES.include? self.status
end