/// <summary> /// Process order paid status /// </summary> /// <param name="order">Order</param> protected virtual async Task ProcessOrderPaid(Order order) { if (order == null) { throw new ArgumentNullException(nameof(order)); } //raise event await _mediator.Publish(new OrderPaidEvent(order)); //order paid email notification if (order.OrderTotal != decimal.Zero) { var customer = await _customerService.GetCustomerById(order.CustomerId); var orderPaidAttachmentFilePath = _orderSettings.AttachPdfInvoiceToOrderPaidEmail && !_orderSettings.AttachPdfInvoiceToBinary ? await _pdfService.PrintOrderToPdf(order, "") : null; var orderPaidAttachmentFileName = _orderSettings.AttachPdfInvoiceToOrderPaidEmail && !_orderSettings.AttachPdfInvoiceToBinary ? "order.pdf" : null; var orderPaidAttachments = _orderSettings.AttachPdfInvoiceToOrderPaidEmail && _orderSettings.AttachPdfInvoiceToBinary ? new List <string> { await _pdfService.SaveOrderToBinary(order, "") } : new List <string>(); await _messageProviderService.SendOrderPaidCustomerMessage(order, customer, order.CustomerLanguageId, orderPaidAttachmentFilePath, orderPaidAttachmentFileName, orderPaidAttachments); await _messageProviderService.SendOrderPaidStoreOwnerMessage(order, customer, _languageSettings.DefaultAdminLanguageId); if (order.OrderItems.Any(x => !string.IsNullOrEmpty(x.VendorId))) { var vendors = await _mediator.Send(new GetVendorsInOrderQuery() { Order = order }); foreach (var vendor in vendors) { await _messageProviderService.SendOrderPaidVendorMessage(order, vendor, _languageSettings.DefaultAdminLanguageId); } } //TODO add "order paid email sent" order note } }