Magento with Desjardins payment gateway.

I have noticed that my sales order email is sending well with other payment method but with Desjardins payment gateway its not.

I worried bit and checked the extension code, there is no problem at all. then I checked core files. and I noticed code in


saveOrder() function where I changed the code

this to

if (!$redirectUrl && $order->getCanSendNewEmailFlag()) {
                try {
                } catch (Exception $e) {


if ($order->getCanSendNewEmailFlag()) {
                try {
                } catch (Exception $e) {

Now its working fine.

I understood that $redirectUrl contains url to redirect customer page to payment gateway page but it seems when we have $redirectUrl magento will not send order email?

Desjardins gateway is redirect to third party web page for payment and other payment methods are not.

as I saw the first if conditions its state the $redirectUrl is set then email order sending code line is not executing.

I did't get this. Can any one tell me what's going on here?

1 Answer 1


The !$redirectUrl conditions has a very big value, you should not delete it.
The email confirmation must be sent when everything is ok with the order. If the payment method requires a redirect to a third party app where the user inputs his credit card data then the order is not valid until the payment is confirmed.
Here is a scenario that could happen in your case when you deleted the !$redirectUrl condition.

  1. The user adds products to the cart.
  2. The user goes throught the checkout process.
  3. On the payment step he selects the payment method in question.
  4. The user places the order and is redirected to the payment gateway.
  5. The order e-mail is sent.
  6. The user stops the payment process.
  7. The user starts complaining to you that he received the order confirmation but you are not shipping his goods.
  8. Nobody is happy.

The payment gateway should send you messages at a callback url telling you if the payment was ok or not. The email should be sent by the action from the callback url only if the payment went through.
If this doesn't happen for you, you should make the the extension send the email when an OK is received for payment. You should not remove the !$redirectUrl condition.
You can send the email just by calling $order->sendNewOrderEmail() where $order is the instance of the Mage_Sales_Model_Order class for which the payment is validated.

  • Thanks for reply. I log the $redirectUrl and it prints only following url http://mydomainname/index.php/default/desjardins/index/orderplace/
    – Charlie
    Feb 10, 2015 at 9:10
  • That one is the url where the checkout redirects in order to sent the order details to the payment gateway. Most probably that page just contains a form that is autosubmited to the payment gateway. I don't know how the payment method works but most probably there should be a callback url where the payment gateway sends the OK or not OK messages after the payment is processed. This can happen synchronously or not. That't the action from where you should send the e-mail.
    – Marius
    Feb 10, 2015 at 9:15
  • @Matius, Ohh, then again I need to dig all the code to find the problem.:{ Thanks for guidelines
    – Charlie
    Feb 10, 2015 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.