Class: ActiveMerchant::Billing::Integrations::EPaymentPlans::Notification

Inherits:
Notification
  • Object
show all
Includes:
PostsData
Defined in:
lib/active_merchant/billing/integrations/e_payment_plans/notification.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Methods inherited from 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 EPaymentPlans. This method has to be called after a new apc arrives. EPaymentPlans will verify that all the information we received are correct and will return ok or a fail.

Example:

def ipn
  notify = EPaymentPlans.notification(request.raw_post)

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

Raises:

  • (StandardError)


61
62
63
64
65
66
67
68
69
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 61

def acknowledge
  payload = raw

  response = ssl_post(EPaymentPlans.notification_confirmation_url, payload)

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

#complete?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 9

def complete?
  status == "Completed"
end

#currencyObject



30
31
32
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 30

def currency
  params['currency']
end

#grossObject



26
27
28
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 26

def gross
  params['gross']
end

#item_idObject



17
18
19
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 17

def item_id
  params['item_id']
end

#received_atObject

When was this payment received by the client.



22
23
24
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 22

def received_at
  Time.parse(params['received_at'].to_s).utc
end

#security_keyObject



34
35
36
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 34

def security_key
  params['security_key']
end

#statusObject



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

def status
  params['status'].capitalize
end

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


39
40
41
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 39

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

#transaction_idObject



13
14
15
# File 'lib/active_merchant/billing/integrations/e_payment_plans/notification.rb', line 13

def transaction_id
  params['transaction_id']
end