Included Modules

Class Index [+]

Quicksearch

ActiveMerchant::Billing::Integrations::Nochex::Notification

Parser and handler for incoming Automatic Payment Confirmations from Nochex.

Public Instance Methods

acknowledge() click to toggle source

Acknowledge the transaction to Nochex. This method has to be called after a new apc arrives. Nochex will verify that all the information we received are correct and will return a ok or a fail. This is very similar to the PayPal IPN scheme.

Example:

  def nochex_ipn
    notify = NochexNotification.new(request.raw_post)

    if notify.acknowledge 
      ... process order ... if notify.complete?
    else
      ... log possible hacking attempt ...
    end
    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 77
77:           def acknowledge
78:              payload =  raw
79: 
80:              response = ssl_post(Nochex.notification_confirmation_url, payload, 
81:                'Content-Length' => "#{payload.size}",
82:                'User-Agent'     => "Active Merchant -- http://activemerchant.org",
83:                'Content-Type'   => "application/x-www-form-urlencoded"
84:              )
85: 
86:              raise StandardError.new("Faulty Nochex result: #{response}") unless ["AUTHORISED", "DECLINED"].include?(response)
87: 
88:              response == "AUTHORISED"
89:           end
complete?() click to toggle source
    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 12
12:           def complete?
13:             status == 'Completed'
14:           end
currency() click to toggle source
    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 25
25:           def currency
26:             'GBP'
27:           end
gross() click to toggle source

the money amount we received in X.2 decimal.

    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 50
50:           def gross
51:             sprintf("%.2f", params['amount'].to_f)
52:           end
item_id() click to toggle source

Id of the order we passed to Nochex

    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 17
17:           def item_id
18:             params['order_id']
19:           end
payer_email() click to toggle source
    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 37
37:           def payer_email
38:             params['from_email']
39:           end
received_at() click to toggle source

When was this payment received by the client.

    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 30
30:           def received_at
31:             # U.K. Format: 27/09/2006 22:30:54
32:             return if params['transaction_date'].blank?
33:             time = params['transaction_date'].scan(/\d+/)
34:             Time.utc(time[2], time[1], time[0], time[3], time[4], time[5])
35:           end
receiver_email() click to toggle source
    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 41
41:           def receiver_email
42:             params['to_email']
43:           end
security_key() click to toggle source
    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 45
45:           def security_key
46:             params['security_key']
47:           end
status() click to toggle source
    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 59
59:           def status
60:             'Completed'
61:           end
test?() click to toggle source

Was this a test transaction?

    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 55
55:           def test?
56:             params['status'] == 'test'
57:           end
transaction_id() click to toggle source
    # File lib/active_merchant/billing/integrations/nochex/notification.rb, line 21
21:           def transaction_id
22:             params['transaction_id']
23:           end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.