Class: OffsitePayments::Integrations::EPaymentPlans::Notification

Inherits:
Notification
  • Object
show all
Includes:
ActiveMerchant::PostsData
Defined in:
lib/offsite_payments/integrations/e_payment_plans.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

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

Constructor Details

This class inherits a constructor from OffsitePayments::Notification

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object

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)

123
124
125
126
127
128
129
130
131
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 123

def acknowledge(authcode = nil)
  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


71
72
73
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 71

def complete?
  status == "Completed"
end

#currencyObject


92
93
94
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 92

def currency
  params['currency']
end

#grossObject


88
89
90
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 88

def gross
  params['gross']
end

#item_idObject


79
80
81
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 79

def item_id
  params['item_id']
end

#received_atObject

When was this payment received by the client.


84
85
86
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 84

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

#security_keyObject


96
97
98
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 96

def security_key
  params['security_key']
end

#statusObject


105
106
107
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 105

def status
  params['status'].capitalize
end

#test?Boolean

Was this a test transaction?


101
102
103
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 101

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

#transaction_idObject


75
76
77
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 75

def transaction_id
  params['transaction_id']
end