We are indeed experiencing this same issue on enterprise 1.10.0.1. This appears to be a known bug that has been filed with Varien. However - I have not found a solution.
Best thing I could find is this thread: http://www.magentocommerce.com/boards/v/viewthread/234872
The bug report I found is posted below.
BUG ID: 26516
Posted: 2011-09-21 15:22:18
When payment processing fails with an exception, the following error occurs in certain situations:
Zend_Db_Statement_Exception: SQLSTATE[23000]: Integrity constraint
violation: 1452 Cannot add or update a child row: a foreign key
constraint fails (magento_enterprise.enterprise_reward, CONSTRAINT
FK_REWARD_CUSTOMER_ID FOREIGN KEY (customer_id) REFERENCES
customer_entity (entity_id) ON DELETE CASCADE ON UPDATE CASCADE)
./lib/Zend/Db/Statement/Pdo.php:234
./lib/Zend/Db/Statement.php:300
./lib/Zend/Db/Adapter/Abstract.php:479
./lib/Zend/Db/Adapter/Pdo/Abstract.php:238
./lib/Varien/Db/Adapter/Pdo/Mysql.php:333
./lib/Zend/Db/Adapter/Abstract.php:574
./app/code/core/Mage/Core/Model/Mysql4/Abstract.php:414
./app/code/core/Mage/Core/Model/Abstract.php:318
./app/code/core/Enterprise/Reward/Model/Reward.php:202
./app/code/core/Enterprise/Reward/Model/Observer.php:548
./app/code/core/Enterprise/Reward/Model/Observer.php:564
./app/code/core/Mage/Core/Model/App.php:1265
./app/code/core/Mage/Core/Model/App.php:1246
./app/Mage.php:416
./app/code/core/Mage/Sales/Model/Service/Quote.php:187
./app/code/core/Mage/Sales/Model/Service/Quote.php:126
./EnterpriseRewardTest.php:70
Steps to reproduce:
- use Magento Enterprise with Enterprise Rewards enabled (or another
module with a similar code, see below)
- use a payment module that supports on-line authorization
- check out an order as a new customer
- trigger a payment error (e.g. by entering an invalid CC no).
I attached a PHPUnit test case that should reproduce the problem reliably.
The culprit is the code in Mage_Sales_Model_Service_Quote::submitOrder that does the following:
- start a transaction
- build a new order
- create a new customer and fill in the order's customerId field
- attempt to process the order, which raises an exception
- roll back the transaction
- dispatch "quote_submit_failure" event using the order as event data. Note that the order's customerId field now contains an invalid value since the transaction has been rolled back.
Now, if a handler for quote_submit_failure proceeds to use order's customerId, it will necessarily trigger the aforementioned "integrity constraint violation" error.
The problem can be reproduced on following versions:
- Magento Enterprise Edition v1.10.0.1
- Magento Community Edition v1.6.0.0 (provided there happens to be a quote_submit_failure handler that expect a valid customerId.