Class: OffsitePayments::Integrations::Liqpay::Return

Inherits:
Return
  • Object
show all
Defined in:
lib/offsite_payments/integrations/liqpay.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.



144
145
146
147
148
# File 'lib/offsite_payments/integrations/liqpay.rb', line 144

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)


140
141
142
# File 'lib/offsite_payments/integrations/liqpay.rb', line 140

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

Instance Method Details

#accountObject



154
155
156
# File 'lib/offsite_payments/integrations/liqpay.rb', line 154

def 
  params['merchant_id']
end

#acknowledge(authcode = nil) ⇒ Object



210
211
212
# File 'lib/offsite_payments/integrations/liqpay.rb', line 210

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

#action_nameObject



170
171
172
# File 'lib/offsite_payments/integrations/liqpay.rb', line 170

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

#amountObject



158
159
160
# File 'lib/offsite_payments/integrations/liqpay.rb', line 158

def amount
  BigDecimal(gross)
end

#codeObject



198
199
200
# File 'lib/offsite_payments/integrations/liqpay.rb', line 198

def code
  params['code']
end

#complete?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/offsite_payments/integrations/liqpay.rb', line 150

def complete?
  status == 'success'
end

#currencyObject



190
191
192
# File 'lib/offsite_payments/integrations/liqpay.rb', line 190

def currency
  params['currency']
end

#generate_signatureObject



206
207
208
# File 'lib/offsite_payments/integrations/liqpay.rb', line 206

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

#generate_signature_stringObject



202
203
204
# File 'lib/offsite_payments/integrations/liqpay.rb', line 202

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

#grossObject



186
187
188
# File 'lib/offsite_payments/integrations/liqpay.rb', line 186

def gross
  params['amount']
end

#item_idObject



162
163
164
# File 'lib/offsite_payments/integrations/liqpay.rb', line 162

def item_id
  params['order_id']
end

#security_keyObject



182
183
184
# File 'lib/offsite_payments/integrations/liqpay.rb', line 182

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

#sender_phoneObject



178
179
180
# File 'lib/offsite_payments/integrations/liqpay.rb', line 178

def sender_phone
  params['sender_phone']
end

#statusObject



194
195
196
# File 'lib/offsite_payments/integrations/liqpay.rb', line 194

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

#transaction_idObject



166
167
168
# File 'lib/offsite_payments/integrations/liqpay.rb', line 166

def transaction_id
  params['transaction_id']
end

#versionObject



174
175
176
# File 'lib/offsite_payments/integrations/liqpay.rb', line 174

def version
  params['version']
end