Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento PayPal Duplicate Invoice Error
    primarykey
    data
    text
    <p>Every once in a while a customer will get an error when attempting to submit an order that says <strong>PayPal gateway has rejected request. The transaction was refused as a result of a duplicate invoice ID supplied.</strong> After digging into this a bit I believe I have narrowed down the problem. In the most recent of cases, a customer had attempted to place an order 4 months ago and received an <strong>Internal Error</strong> from PayPal. I learned from speaking with PayPal that this customer's credit card had been flagged. When they attempted to place the first order, PayPal rejected it but still considered the Invoice ID that our Magento Store had provided "used".</p> <p>Fast forward to today...same customer, new order. Magento STILL had the old quote from September in the <code>sales_flat_quote</code> table. When they logged in, it loaded the customer quote (which was still active) and attempted to use it for this order. That resulted in the <strong>Duplicate Invoice ID</strong> error.</p> <p>I see in the Mage_Sales_Model_Observer class that there is a <code>cleanExpiredQuotes</code> method that is called from a cron job. However, this only effects quotes with "is_active" = 0. Since this quote is considered active it never got cleared out.</p> <p>So clearly there's a disconnect between the Magento code and PayPal. But that's about as far as I've gotten with it. Has anyone else experienced this? If so, any suggestions?</p> <h2>EDIT:</h2> <p>I've gotten a bit further with this. I have added code to the checkout IndexController to catch the error and, if it's a Duplicate Invoice Error, it unsets the <strong>reserved_order_id</strong> in the quote a calls the <strong>saveOrderAction</strong> again. This causes the quote to reserve a new order ID, which it then submits to PayPal. The problem I'm having now is that when it tries the second time with the new Invoice Number, all the totals are 0. I tried setting the <strong>totals_collected_flag</strong> to false so it re-collects the totals, but they are always 0 the second time through. More specifically, the totals in the <strong>Mage_Sales_Model_Quote_Address</strong> are 0, which is what the <strong>Mage_Sales_Model_Order</strong> ends up using. The totals in the <strong>Mage_Sales_Model_Quote</strong> are correct, but they get overwritten in the <code>collectTotals()</code> method of the quote.</p> <p>Obviously, after the first attempt, something is unsetting all the values, but I don't know what or where. If anyone has any ideas I'd love to hear them!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload