Error: SQL integrity constraing violation after checkout

Modified on Thu, 26 Feb at 8:48 AM

Some stores may encounter the following SQL error when using the checkout. It's been reported this often happens after reaching the success page after checkout.

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

`quote_payment`, CONSTRAINT `QUOTE_PAYMENT_QUOTE_ID_QUOTE_ENTITY_ID` FOREIGN KEY (`quote_id`) REFERENCES `quote` (`entity_id`) ON DELETE CASCADE), query was: INSERT INTO `quote_payment` (`additional_information`) VALUES (?)

This SQL error implies there is an issue with storing the data to the database. This error has been reported to us in the past, but in each case it did not stem from our own extension and we've not yet been provided with additional information on found solutions.


If the payment transaction was successful, that typically indicates something outside of our code triggered the error which is out of our control. In most cases, the payment step will halt order processing when a payment transaction fails. You can confirm the state of the transaction based on the response code in the tokenbase.log. If you are using our Authorize.Net extension, they offer a page to query the response code meaning.


This SQL error could be from other code or from a past error that lead to data being saved to the database that is not expected to be there. You will primarily want to review the database data to review what may be causing this error. Magento offers a command to log database requests so you can review the data attempting to be submitted.

If you are unable to find any additional information and your store is a clean Magento installation with nothing but our payment extension installed, please reach out to our support with the following pieces of information so we may review:

- Payment extension version
- Current Magento version
- Information on data used to trigger the error (customer type, product type, card data if sandbox, etc)
- Steps to reliably reproduce from a fresh Magento installation

You may also wish to review your stores logs to see if a stack trace was logged for this SQL error. A stack trace in either the PHP error log or Magento exception log may give more insight into what code was running prior to the SQL exception.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article