Magento – What caused this “Payment Transaction Failed” error

errormagento-1.9

I am getting intermittent errors that look like the one I copied below. Any ideas what is causing this, and how to fix it?


Payment transaction failed.
Reason
This customer email already exists

Checkout Type
onepage

Customer:
XXXXX XXXXX XXXXXXXX

Items
AAAAAAAA® x 1 USD 44.99
BBBBBBBBB® x 1 USD 49.9900
Total:
USD 107.69

Billing Address:
Xxxxxx xxxxxxxx
693 E. Xxxxxx St
Xxxxxxx, California, xxxxx
United States
T: xxxxxxxxxxx
T: 5598015225

Shipping Address:
Xxxxxx xxxxxxxx
693 E. Xxxxxx St
Xxxxxxx, California, xxxxx
United States
T: xxxxxxxxxxx

Shipping Method:
StoreName Shipping

Payment Method:
PayPal

Date & Time:
Feb 4, 2015 3:14:19 PM

Best Answer

The exception you get is generated by the customer resource model's _beforeSave function, which checks if a customer with the given email address exists. The check's code:

  $adapter = $this->_getWriteAdapter();
$bind = array('email' => $customer->getEmail());

$select = $adapter->select()
    ->from($this->getEntityTable(), array($this->getEntityIdField()))
    ->where('email = :email');
if ($customer->getSharingConfig()->isWebsiteScope()) {
    $bind['website_id'] = (int)$customer->getWebsiteId();
    $select->where('website_id = :website_id');
}
if ($customer->getId()) {
    $bind['entity_id'] = (int)$customer->getId();
    $select->where('entity_id != :entity_id');
}
result = $adapter->fetchOne($select, $bind);
if ($result) {
    throw Mage::exception(
        'Mage_Customer', Mage::helper('customer')->__('This customer email already exists'),
        Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS
    );
}

You customers are logged in, which means the condition $customer->getId() is true. But since you get an exception, I suggest, there are duplicate customer accounts with the same emails.

Can it be that your import tool has created duplicates in the customer data? That is the only reason I can think of. Check your database with this query:

select email, count(*) from customer_entity group by email having count(*) > 1

Original answer found here

Related Topic