Class: OffsitePayments::Integrations::Liqpay::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/offsite_payments/integrations/liqpay.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, #iso_currency, #test?, #valid_sender?

Constructor Details

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

Returns a new instance of Notification.

Raises:

  • (ArgumentError)


64
65
66
67
68
# File 'lib/offsite_payments/integrations/liqpay.rb', line 64

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)


60
61
62
# File 'lib/offsite_payments/integrations/liqpay.rb', line 60

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

Instance Method Details

#accountObject



78
79
80
# File 'lib/offsite_payments/integrations/liqpay.rb', line 78

def 
  params['merchant_id']
end

#acknowledge(authcode = nil) ⇒ Object



134
135
136
# File 'lib/offsite_payments/integrations/liqpay.rb', line 134

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

#action_nameObject



94
95
96
# File 'lib/offsite_payments/integrations/liqpay.rb', line 94

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

#amountObject



82
83
84
# File 'lib/offsite_payments/integrations/liqpay.rb', line 82

def amount
  Money.from_amount(BigDecimal(gross), currency)
end

#codeObject



122
123
124
# File 'lib/offsite_payments/integrations/liqpay.rb', line 122

def code
  params['code']
end

#complete?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/offsite_payments/integrations/liqpay.rb', line 74

def complete?
  status == 'success'
end

#currencyObject



114
115
116
# File 'lib/offsite_payments/integrations/liqpay.rb', line 114

def currency
  params['currency']
end

#generate_signatureObject



130
131
132
# File 'lib/offsite_payments/integrations/liqpay.rb', line 130

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

#generate_signature_stringObject



126
127
128
# File 'lib/offsite_payments/integrations/liqpay.rb', line 126

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

#grossObject



110
111
112
# File 'lib/offsite_payments/integrations/liqpay.rb', line 110

def gross
  params['amount']
end

#item_idObject



86
87
88
# File 'lib/offsite_payments/integrations/liqpay.rb', line 86

def item_id
  params['order_id']
end

#security_keyObject



106
107
108
# File 'lib/offsite_payments/integrations/liqpay.rb', line 106

def security_key
  params[OffsitePayments::Integrations::Liqpay.signature_parameter_name]
end

#sender_phoneObject



102
103
104
# File 'lib/offsite_payments/integrations/liqpay.rb', line 102

def sender_phone
  params['sender_phone']
end

#statusObject



118
119
120
# File 'lib/offsite_payments/integrations/liqpay.rb', line 118

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

#transaction_idObject



90
91
92
# File 'lib/offsite_payments/integrations/liqpay.rb', line 90

def transaction_id
  params['transaction_id']
end

#versionObject



98
99
100
# File 'lib/offsite_payments/integrations/liqpay.rb', line 98

def version
  params['version']
end

#xmlObject



70
71
72
# File 'lib/offsite_payments/integrations/liqpay.rb', line 70

def xml
  @params["operation_xml"]
end