Class: OffsitePayments::Integrations::WirecardCheckoutPage::Notification

Inherits:
Notification
  • Object
show all
Includes:
Common
Defined in:
lib/offsite_payments/integrations/wirecard_checkout_page.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods included from Common

#message, #verify_response

Methods inherited from Notification

#amount, #empty!, #gross_cents, #initialize, #iso_currency, #valid_sender?

Constructor Details

This class inherits a constructor from OffsitePayments::Notification

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args) ⇒ Object



316
317
318
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 316

def method_missing(method_id, *args)
  return params[method_id.to_s] if params.has_key?(method_id.to_s)
end

Instance Method Details

#acknowledgeObject

Acknowledge the transaction to WirecardCheckoutPage. This method has to be called after a new apc arrives. WirecardCheckoutPage will verify that all the information we received are correct and will return a ok or a fail.

Example:

def ipn
  notify = WirecardCheckoutPageNotification.new(request.raw_post, options)

  if notify.acknowledge
    ... process order ... if notify.complete?
  else
    ... log possible hacking attempt ...
  end


304
305
306
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 304

def acknowledge
  verify_response(params, @options[:secret])
end

#complete?Boolean

Returns:

  • (Boolean)


244
245
246
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 244

def complete?
  @paymentstate == 'SUCCESS'
end

#grossObject

the money amount we received in X.2 decimal.



262
263
264
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 262

def gross
  params['amount']
end

#item_idObject



248
249
250
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 248

def item_id
  params['xActiveMerchantOrderId']
end

#received_atObject

When was this payment received by the client.



257
258
259
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 257

def received_at
  nil
end

#response(umessage = nil) ⇒ Object



308
309
310
311
312
313
314
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 308

def response(umessage = nil)
  if @message || umessage
    '<QPAY-CONFIRMATION-RESPONSE result="NOK" message="' + CGI.escapeHTML(umessage ? umessage : @message) + '"/>'
  else
    '<QPAY-CONFIRMATION-RESPONSE result="OK"/>'
  end
end

#statusObject



271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 271

def status
  case @paymentstate
    when 'SUCCESS'
      'Completed'
    when 'PENDING'
      'Pending'
    when 'CANCEL'
      'Cancelled'
    when 'FAILURE'
      'Failed'
    else
      'Error'
  end
end

#status_codeObject



286
287
288
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 286

def status_code
  @paymentstate
end

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


267
268
269
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 267

def test?
  false
end

#transaction_idObject



252
253
254
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 252

def transaction_id
  params['orderNumber']
end