The problem is, that after the payment is succeeded and the task is hit, the InvoiceNumber is still 0 - is this a bug, or is there a reason?
As a next step I want to send the PDF to the customer. Should I use the Notification for that?
Is it possible to have something like:
public override void PerformSend(IFormattedNotificationMessage message)
{
// There is no way to access invoice
string invoiceNumber = message.Invoice.InvoiceNumber;
GetPdfPathByInvoiceNumber(invoiceNumber);
}
private GetPdfPathByInvoiceNumber(int invoiceNumber)
{
var privateFolder = WebConfigurationManager.AppSettings["privateFolderPath"].ToString();
return Path.Combine(privateFolder, "Confirmations", invoiceNumber + ".pdf");
}
Yes, the invoice number would 0 in the builder - that's by design as there are many reasons you would want to preview an invoice without actually saving it (which is when the invoice number is actually generated).
A good place to generate the PDF would be in the SalePreparationBase.Finalizing event which occurs right after a payment result is received back from the payment provider in the SalePreparation stage of the workflow.
You would have a persisted invoice and a payment result and the event would be triggered before the result is passed back to the controller (which I assume is where you are initiating the email construction).
I already found it out by looking at the code - but thank you for the example - forgot that I have a thread here asking this ;-).
The only thing I couldn't figure out yet is how I can attach a file to the Notification Service from merchello. Or do you think I should write my own mailer?
Creating PDF and sending it via E-Mail
Hi Rusty
Still trying to get into Merchello and figure out, how it works under the hood ;-).
I thought it's faster if I ask you about this :-P.
After the payment is done, I want to generate a PDF. Therefore I created a task chain and added it to the merchello.config:
The problem is, that after the payment is succeeded and the task is hit, the InvoiceNumber is still 0 - is this a bug, or is there a reason?
As a next step I want to send the PDF to the customer. Should I use the Notification for that?
Is it possible to have something like:
Thank you
Calvin
Hi Calvin,
Yes, the invoice number would 0 in the builder - that's by design as there are many reasons you would want to preview an invoice without actually saving it (which is when the invoice number is actually generated).
A good place to generate the PDF would be in the SalePreparationBase.Finalizing event which occurs right after a payment result is received back from the payment provider in the SalePreparation stage of the workflow.
I've used it in this file if you want an example ... https://github.com/Merchello/Merchello/blob/1.4.1/src/Merchello.Web/UmbracoApplicationEventHandler.cs
You would have a persisted invoice and a payment result and the event would be triggered before the result is passed back to the controller (which I assume is where you are initiating the email construction).
Does this help?
Hi Rusty
Thank you for the reply.
I already found it out by looking at the code - but thank you for the example - forgot that I have a thread here asking this ;-).
The only thing I couldn't figure out yet is how I can attach a file to the Notification Service from merchello. Or do you think I should write my own mailer?
Solved? I think that is more simple that you send email via Umbraco mailer or overload controller method.
is working on a reply...