Class: ActiveMerchant::Billing::Integrations::Nelnet::Notification
- Inherits:
-
ActiveMerchant::Billing::Integrations::Notification
- Object
- ActiveMerchant::Billing::Integrations::Notification
- ActiveMerchant::Billing::Integrations::Nelnet::Notification
- Defined in:
- lib/active_merchant/billing/integrations/nelnet/notification.rb
Instance Attribute Summary
Attributes inherited from ActiveMerchant::Billing::Integrations::Notification
Instance Method Summary collapse
-
#acknowledge ⇒ Object
Acknowledge the transaction to Nelnet.
- #complete? ⇒ Boolean
-
#gross ⇒ Object
the money amount we received in X.2 decimal.
- #item_id ⇒ Object
- #payer_email ⇒ Object
-
#received_at ⇒ Object
When was this payment received by the client.
- #receiver_email ⇒ Object
- #security_key ⇒ Object
- #status ⇒ Object
-
#test? ⇒ Boolean
Was this a test transaction?.
- #transaction_id ⇒ Object
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
#acknowledge ⇒ Object
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
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
8 9 10 |
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 8 def complete? params[''] end |
#gross ⇒ Object
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_id ⇒ Object
12 13 14 |
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 12 def item_id params[''] end |
#payer_email ⇒ Object
25 26 27 |
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 25 def payer_email params[''] end |
#received_at ⇒ Object
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_email ⇒ Object
29 30 31 |
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 29 def receiver_email params[''] end |
#security_key ⇒ Object
33 34 35 |
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 33 def security_key params[''] end |
#status ⇒ Object
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?
43 44 45 |
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 43 def test? params[''] == 'test' end |
#transaction_id ⇒ Object
16 17 18 |
# File 'lib/active_merchant/billing/integrations/nelnet/notification.rb', line 16 def transaction_id params[''] end |