How to Fix: PayPal “This invoice has already been paid” message

Submitted by deeperdata - 2 years ago

I experienced this issue after an upgrade to a client's very dated install. We found that user's attempting to checkout with PayPal would click to proceed to the PayPal portal after filling out their billing/shipping information and would be confronted with this error: “This invoice has already been paid” Users who experienced this error had no alternatives or ways to resolve the problem, it was simply a PayPal gateway error. The problem originated with Magento's internal numbering system - specifically for the eav_entity_store table. Somehow, invoice ID (entity_type_id = 6) fell way behind order ID (entity_type_id = 5). Every time Magento would send payment information to PayPal, it would send a potentially already used invoice ID to which would in turn cause the payment to get rejected completely resulting in a loss of sale for the store owner. There are people who suggest to do the following which is only fixing the symptom and not the problem: Log into your PayPal Account (standard) -> Profile -> Payment Receiving Preferences -> Under Block accidental payments: select “No, allow multiple payments per invoice ID” The correct way is to update your lagging invoice increment_last_id (entity_type_id = 6) to match your order increment_last_id (entity_type_id = 5) in the eav_entity_store table. See below for the very table I had to update. Here is some additional reading on increment IDs in Magento: https://www.ashsmith.io/2012/12/quick-tip-change-magento-default-increment-id-for-orders-invoices/

+-----------------+----------------+----------+------------------+-------------------+
| entity_store_id | entity_type_id | store_id | increment_prefix | increment_last_id |
+-----------------+----------------+----------+------------------+-------------------+
|               1 |              5 |        1 | 1                | 100006819         |
|               2 |              6 |        1 | 1                | 100006775         |
|               3 |              8 |        1 | 1                | 100006368         |
|               4 |              1 |        0 | 0                | 000001494         |
|               5 |              7 |        1 | 1                | 100000031         |
|               6 |              5 |        2 | 2                | 200000299         |
|               7 |              6 |        2 | 2                | 200000277         |
|               8 |              8 |        2 | 2                | 200000275         |
|               9 |              7 |        2 | 2                | 200000002         |
+-----------------+----------------+----------+------------------+-------------------+

// As you can see above, my invoice increment_last_id is way behind my order increment_last_id.
// Here is a query you might run to get them to match.


update eav_entity_store set increment_last_id="100006819" where entity_type_id="6" and store_id="1";
affiliate_link
Learn PHP
comments powered by Disqus
Proudly hosted on Digital Ocean