Included Modules

Class/Module 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
def acknowledge
   payload =  raw

   response = ssl_post(Nochex.notification_confirmation_url, payload, 
     'Content-Length' => "#{payload.size}",
     'User-Agent'     => "Active Merchant -- http://activemerchant.org",
     'Content-Type'   => "application/x-www-form-urlencoded"
   )

   raise StandardError.new("Faulty Nochex result: #{response}") unless ["AUTHORISED", "DECLINED"].include?(response)

   response == "AUTHORISED"
end
complete?() click to toggle source
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 12
def complete?
  status == 'Completed'
end
currency() click to toggle source
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 25
def currency
  'GBP'
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
def gross
  sprintf("%.2f", params['amount'].to_f)
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
def item_id
  params['order_id']
end
payer_email() click to toggle source
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 37
def payer_email
  params['from_email']
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
def received_at
  # U.K. Format: 27/09/2006 22:30:54
  return if params['transaction_date'].blank?
  time = params['transaction_date'].scan(/\d+/)
  Time.utc(time[2], time[1], time[0], time[3], time[4], time[5])
end
receiver_email() click to toggle source
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 41
def receiver_email
  params['to_email']
end
security_key() click to toggle source
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 45
def security_key
  params['security_key']
end
status() click to toggle source
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 59
def status
  'Completed'
end
test?() click to toggle source

Was this a test transaction?

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.