Question

I'm having problems with the credit card payment transaction and I'm kind of sure that the quote_id is the cause of it. The problem is I don't know how to increment manually the quote_id in order to find out if I'm right or I'm wrong.

Was it helpful?

Solution 2

First at all, the problem I was having was getting the "ABORTED" answer, the reason was that one field always was sent with the same value, that value was orderid (which is actually the quote_id because the order id is hasn't been created at that point), which is forbidden cause is a unique field in their database. Magento never create a new quote for one user until its current transaction is complete (or when another session is created, I'm not sure yet), the quote_id is sent (as a orderid) with the same value for one user, over and over again so every transaction is aborted.

The solution: just deactive the current quote when the credit card gateway doesn't answer with the string "APPROVED", in sales_flat_quote just set is_active to 0, so Magento would give to the user a brand new quote. The problem is that everything in the cart would lost for the user (the record still exists, but the user wouldn't have access to it anymore), so the Magento would have to clone the quote, then deactive the current and save both, the cloned quote will be now the current quote but with a different quote_id.

// get the current quote
$current_quote = Mage::getModel('sales/quote')->load(23);

// create a new one
$cloned_quote = Mage::getModel('sales/quote');

// copy the content of the current one into the new one
$cloned_quote->merge($current_quote);

// deactive the current quote
$current_quote->setIsActive(false);

// save the cloned quote
$cloned_quote->collectTotals()->save();

// and save the changes of the current quote
$current_quote->save();

// now the current save is inactive 
// and the cloned one is the "new" current quote

the solution was taken from here How to copy one quote (only cart items) to other quote (only items )

Now the final step (or maybe the first one) is increment the quote_id manually, why? the credit card gateway already has a lot of order ids registered with this e-shop, 149 to be precise (using Magento 1.7, by the way). I migrated almost everything to Magento 1.9, but with a brand new database, the quotes were setted to zero, so the first quote generated will be rejected from the cc gateway. This is the solution:

ALTER TABLE sales_flat_quote AUTO_INCREMENT = 149;

So, basically this sum up the solution to my problem. Hope this will be useful to someone else.

OTHER TIPS

First

You cannot do increment manually the quote_id since it is set to auto increment in the database since it is primary key of the table.

So when any quote is created, quote_id is created automatically as it is auto increment and which has to be unique all the time as per sql rule.

To your problem

If you have problem with credit card payment then should you be debugging in payment section. If you are using any external extension for your payment system then please contact them. Or else magento should by default handle all payment without any error.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top