Class: ActiveMerchant::Billing::Integrations::Liqpay::Notification
- Inherits:
-
Notification
- Object
- Notification
- ActiveMerchant::Billing::Integrations::Liqpay::Notification
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
#empty!, #gross_cents, #test?, #valid_sender?
Constructor Details
#initialize(post, options = {}) ⇒ Notification
Returns a new instance of Notification.
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
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
#account ⇒ Object
26
27
28
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 26
def account
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_name ⇒ Object
42
43
44
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 42
def action_name
params['action_name'] end
|
#amount ⇒ Object
30
31
32
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 30
def amount
BigDecimal.new(gross)
end
|
#code ⇒ Object
70
71
72
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 70
def code
params['code']
end
|
#complete? ⇒ Boolean
22
23
24
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 22
def complete?
status == 'success'
end
|
#currency ⇒ Object
62
63
64
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 62
def currency
params['currency']
end
|
#generate_signature ⇒ Object
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_string ⇒ Object
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
|
#gross ⇒ Object
58
59
60
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 58
def gross
params['amount']
end
|
#item_id ⇒ Object
34
35
36
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 34
def item_id
params['order_id']
end
|
#sender_phone ⇒ Object
50
51
52
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 50
def sender_phone
params['sender_phone']
end
|
#status ⇒ Object
66
67
68
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 66
def status
params['status'] end
|
#transaction_id ⇒ Object
38
39
40
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 38
def transaction_id
params['transaction_id']
end
|
#version ⇒ Object
46
47
48
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 46
def version
params['version']
end
|
#xml ⇒ Object
18
19
20
|
# File 'lib/active_merchant/billing/integrations/liqpay/notification.rb', line 18
def xml
@params["operation_xml"]
end
|