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.
2 Answers
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.
-
Eventually I guess I will have to put in contact with the credic card transaction company support office, but before of that I want to. I already logged everything about the cc payment transaction and the only thing out of place is the costant value of
quote_id
(which is not allowed it), but how I tell to Magento to jump to the follow ID?– abiyiCommented Jun 23, 2015 at 13:45 -
I noticed something interesting: into the data array sent to the cc transaction company is included the order ID, but the value doesn't come from
order_id
but fromquote_id
(probably because theorder_id
is created at the very end of the process, after the cc data is sent), now I found out that I can change the quote lifetime days in the Admin Panel, but thecuote_id
for my user keeps using the same ID. That could explain why the cc transaction was rejected "ramdomly".– abiyiCommented Jun 23, 2015 at 20:18
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.
quote_id
isauto_increment
in the database, thus it will increment for each new record. You should check first if a quote record is created, then if the id of that quote is sent to the cc transaction company.