Class: ActiveMerchant::Billing::Integrations::Nelnet::Notification

Inherits:
ActiveMerchant::Billing::Integrations::Notification show all
Defined in:
lib/active_merchant/billing/integrations/nelnet/notification.rb

Instance Attribute Summary

Attributes inherited from ActiveMerchant::Billing::Integrations::Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from ActiveMerchant::Billing::Integrations::Notification

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

Constructor Details

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

Instance Method Details

#acknowledgeObject

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

Example:

def ipn
  notify = NelnetNotification.new(request.raw_post)

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

Raises:

  • (StandardError)


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 65

def acknowledge
  payload = raw

  uri = URI.parse(Nelnet.notification_confirmation_url)

  request = Net::HTTP::Post.new(uri.path)

  request['Content-Length'] = "#{payload.size}"
  request['User-Agent'] = "Active Merchant -- http://home.leetsoft.com/am"
  request['Content-Type'] = "application/x-www-form-urlencoded"

  http = Net::HTTP.new(uri.host, uri.port)
  http.verify_mode    = OpenSSL::SSL::VERIFY_NONE unless @ssl_strict
  http.use_ssl        = true

  response = http.request(request, payload)

  # Replace with the appropriate codes
  raise StandardError.new("Faulty Nelnet result: #{response.body}") unless ["AUTHORISED", "DECLINED"].include?(response.body)
  response.body == "AUTHORISED"
end

#complete?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 8

def complete?
  params['']
end

#grossObject

the money amount we received in X.2 decimal.



38
39
40
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 38

def gross
  params['']
end

#item_idObject



12
13
14
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 12

def item_id
  params['']
end

#payer_emailObject



25
26
27
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 25

def payer_email
  params['']
end

#received_atObject

When was this payment received by the client.



21
22
23
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 21

def received_at
  params['']
end

#receiver_emailObject



29
30
31
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 29

def receiver_email
  params['']
end

#security_keyObject



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

def security_key
  params['']
end

#statusObject



47
48
49
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 47

def status
  params['']
end

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


43
44
45
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 43

def test?
  params[''] == 'test'
end

#transaction_idObject



16
17
18
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 16

def transaction_id
  params['']
end