Trigger a notification message from the on_before_save hook within a custom module's model.

edited June 2012 in Modules
I'm working on an Authorize.net integration within a module I have called "Refunds". The goal is to store refund information for refund transactions, and in addition to storing the information in a Fuel model, I want it to actually process the refund in Authorize.net. I also want to display notifications in the notifications bar of Fuel to let the user know if the refund transaction was successful or not. You can imagine that it makes sense that the Authorize.net transaction needs to be handled before the Refund is saved to the database, hence the use of the on_before_save hook.

How do I tap into that area in order to setup my own custom messages, in addition to the "Data has been saved." message that flashes in green? I would like a notification to display in red when the transaction fails to process, and green otherwise.

Thanks,
Erik

Comments

  • edited 10:28AM
    To flash an error you can use the add_error method on your model. The module controller will check that and if there are any errors, it will add that to the notification area. Otherwise, it will flash green stating that the data was saved.
  • edited 10:28AM
    Thanks! works perfectly!
Sign In or Register to comment.