Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Calvin Frei 106 posts 314 karma points
    Sep 12, 2014 @ 23:43
    Calvin Frei
    0

    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:

    <task type="Test.Chains.InvoiceCreation.GenereatePdf, Test.Chains" />
    

    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");
    }
    

    Thank you
    Calvin

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Sep 20, 2014 @ 18:16
    Rusty Swayne
    0

    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?

  • Calvin Frei 106 posts 314 karma points
    Sep 21, 2014 @ 22:33
    Calvin Frei
    0

    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?

  • Biagio Paruolo 1594 posts 1825 karma points c-trib
    Sep 05, 2015 @ 07:47
    Biagio Paruolo
    0

    Solved? I think that is more simple that you send email via Umbraco mailer or overload controller method.

Please Sign in or register to post replies

Write your reply to:

Draft