class OffsitePayments::Integrations::EPaymentPlans::Notification

Public Instance Methods

acknowledge(authcode = nil) click to toggle source

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
# 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?() click to toggle source
# File lib/offsite_payments/integrations/e_payment_plans.rb, line 71
def complete?
  status == "Completed"
end
currency() click to toggle source
# File lib/offsite_payments/integrations/e_payment_plans.rb, line 92
def currency
  params['currency']
end
gross() click to toggle source
# File lib/offsite_payments/integrations/e_payment_plans.rb, line 88
def gross
  params['gross']
end
item_id() click to toggle source
# File lib/offsite_payments/integrations/e_payment_plans.rb, line 79
def item_id
  params['item_id']
end
received_at() click to toggle source

When was this payment received by the client.

# File lib/offsite_payments/integrations/e_payment_plans.rb, line 84
def received_at
  Time.parse(params['received_at'].to_s).utc
end
security_key() click to toggle source
# File lib/offsite_payments/integrations/e_payment_plans.rb, line 96
def security_key
  params['security_key']
end
status() click to toggle source
# File lib/offsite_payments/integrations/e_payment_plans.rb, line 105
def status
  params['status'].capitalize
end
test?() click to toggle source

Was this a test transaction?

# File lib/offsite_payments/integrations/e_payment_plans.rb, line 101
def test?
  params['test'] == 'test'
end
transaction_id() click to toggle source
# File lib/offsite_payments/integrations/e_payment_plans.rb, line 75
def transaction_id
  params['transaction_id']
end

Private Instance Methods

parse(post) click to toggle source

Take the posted data and move the relevant data into a hash

# File lib/offsite_payments/integrations/e_payment_plans.rb, line 136
def parse(post)
  @raw = post
  for line in post.split('&')
    key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
    params[key] = value
  end
end