OrderPaidEvent -Handling

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


Can you please provide the code for this?

thank you,
Ashima
9 anos atrás
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 anos atrás
Thanks Quantis!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.