Class: ActiveMerchant::Billing::Integrations::Liqpay::Return

Inherits:
Return
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/liqpay/return.rb

Instance Attribute Summary

Attributes inherited from Return

#notification, #params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Return

#cancelled?, #message, #parse, #success?

Constructor Details

#initialize(post) ⇒ Return

Returns a new instance of Return.



10
11
12
13
14
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 10

def initialize(post)
  super
  xml = Base64.decode64(@params["operation_xml"])
  @params.merge!(Hash.from_xml(xml)["response"])
end

Class Method Details

.recognizes?(params) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 6

def self.recognizes?(params)
  params.has_key?('amount') && params.has_key?('order_id')
end

Instance Method Details

#accountObject



20
21
22
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 20

def 
  params['merchant_id']
end

#acknowledgeObject



76
77
78
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 76

def acknowledge
  security_key == generate_signature
end

#action_nameObject



36
37
38
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 36

def action_name
  params['action_name'] # either 'result_url' or 'server_url'
end

#amountObject



24
25
26
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 24

def amount
  BigDecimal.new(gross)
end

#codeObject



64
65
66
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 64

def code
  params['code']
end

#complete?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 16

def complete?
  status == 'success'
end

#currencyObject



56
57
58
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 56

def currency
  params['currency']
end

#generate_signatureObject



72
73
74
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 72

def generate_signature
  Base64.encode64(Digest::SHA1.digest(generate_signature_string)).gsub(/\n/, '')
end

#generate_signature_stringObject



68
69
70
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 68

def generate_signature_string
  ['', version, @options[:secret], action_name, sender_phone, , gross, currency, item_id, transaction_id, status, code, ''].flatten.compact.join('|')
end

#grossObject



52
53
54
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 52

def gross
  params['amount']
end

#item_idObject



28
29
30
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 28

def item_id
  params['order_id']
end

#security_keyObject



48
49
50
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 48

def security_key
  params[ActiveMerchant::Billing::Integrations::Liqpay.signature_parameter_name]
end

#sender_phoneObject



44
45
46
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 44

def sender_phone
  params['sender_phone']
end

#statusObject



60
61
62
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 60

def status
  params['status'] # 'success', 'failure' or 'wait_secure'
end

#transaction_idObject



32
33
34
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 32

def transaction_id
  params['transaction_id']
end

#versionObject



40
41
42
# File 'lib/active_merchant/billing/integrations/liqpay/return.rb', line 40

def version
  params['version']
end