Do You Need to Pay and Return to Site to Get PayPal Order Confirmation Email in Magento?

emailmagento-1.9paypal

we are not getting order confirmation email if customer placed an order through paypal.but we get invoice and shipment mails.

we set Sale : Payment Action in paypal configuration.

so once we create the order, along with the order email [its not going to customer] i want to send invoice mail also to customer. i think this extension will send invoice only once order status become complete.

if we use SMTP extension will it work for us ?

is there any thing else we need to do ?

Edit

also I want to know is Email will send only if we pay money and succesfully return to site ? If we just click on "place order" & redirect to paypal page, will it not send email ?

2016-06-13T20:15:10+00:00 ERR (3): 
exception 'Mage_Paypal_UnavailableException' with message 'Empty response.' in /home/site/public_html/app/code/core/Mage/Paypal/Model/Ipn.php:166
Stack trace:
#0 /home/site/public_html/app/code/core/Mage/Paypal/Model/Ipn.php(116): Mage_Paypal_Model_Ipn->_postBack(Object(Varien_Http_Adapter_Curl))
#1 /home/site/public_html/app/code/core/Mage/Paypal/controllers/IpnController.php(43): Mage_Paypal_Model_Ipn->processIpnRequest(Array, Object(Varien_Http_Adapter_Curl))
#2 /home/site/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Paypal_IpnController->indexAction()
#3 /home/site/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#4 /home/site/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#5 /home/site/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#6 /home/site/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#7 /home/site/public_html/index.php(87): Mage::run('', 'store')
#8 {main}

Best Answer

Concepts

we are not getting order confirmation email if customer placed an order through paypal.but we get invoice and shipment mails.

This clarifies one thing: that your email sending mechanism (likely the Magento cron) is working correctly in general.

if we use SMTP extension will it work for us ?

Whether you implement this extension or not, it will not affect whether your PayPal order emails work. This module is designed to sit in the background and take the regular email send jobs from the core Magento mail module and do its own thing with them. You will not notice a difference in regular Magento use from installing it, other than an email log table in Magento admin which contains a history of your sent emails.

If you have installed this extension, you could use that email log in Magento admin to check what has been sent. You can access it via System -> Tools -> SMTP Pro - Email Log.

also I want to know is Email will send only if we pay money and succesfully return to site ? If we just click on "place order" & redirect to paypal page, will it not send email ?

Emails are sent when certain status changes occur on various models in Magento. Order emails are sent when an order reaches the processing status, which means it has been invoiced and paid (payment method has been charged [capture() method]). Invoice emails are sent when the order's invoice is created (normally/often when the order is created as well). Shipment emails are created when a shipment is created for an order, etc...

Yes - the email will send only if you've completed the PayPal transaction and successfully returned to your Magento site (and Magento has successfully registered that payment against the order and saved it).

If you just click on "place order" & redirect to PayPal page, it will not trigger any emails to be sent. Your order doesn't exist at this point, it is simply a quote waiting to be converted to an order when the customer returns from PayPal.

The code

If you take a look at Mage_Paypal_Model_Express_Checkout::place() as an example, you will see the following conditions apply to when Magento will send (queue) a new order email. This method is triggered when customers return from PayPal (the returnAction in Mage_Paypal_Controller_Express_Abstract sends them here via ->placeOrderAction() then $this->_checkout->place()):

# File: app/code/core/Mage/Paypal/Model/Express/Checkout.php
switch ($order->getState()) {
    // even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
    case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
        // TODO
        break;
    // regular placement, when everything is ok
    case Mage_Sales_Model_Order::STATE_PROCESSING:
    case Mage_Sales_Model_Order::STATE_COMPLETE:
    case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
        $order->queueNewOrderEmail();
        break;
}

Essentially the email will be sent (queued) if the new order's state is either "processing", "complete" or "payment_review" - have you checked the affected PayPal orders to see what their status is? You say you can ship them, so I assume that they're "processing".

The one exception as you can see above is when the state of the new order is "pending payment". The comment from the Magento developers explains it, but it can happen in a delayed payment situation. I would suggest that this is not very common.

Of course, that switch statement is specific and doesn't contain a default case (side note: this breaks the Zend style guidelines, but so does a lot of the core Magento code!). This means that if the order state is not any of the ones mentioned, the order will also not be sent (queued).


Where to from here?

I'd suggest you do the following:

  • Get a PayPal sandbox account set up in your development environment so you can test it yourself!
  • Inspect the status of new PayPal orders as they come in. Look at the status of the orders. Look at the history of the order to see if anything seems out of the ordinary. Try changing the email on one of the orders to yours and triggering the order email to be re-sent manually from the order view screen in Magento admin (this will eliminate the email template itself as an issue)
  • Enable PayPal logging, and inspect the API logs as the requests are made (best done in a development environment, assuming you can reproduce it)

Notes

The comments/suggestions I've made above assume that you don't have any third-party or custom made modules getting in the way of any of the orders or payments processes in Magento. If you do, you should mention them!

Good luck, hope this helps!

Related Topic