OrderPaidEvent -Handling

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
Can anyone explain clearly how the OrderPaidEvent is handled..
Which class implements (IConsumer) is used to handle that OrderPaidEvent ?
10 years ago
You create a plugin that has a class that implements IConsumer<OrderPaidEvent>.  Then when the event happens, your plugin is called and you can have it do whatever actions you need it to do.
10 years ago
public class MyOrderPaidConsumer : BasePlugin, IConsumer<OrderPaidEvent>
{
        public void HandleEvent(OrderPaidEvent eventMessage)
        {
            /*eventMessage has the Order as a property, do your task here*/
        }
}
10 years ago
It worked perfectly Andy.
10 years ago
Could anyone tell me how to do this exactly ?
in wich file do i need to put the code ?
9 years ago
I am trying to achieve this feature where Customer/vendors emails to be triggered only after the payment status is changed to PAID. Can someone share code on how to do this?

thank you,
Ashima
9 years ago
Nishanth wrote:
It worked perfectly Andy.


Can you please provide the code for this?

thank you,
Ashima
9 years ago
Hi,
Some code snippets of my plugin. You need to create own plugin and add code like below.
J.


namespace Nop.Plugin.Misc.QESynchronization
{
    public partial class SynchronizationPlugin : BasePlugin, IMiscPlugin,
        IConsumer<OrderPaidEvent>,
    {
        
        #region Fields

        private readonly ISettingService _settingService;
        private readonly ILogger _logger;
        private readonly IWorkflowMessageServiceQE _workflowMessageServiceQE;

        #endregion

        #region Ctor

        public SynchronizationPlugin(
            ISettingService settingService,
            ILogger logger,
            IWorkflowMessageServiceQE workflowMessageServiceQE,
            )
        {
            this._settingService = settingService;
            this._logger = logger;
            this._workflowMessageServiceQE = workflowMessageServiceQE;
        }

        #endregion



  /// <summary>
        /// Handles the event.
        /// </summary>
        /// <param name="eventMessage">The event message.</param>
        public void HandleEvent(OrderPaidEvent eventMessage)
        {
            try
            {
                var order = eventMessage.Order;

                if (order == null)
                    throw new ArgumentNullException("Order is null");

                var qeSynchronizationSettings = _settingService.LoadSetting<QESynchronizationSettings>(order.StoreId);

                if (qeSynchronizationSettings.SendOrderPaidCustomerNotification)
                {
                    _workflowMessageServiceQE.SendOrderPaidCustomerNotification(order, order.CustomerLanguageId);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex);
            }
        }
9 years ago
Thanks Quantis!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.