OrderPaidEvent -Handling

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 10 ans
Can anyone explain clearly how the OrderPaidEvent is handled..
Which class implements (IConsumer) is used to handle that OrderPaidEvent ?
Il y a 10 ans
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.
Il y a 10 ans
public class MyOrderPaidConsumer : BasePlugin, IConsumer<OrderPaidEvent>
{
        public void HandleEvent(OrderPaidEvent eventMessage)
        {
            /*eventMessage has the Order as a property, do your task here*/
        }
}
Il y a 10 ans
It worked perfectly Andy.
Il y a 10 ans
Could anyone tell me how to do this exactly ?
in wich file do i need to put the code ?
Il y a 9 ans
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
Il y a 9 ans
Nishanth wrote:
It worked perfectly Andy.


Can you please provide the code for this?

thank you,
Ashima
Il y a 9 ans
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);
            }
        }
Il y a 9 ans
Thanks Quantis!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.