Copied to clipboard

Flag this post as spam?

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


  • Zac 239 posts 541 karma points
    Jul 06, 2016 @ 19:08
    Zac
    0

    Notes do not save

    We're trying to save notes in Merchello 2.0 in the CheckoutPaymentController process payment.

    We've tried several things, none of which have worked. We're doing this after processing the payment.

    A few notes: 1. Our customers are anonymous 2. No errors are thrown and everything works correctly, but the note does not display in the Merchello Sale display

    Here's what we've tried:

    1. CheckoutManager.Extended.AddNote(message)
    2. Create the note and add to invoice var invoiceService = MerchelloContext.Current.Services.InvoiceService; var invoice = invoiceService.GetByKey(invoiceKey); // ensure the invoice is already saved MerchelloContext.Current.Services.InvoiceService.Save(invoice);

              var noteService = MerchelloContext.Current.Services.NoteService;
              var note = noteService.CreateNoteWithKey(invoice.Key, EntityType.Invoice, model.Notes);
      
      
      
          noteService.Save(note);
          // resave the invoice - shouldn't need to do this either
          MerchelloContext.Current.Services.InvoiceService.Save(invoice);
      
    3. Same as above, but manually add the note var notes = noteService.GetNotesByEntityKey(invoice.Key); if(notes == null) { notes = new List

    4. We've already tried these suggestions: https://our.umbraco.org/projects/collaboration/merchello/merchello/74101-how-to-implementate-note-s-to-invoices

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jul 06, 2016 @ 20:35
    Rusty Swayne
    101

    Hey Zac,

    It's because it is after the payment and the CheckoutManager has been cleared by an event so it's losing context so Number 1 will not work as it is assuming the checkout has been completed (assuming the payment was successful).

    Depending on where your getting your information for your message:

    1) If it is available through the payment result, you could use one of the event handlers off of the PaymentMethodBase class or the Finalizing event off the checkout manager.

    2) If the information is specific (like a text box entry from a form field) you have to add the note to the invoice and then re-save the invoice:

    To prevent multiple saves

    • Use the NoteService to create the note (without a key)
    • Add it to the invoice notes (directly on the invoice)
    • Save the invoice

    It's basically the same thing that is done in the CheckoutManager ...

    https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.Web/Workflow/InvoiceCreation/CheckoutManager/AddNotesToInvoiceTask.cs#L44

  • Zac 239 posts 541 karma points
    Jul 06, 2016 @ 20:59
    Zac
    2

    That worked.

    For other people having the same issue, here's what we did:

                var invoiceService = MerchelloContext.Current.Services.InvoiceService;
                var invoice = invoiceService.GetByKey(invoiceKey);
                var noteService = MerchelloContext.Current.Services.NoteService;
                var note = noteService.CreateNote(invoice.Key, EntityType.Invoice, model.Notes);
                note.Author = "Order Note";
                note.CreateDate = DateTime.Now;
                note.InternalOnly = false;
                noteService.Save(note);
                invoice.Notes = new List<INote>() { note };
                MerchelloContext.Current.Services.InvoiceService.Save(invoice);
    
  • Zac 239 posts 541 karma points
    Jul 07, 2016 @ 01:39
    Zac
    0

    Thanks again Rusty - would you be able to provide any insight on this: https://our.umbraco.org/projects/collaboration/merchello/merchello/78254-digital-products-checkout-flow?

    We've been spinning our wheels trying to get the fulfillment to display correctly.

Please Sign in or register to post replies

Write your reply to:

Draft