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
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