Class: Adyen::Notification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/adyen/notification.rb

Direct Known Subclasses

HttpPost

Defined Under Namespace

Classes: HttpPost, Migration

Constant Summary collapse

DEFAULT_TABLE_NAME =
:adyen_notifications

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log(params) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/adyen/notification.rb', line 16

def self.log(params)
  converted_params = {}
  # Convert each attribute from CamelCase notation to under_score notation
  # For example, merchantReference will be converted to merchant_reference
  params.each do |key, value|
    field_name                   = key.to_s.underscore
    converted_params[field_name] = value if self.column_names.include?(field_name)
  end
  self.create!(converted_params)
end

Instance Method Details

#authorisation?Boolean Also known as: authorization?

Returns:

  • (Boolean)


27
28
29
# File 'lib/adyen/notification.rb', line 27

def authorisation?
  event_code == 'AUTHORISATION'
end

#collect_payment_for_recurring_contract!(options) ⇒ Object



37
38
39
40
41
42
# File 'lib/adyen/notification.rb', line 37

def collect_payment_for_recurring_contract!(options)
  # Make sure we convert the value to cents
  options[:value] = Adyen::Formatter::Price.in_cents(options[:value])
  raise "This is not a recurring contract!" unless event_code == 'RECURRING_CONTRACT'
  Adyen::SOAP::RecurringService.submit(options.merge(:recurring_reference => self.psp_reference))
end

#deactivate_recurring_contract!(options) ⇒ Object



44
45
46
47
# File 'lib/adyen/notification.rb', line 44

def deactivate_recurring_contract!(options)
  raise "This is not a recurring contract!" unless event_code == 'RECURRING_CONTRACT'
  Adyen::SOAP::RecurringService.deactivate(options.merge(:recurring_reference => self.psp_reference))
end

#successful_authorisation?Boolean Also known as: successful_authorization?

Returns:

  • (Boolean)


33
34
35
# File 'lib/adyen/notification.rb', line 33

def successful_authorisation?
  event_code == 'AUTHORISATION' && success?
end