public async Task SendInvoiceAsEmailAttachment(UserDao user, PaymentIntentDao paymentIntent, string subscriptionName, DateTime subscriptionStartDate, long totalAmount, string invoiceNumber, string rootFolder, CancellationToken cancellationToken) { Guard.Argument(paymentIntent, nameof(paymentIntent)).NotNull(); Guard.Argument(subscriptionName, nameof(subscriptionName)).NotNull().NotEmpty().NotWhiteSpace(); Guard.Argument(invoiceNumber, nameof(invoiceNumber)).NotNull().NotEmpty().NotWhiteSpace(); Guard.Argument(rootFolder, nameof(rootFolder)).NotNull().NotEmpty().NotWhiteSpace(); var emailBody = _emailTemplateHelper.GetInvoiceEmailBody(rootFolder, user.FirstName); var emailMessage = new EmailDao { ToAddress = user.Email, ToName = user.FullName, FromAddress = Constants.AutomatedEmailFromAddress, Subject = Constants.InvoiceEmailSubject, HtmlBody = emailBody, }; var address = paymentIntent.Address ?? user.Address; var filePath = GenerateInvoice(user.FullName, address, $"{paymentIntent.CarIssuer} ****{paymentIntent.Last4}", invoiceNumber, subscriptionName, subscriptionStartDate, totalAmount, rootFolder); _logger.Information($"Generated invoice '{filePath}' for user '{user.Id}'"); await _emailService.SendEmail(emailMessage, filePath, cancellationToken); _logger.Information($"Sent invoice for user '{user.Id}'"); _fileHelper.DeleteFileDirectory(filePath); _logger.Information($"Deleted invoice file '{filePath}'"); }
public static PaymentIntentResponse ToResponse(this PaymentIntentDao source) { if (source == null) { return(null); } return(new PaymentIntentResponse { Id = source.Id, ClientSecret = source.ClientSecret, Amount = source.Amount }); }