Oooh, that's an interesting one. I see a couple of options.
One option could be to fire the regular email template off, but insert a link to "Download PDF invoice" and have this link to an MVC controller which accepts an order number parameter (you'll need to add extra info / encrypt the params so people can't just increment the order number to see other peoples invoices) and then you could lookup the order and generate the PDF on the fly. Benefit here being you only generate PDFs for people who really need them.
Second option could be to hook into the NotificationCenter.EmailTemplate.MailSending event fired by Tea Commerce and generate and attach the PDF to the outgoing Confirmation email. The MailSending event receives a MailSendingEventArgs args object which itself contains a copy of the order and the MailMessage object so you should have everything you need to generate the PDF and attatch it. The MailSending event also recieves a copy of the EmailTemplate object too so you can make sure you only generate the PDF for "Confirmation" emails.
I think the second option would be the safer option, ie you don't expose an endpoint that others could try and manipulate, but on the other hand, this would generate PDF invoices all the time, whether people really wanted them or not.
Those are both really good ideas that I had not considered.
I quite like first one actually. Most of the website is protected by membership and with the TC orders tagged with the member it will be pretty simple to ensure folk only get to see their own invoices. I've already done it for the member-profile/your-orders section. :-)
As long as it's safe and secure (which it sounds like it will be) it's as good a solution as any and like I say, saves you wasting resources untill someone actually needs it (minor resources yes, but hey, every little helps :))
PDF Invoice
Does anybody have any experience of creating and sending a PDF invoice rather than the usual HTML email?
Thanks,
Matt
Oooh, that's an interesting one. I see a couple of options.
One option could be to fire the regular email template off, but insert a link to "Download PDF invoice" and have this link to an MVC controller which accepts an order number parameter (you'll need to add extra info / encrypt the params so people can't just increment the order number to see other peoples invoices) and then you could lookup the order and generate the PDF on the fly. Benefit here being you only generate PDFs for people who really need them.
Second option could be to hook into the
NotificationCenter.EmailTemplate.MailSending
event fired by Tea Commerce and generate and attach the PDF to the outgoing Confirmation email. The MailSending event receives aMailSendingEventArgs
args object which itself contains a copy of the order and theMailMessage
object so you should have everything you need to generate the PDF and attatch it. The MailSending event also recieves a copy of theEmailTemplate
object too so you can make sure you only generate the PDF for "Confirmation" emails.I think the second option would be the safer option, ie you don't expose an endpoint that others could try and manipulate, but on the other hand, this would generate PDF invoices all the time, whether people really wanted them or not.
Hope this helps
Matt
Thanks Matt,
Those are both really good ideas that I had not considered.
I quite like first one actually. Most of the website is protected by membership and with the TC orders tagged with the member it will be pretty simple to ensure folk only get to see their own invoices. I've already done it for the member-profile/your-orders section. :-)
Cheers,
Matt
As long as it's safe and secure (which it sounds like it will be) it's as good a solution as any and like I say, saves you wasting resources untill someone actually needs it (minor resources yes, but hey, every little helps :))
I use the nuget package PDFSharp to create and read PDFs. It's reasonably easy to use.
You can also write to PDFs from XAML layouts in C#.
Thanks,
That one seems popular, so does Rotativa which I have been exploring.
is working on a reply...