Magento – Payment failed / Payment failed disable mails

In the context of a customer project we have the Magento system rebuilt so, that it is optimally suited as competition page. In the case of this must be in the event of a material price entered the shipping address and a photo upload and uploaded.

Now we had the problem, Magento that every time, if a user wanted to upload no upload or wrong format (But although an error message on the page came) an email sent from the system, that the payment failed.

Picture

this is generally the setting in System > Configuration > Sales / Checkout and there with “E-mails From a Failed Payment” responsible. Here one could get the idea, that no mail is sent, if you leave the field with the address just empty – denkste! If you look at the names of the fields, one sees, that there is something of copy. The “Payment failed”-Mail is sent ALWAYS namely the stored in the system contact email address and can then be shipped to the ADDITION here to be filed with mail (therefore, the last setting “Bcc / Separate Mail”).

If one now so NO -and I mean NO- “Payment failed”-Mail wants more, You can accomplish this in several ways.

One can write a rewrite of app / code / core / Mage / Checkout / Helper / data.php and there in particular for

public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')

This would be better than just the part

public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
{
$translate = Mage::getSingleton('core/translate');
/* @var $translate Mage_Core_Model_Translate */
$translate->set's late inline(false);

$mailTemplate = Mage::getModel('core/email_template');
/* @var $mailTemplate Mage_Core_Model_Email_Template */

$template = Mage::getStoreConfig('checkout/payment_failed/template', $checkout->getStoreId());

$copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId());
$copyMethod = Mage::getStoreConfig('checkout/payment_failed/copy_method', $checkout->getStoreId());
if ($copyTo && $copyMethod == 'bcc') {
$mailTemplate->addBcc($copyTo);
}

$_reciever = Mage::getStoreConfig('checkout/payment_failed/reciever', $checkout->getStoreId());
$sendTo = array(
array(
'email' => Magus::getStoreConfig('trans_email/ident_'.$_reciever.'/email', $checkout->getStoreId()),
'name' => Magus::getStoreConfig('trans_email/ident_'.$_reciever.'/name', $checkout->getStoreId())
)
);

if ($copyTo && $copyMethod == 'copy') {
foreach ($copyTo as $email) {
$sendTo[] = array(
'email' => $email,
'name' => null
);
}
}
$shippingMethod = '';
if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) {
$data = explode('_', $shippingInfo);
$shippingMethod = $data[0];
}

$paymentMethod = '';
if ($paymentInfo = $checkout->getPayment()) {
$paymentMethod = $paymentInfo->getMethod();
}

$items = '';
foreach ($checkout->getAllVisibleItems() as $_item) {
/* @var $_item Mage_Sales_Model_Quote_Item */
$items .= $_item->getProduct()->getName() . ' x '. $_item->getQty() . ' '
. $checkout->getStoreCurrencyCode() . ' '
. $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
}
$total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();

foreach ($sendTo as $recipient) {
$mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$checkout->getStoreId()))
->sendTransactional(
$template,
Magus::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()),
$recipient['email'],
$recipient['name'],
array(
'reason' => $message,
'checkoutType' => $checkoutType,
'DateAndTime' => Magus::app()->getLocale()->date(),
'customer' => Magus::helper('customer')->getFullCustomerName($checkout),
'customerEmail' => $checkout->getCustomerEmail(),
'billingAddress' => $checkout->getBillingAddress(),
'shippingAddress' => $checkout->getShippingAddress(),
'shippingMethod' => Magus::getStoreConfig('carriers/' . $shippingMethod . '/title'),
'paymentMethod' => Magus::getStoreConfig('payment/' . $paymentMethod . '/title'),
'items' => nl2br($items),
'total' => $total,
)
);
}

$translate->set's late inline(true);

return $this;
}

by

public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
{
return $this;
}

to replace.

But would also work 😉 It may be, that the system still complains in Exception.log. But mails are no more respect. “Payment failed”.

Posted in Magento 1.9.4.0

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

Leave a Reply

Your email address will not be published. Required fields are marked *