Class: ActiveMerchant::Billing::Integrations::WirecardCheckoutPage::Notification

Inherits:
Notification
  • Object
show all
Includes:
Common
Defined in:
lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.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, #valid_sender?

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::Integrations::Notification

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args) ⇒ Object



83
84
85
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 83

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


71
72
73
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 71

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

#complete?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 10

def complete?
  @paymentstate == 'SUCCESS'
end

#grossObject

the money amount we received in X.2 decimal.



28
29
30
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 28

def gross
  params['amount']
end

#item_idObject



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

def item_id
  params['xActiveMerchantOrderId']
end

#received_atObject

When was this payment received by the client.



23
24
25
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 23

def received_at
  nil
end

#response(umessage = nil) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 75

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



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 37

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

#status_codeObject



52
53
54
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 52

def status_code
  @paymentstate
end

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


33
34
35
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb', line 33

def test?
  false
end

#transaction_idObject



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

def transaction_id
  params['orderNumber']
end