Copied to clipboard

Flag this post as spam?

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


  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jul 24, 2016 @ 12:03
    David Brendel
    0

    SMTP Provider problems

    Hi all,

    I'm currently integration Merchello 2.1.0 into my website. Everything is working fine except the smpt notification sending.

    I added the smpt settings at the gateway tab and set up an OrderConfirmation notification.

    The problem is the notification never gets send after the order is completet (currently with PayPal express checkout). The Umbraco log has also no error messages in it.

    General sending is working.

    Somebody faced the same problem?

    Regards David

  • David Peck 687 posts 1863 karma points c-trib
    Jul 29, 2016 @ 18:13
    David Peck
    0

    I don't know enough to diagnose the issue if it's complicated but I do recall this is a common complaint and that Rusty's initial resolve here may resolve it for you. https://our.umbraco.org/projects/collaboration/merchello/merchello/62002-v180-NotificationsEvents-not-firing

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jul 31, 2016 @ 10:19
    David Brendel
    0

    Hi David,

    thanks for posting it. Will have a look and see if it gets me somewhere!

    Regards David

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 10, 2016 @ 18:08
    David Brendel
    0

    Hi,...

    sadly the post hasn't helped me with my problem.

    Any other suggestion?

    Regards David

  • Toppers 31 posts 155 karma points
    Aug 10, 2016 @ 18:23
    Toppers
    0

    Why don't you change the SMTP notification to write to your local directory by changing your web.config....

    <mailSettings>
      <smtp from="[email protected]" deliveryMethod="SpecifiedPickupDirectory">
       <specifiedPickupDirectory pickupDirectoryLocation="C:\intepub\wwwroot\yourproject\emails" />
      </smtp>
    </mailSettings> 
    

    Then at least you can check if its your server settings which is causing the problem!

  • David Peck 687 posts 1863 karma points c-trib
    Aug 10, 2016 @ 18:49
    David Peck
    0

    Or mail trap, but if general sending is working then that doesn't sound like it's an issue.

    Perhaps it would help if you pasted some code?

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 10, 2016 @ 19:13
    David Brendel
    0

    Hi Topppers,

    haven't thought about that to be honest. Tried it right now and nothing gets generated in the folder.

    Hi David,

    can't really provide some code as I haven't added anything for the mail sending as the default smtp gateway provider from merchello should handle the mail sending.

    Error log also seems normal.

    Regards David

  • Toppers 31 posts 155 karma points
    Aug 10, 2016 @ 19:20
    Toppers
    0

    I don't know Merchello but are there any settings on Merchello which cause it to send emails - which may be switched off?....

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 10, 2016 @ 19:27
    David Brendel
    0

    Hi Toppers,

    there is a smtp gateway provider which is configured with my actual smtp settings which I also use for my contact page which is working fine.

    Regards David

  • Lee 1130 posts 3088 karma points
    Aug 11, 2016 @ 10:39
    Lee
    0

    Similar to other providers in Merchello, Notifications have Gateway Providers which manage one or more methods for performing operations respective to the provider type. Notification provider methods are responsible for “sending notification messages.”

    The built in Notification provider is the Email Notification provider, which as the name infers, is responsible for sending email (SMTP based) messages.

    Notifications are loosely coupled with a set of “Triggers” and “Monitors” based on the .NET IObservable pattern. Triggers notify “subscribing” Monitors that it should execute some function or process for an object (model) the trigger passes to the monitor.

    You can think of this as a monitor which has subscribed to the trigger then does something when the trigger instructs it to do so.

    It is important to make the distinction between “Triggers” and “Events.” Merchello does not use events to send notifications - it uses explicitly called triggers to allow for more granular control of if and when an appropriate Notification process should be executed.

    Note: The OrderConfirmation trigger sometimes confuses people that are first starting out in Merchello as it is generally triggered by Payment Provider developers once a payment has been authorized - so it “appears to act like an event” but in fact it is executed in the provider with code similar to:

    Notification.Trigger("OrderConfirmation", paymentAttempt, new[] { "[email protected]" });
    

    The default SMTP Notification Provider, utilizes the triggers and monitors to send one or more messages for any configured monitor.

    When a trigger is executed, any monitor subscribing to the trigger looks to see if it has any associated messages. If there are any messages, the monitor instantiates a formatter to format the message body and for each message passes the message and formatter off to be sent.
    Assume in the diagram below that the Trigger is an “OrderConfirmation” trigger.

    Monitor 1 has 3 messages associated with it through the back office. When the trigger is executed Monitor 1 creates a Razor formatter and sends the 3 messages through the SMTP Notification provider.

    The messages could be completely different if a separate razor files were used to create the message bodies. They could also have different recipients so you could have:

    • An email for the customer
    • An email for the store owner
    • An email for a drop shipper

    Notification

  • Lee 1130 posts 3088 karma points
    Aug 11, 2016 @ 10:40
    Lee
    0

    This is taken from some of our Workshop. Not sure if it helps everyone understand notifications further.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Aug 11, 2016 @ 21:29
    Rusty Swayne
    0

    Hey David,

    I had another, similar, issue posted a couple of days ago with the Braintree provider implementation with the FastTrack starter. I think it may be an issue with things happening async - I'll be looking at it this week.

    Can you confirm you are using the FastTrack starter (or implementation based off that example)?

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 12, 2016 @ 10:13
    David Brendel
    0

    Hi Lee, Hi Rusty,

    thanks for that explanation. Really interesting to hear the internals of the notification system.

    I'm not using the FastTrack starter right now. Just some custom implementation based on things I saw in the FastTrack code. Main reason for this was skipping al the shipment stuff as I only have digital goods.

    I have done implementations for:

    CheckoutSummaryControllerBase
    CheckoutPaymentMethodControllerBase
    CheckoutAddressControllerBase
    

    I can post the code if needed.

    I also tried calling the notifications manually by the method that Lee provided but that also doesn't help.

    private void SetOrderStatus(ICustomerContext context, IOrderService orderService)
        {
            var invoiceKey = Guid.Parse(context.GetValue("invoiceKey"));
            var orders = orderService.GetOrdersByInvoiceKey(invoiceKey);
            foreach (var order in orders)
            {
                order.OrderStatus = orderService.GetOrderStatusByKey(Merchello.Core.Constants.DefaultKeys.OrderStatus.Fulfilled);
                Notification.Trigger("OrderConfirmation", order, new List<string> { ((Order)order).Invoice().GetBillingAddress().Email });
            }
    
            orderService.Save(orders);
        }
    

    I think I will try the FastTrack shop and see if it sends emails correctly. Then it's some stuff I done/or haven't done in my code.

    Regards David

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Aug 12, 2016 @ 15:39
    Rusty Swayne
    0

    Hey David,

    I'm actually working on both of these issues right now.

    I tracked the problem with the fulfillment of the orders stems from a very early idea that orders with downloadable items should not be marked as fulfilled until they have been downloaded - but it was never fully implemented. It's also intermixed with some of the back ordering and returns stubs we have in the logic.

    In Merchello, there is a difference between an invoice and and order. The concept is an invoice is generally used for payment and includes all line items (inluding shipping costs and tax) and the order is something that can be handed off to a warehouse / fulfillment system - which is more concerned with freight and inventory. It's sort of like the start to create a "bill of lading".

    The setup is really overkill for simple stores, but may give you an idea of where we're heading. The data is setup so that we can create multiple orders of a single invoice and do some basic A/R operations like multiple payments to an invoice. Split a payment to pay for multiple invoices ... etc.

    With respect to the non shippable items (downloads, class registrations), I think it's an area that we got too tricky as there really is no reason to include them in the order. I remember the use case being a piece of software where one variant could be downloadable and a second being shipped out physically in a box. IMO - something that is not going to be physically packaged and delivered should not be included in the order (only on the invoice).

    Looking at your code above (unless you are using a custom trigger/monitor setup) The model passed into the notification should be an IPaymentResult not an order - but I'd have to see a bit more of the code to understand what your doing a bit better - happy to do that =)

    I confirmed yesterday, that the PayPal provider is not sending the email correctly. I'm working on that today!

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Aug 12, 2016 @ 16:52
    Rusty Swayne
    1

    It turns out for the PayPalExpressCheckout payment provider, I had added an event in the Merchello.Providers.Payment.PayPal.Controllers.PayPalExpressController named Processed to allow for sending notification emails after all of the redirections had completed. In the 2.1.0 version of FastTrack I had mishandled the event.

    Here is a snippet the works:

        /// <summary>
        /// Handles the PayPalExpressCheckoutController processed event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        private void PayPalExpressControllerProcessed(PayPalExpressController sender, PaymentAttemptEventArgs<IPaymentResult> e)
        {
            var attempt = e.Entity;
            if (attempt.Payment.Success)
            {
                var email = attempt.Invoice.BillToEmail;
                Notification.Trigger("OrderConfirmation", attempt, new[] { email }, Topic.Notifications);
            }
        }
    

    @David - I've also updated the NotificationTriggerBase to log a WarnWithException showing an invalid model being passed to the trigger. It will still silently fail, but beford hand is was logging via Debug.

  • Simon 692 posts 1068 karma points
    Nov 24, 2016 @ 13:24
    Simon
    0

    Hi Rusty,

    Where should I add this event?

    I am using Merchello Version 2.2.1 and it is not working as well.

    public class HandleEventForSendingNotifcationsAfterPayPaylSuccessfull
        {
            public HandleEventForSendingNotifcationsAfterPayPaylSuccessfull()
            {
                PayPalExpressController.Processed += PayPalExpressController_Processed;
            }
    
            private void PayPalExpressController_Processed(PayPalExpressController sender, Merchello.Core.Events.PaymentAttemptEventArgs<Merchello.Core.Gateways.Payment.IPaymentResult> e)
            {
                var attempt = e.Entity;
                if (attempt.Payment.Success)
                {
                    var email = attempt.Invoice.BillToEmail;
                    Notification.Trigger("OrderConfirmation", attempt, new[] { email }, Topic.Notifications);
                }
            }
        }
    

    I am trying via sandbox.

    thank you for your help

  • Simon 692 posts 1068 karma points
    Nov 24, 2016 @ 14:38
    Simon
    0

    Hi Rusty,

    Now it is working when I have placed it in a controller.

    But it is hitting three times, and therefore 3 the same emails are being sent.

    Any idea how to change?

    Kind Regards

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 14, 2016 @ 17:27
    David Brendel
    0

    Hi Rusty,

    thanks for your investigation. Will add the event handling code and see if that helps.

    Thanks for the inside of the order/invoice difference. For my case the digital goods don't have a download as they are (currently) generated by hand after the purchase. So the idea of setting the items to fullfilled after they are downloaded wouldn't fit. But understand the idea and it makes sense i think.

    Don't use a custom monitor/trigger setup. So I had used the wrong object for the notification triggering. Think to log that would be a good idea, even if the triggering shouldn't really be called manually very often I think.

    Again thanks for working on that issue and the explanation.

    Regards David

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 15, 2016 @ 15:17
    David Brendel
    1

    Hi Rusty,

    tried to implement the event like you showed in your post and after using the correct smpt settings in web.config all works now. One thing I chnaged was to cast the attempt to the right object. As on the first try no email was send.

    But that was maybe caused by wrong smpt config.

    At least it now sends the order confirmation mail. #h5yr

    Regards David

Please Sign in or register to post replies

Write your reply to:

Draft