Repository navigation
Keep e-mailed invoices in Downloads and delete them with the e-mail #1010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3ddc487
8efd320
4020b40
99f2dd6
5caba04
c2ee2f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,13 +7,15 @@ | |
| using Grand.Domain.Localization; | ||
| using Grand.Domain.Orders; | ||
| using Grand.Mediator; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Grand.Business.Checkout.Commands.Handlers.Orders; | ||
|
|
||
| public class ProcessOrderPaidCommandHandler : IRequestHandler<ProcessOrderPaidCommand, bool> | ||
| { | ||
| private readonly ICustomerService _customerService; | ||
| private readonly LanguageSettings _languageSettings; | ||
| private readonly ILogger<ProcessOrderPaidCommandHandler> _logger; | ||
| private readonly IMediator _mediator; | ||
| private readonly IOrderMessageProviderService _orderMessageProviderService; | ||
| private readonly OrderSettings _orderSettings; | ||
|
|
@@ -25,14 +27,16 @@ public ProcessOrderPaidCommandHandler( | |
| IMediator mediator, | ||
| IPdfService pdfService, | ||
| OrderSettings orderSettings, | ||
| LanguageSettings languageSettings) | ||
| LanguageSettings languageSettings, | ||
| ILogger<ProcessOrderPaidCommandHandler> logger) | ||
| { | ||
| _orderMessageProviderService = orderMessageProviderService; | ||
| _customerService = customerService; | ||
| _mediator = mediator; | ||
| _pdfService = pdfService; | ||
| _orderSettings = orderSettings; | ||
| _languageSettings = languageSettings; | ||
| _logger = logger; | ||
| } | ||
|
|
||
| public async Task<bool> Handle(ProcessOrderPaidCommand request, CancellationToken cancellationToken) | ||
|
|
@@ -61,24 +65,20 @@ protected virtual async Task ProcessOrderPaid(Order order) | |
| { | ||
| 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; | ||
| string invoiceDownloadId = null; | ||
|
|
||
| var orderPaidAttachments = | ||
| _orderSettings.AttachPdfInvoiceToOrderPaidEmail && _orderSettings.AttachPdfInvoiceToBinary | ||
| ? [ | ||
| await _pdfService.SaveOrderToBinary(order, "") | ||
| ] | ||
| : new List<string>(); | ||
| try | ||
| { | ||
| if (_orderSettings.AttachPdfInvoiceToOrderPaidEmail) | ||
| invoiceDownloadId = await _pdfService.SaveOrderToBinary(order, ""); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| _logger.LogError(ex, "Error - order paid attachment file {OrderOrderNumber}", order.OrderNumber); | ||
| } | ||
|
Comment on lines
+75
to
+78
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not changed. This catch is a deliberate best-effort boundary: PDF composition and file storage fail with many unrelated exception types, and none of them may stop the surrounding work. The exception is logged, and the same pattern is already used in |
||
|
|
||
| await _orderMessageProviderService.SendOrderPaidCustomerMessage(order, customer, order.CustomerLanguageId, | ||
| orderPaidAttachmentFilePath, orderPaidAttachmentFileName, orderPaidAttachments); | ||
| invoiceDownloadId); | ||
|
|
||
| await _orderMessageProviderService.SendOrderPaidStoreOwnerMessage(order, customer, | ||
| _languageSettings.DefaultAdminLanguageId); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not changed. This catch is a deliberate best-effort boundary: PDF composition and file storage fail with many unrelated exception types, and none of them may stop the surrounding work. The exception is logged, and the same pattern is already used in
OrderNotificationCommandHandlerand across the business layer.