| Class | ActiveMerchant::Billing::Integrations::Nochex::Notification |
| In: |
lib/active_merchant/billing/integrations/nochex/notification.rb
|
| Parent: | ActiveMerchant::Billing::Integrations::Notification |
Parser and handler for incoming Automatic Payment Confirmations from Nochex.
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
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 12
12: def complete?
13: status == 'Completed'
14: end
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 25
25: def currency
26: 'GBP'
27: end
the money amount we received in X.2 decimal.
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 50
50: def gross
51: params['amount']
52: end
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 37
37: def payer_email
38: params['from_email']
39: end
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
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 41
41: def receiver_email
42: params['to_email']
43: end
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 45
45: def security_key
46: params['security_key']
47: end
# File lib/active_merchant/billing/integrations/nochex/notification.rb, line 59
59: def status
60: 'Completed'
61: end
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