Class: ActiveMerchant::Billing::Integrations::Liqpay::Notification

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

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Notification

#empty!, #gross_cents, #test?, #valid_sender?

Constructor Details

#initialize(post, options = {}) ⇒ Notification

Returns a new instance of Notification.

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 12

def initialize(post, options = {})
  raise ArgumentError if post.blank?
  super
  @params.merge!(Hash.from_xml(Base64.decode64(xml))["response"])
end

Class Method Details

.recognizes?(params) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 8

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

Instance Method Details

#accountObject



26
27
28
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 26

def 
  params['merchant_id']
end

#acknowledge(authcode = nil) ⇒ Object



82
83
84
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 82

def acknowledge(authcode = nil)
  security_key == generate_signature
end

#action_nameObject



42
43
44
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 42

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

#amountObject



30
31
32
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 30

def amount
  BigDecimal.new(gross)
end

#codeObject



70
71
72
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 70

def code
  params['code']
end

#complete?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 22

def complete?
  status == 'success'
end

#currencyObject



62
63
64
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 62

def currency
  params['currency']
end

#generate_signatureObject



78
79
80
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 78

def generate_signature
  Base64.encode64(Digest::SHA1.digest(generate_signature_string)).strip
end

#generate_signature_stringObject



74
75
76
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 74

def generate_signature_string
  "#{@options[:secret]}#{Base64.decode64(xml)}#{@options[:secret]}"
end

#grossObject



58
59
60
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 58

def gross
  params['amount']
end

#item_idObject



34
35
36
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 34

def item_id
  params['order_id']
end

#security_keyObject



54
55
56
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 54

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

#sender_phoneObject



50
51
52
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 50

def sender_phone
  params['sender_phone']
end

#statusObject



66
67
68
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 66

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

#transaction_idObject



38
39
40
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 38

def transaction_id
  params['transaction_id']
end

#versionObject



46
47
48
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 46

def version
  params['version']
end

#xmlObject



18
19
20
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 18

def xml
  @params["operation_xml"]
end