class AdyenNotification

The AdyenNotification class handles notifications sent by Adyen to your servers.

Because notifications contain important payment status information, you should store these notifications in your database. For this reason, AdyenNotification inherits from ActiveRecord::Base, and a migration is included to simply create a suitable table to store the notifications in.

Adyen can either send notifications to you via HTTP POST requests, or SOAP requests. Because SOAP is not really well supported in Rails and setting up a SOAP server is not trivial, only handling HTTP POST notifications is currently supported.

@example

@notification = AdyenNotification.log(request)
if @notification.successful_authorisation?
  @invoice = Invoice.find(@notification.merchant_reference)
  @invoice.set_paid!
end

Public Class Methods

log(params) click to toggle source

Logs an incoming notification into the database.

@param [Hash] params The notification parameters that should be stored in the database. @return [Adyen::Notification] The initiated and persisted notification instance. @raise This method will raise an exception if the notification cannot be stored. @see Adyen::Notification::HttpPost.log

   # File lib/adyen/templates/notification_model.rb
38 def self.log(params)
39   # Assign explicit each attribute from CamelCase notation to notification
40   # For example, merchantReference will be converted to merchant_reference
41   self.new.tap do |notification|
42     params.each do |key, value|
43       setter = "#{key.to_s.underscore}="
44       notification.send(setter, value) if notification.respond_to?(setter)
45     end
46 
47     notification.save!
48   end
49 end

Public Instance Methods

authorisation?() click to toggle source

Returns true if this notification is an AUTHORISATION notification @return [true, false] true iff event_code == 'AUTHORISATION' @see Adyen.notification#successful_authorisation?

   # File lib/adyen/templates/notification_model.rb
54 def authorisation?
55   event_code == 'AUTHORISATION'
56 end
Also aliased as: authorization?
authorization?()
Alias for: authorisation?
successful_authorisation?() click to toggle source

Returns true if this notification is an AUTHORISATION notification and the success status indicates that the authorization was successfull. @return [true, false] true iff the notification is an authorization

and the authorization was successful according to the success field.
   # File lib/adyen/templates/notification_model.rb
64 def successful_authorisation?
65   authorisation? && success?
66 end
Also aliased as: successful_authorization?
successful_authorization?()