When checking the system.log I found an error that relates to PayPal refusing to take a payment due to a duplicate ID.
Payment has already been made for this InvoiceID
system.log error;
2020-03-25 21:19:40] main.CRITICAL: Exception message: PayPal gateway has rejected request. Payment has already been made for this InvoiceID (#10412: Duplicate invoice).
Trace: <pre>#1 Magento\Framework\ObjectManager\Factory\Compiled->create(‘Magento\Framewor…’, array(‘phrase’ => &Magento\Framework\Phrase#000000007f7924f00000000053e3460e#)) called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56]
#2 Magento\Framework\ObjectManager\ObjectManager->create(‘\Magento\Framewo…’, array(‘phrase’ => &Magento\Framework\Phrase#000000007f7924f00000000053e3460e#)) called at [generated/code/Magento/Framework/Exception/LocalizedExceptionFactory.php:43]
#3 Magento\Framework\Exception\LocalizedExceptionFactory->create(array(‘phrase’ => &Magento\Framework\Phrase#000000007f7924f00000000053e3460e#)) called at [vendor/magento/module-paypal/Model/Api/Nvp.php:1307]
#4 Magento\Paypal\Model\Api\Nvp->_handleCallErrors(array(‘TIMESTAMP’ => ‘2020-03-25T21:19…’, ‘CORRELATIONID’ => ‘cc62b99802d56’, ‘ACK’ => ‘Failure’, ‘VERSION’ => 72.0, ‘BUILD’ => 54364458, ‘L_ERRORCODE0’ => 10412, ‘L_SHORTMESSAGE0’ => ‘Duplicate invoic…’, ‘L_LONGMESSAGE0’ => ‘Payment has alre…’, ‘L_SEVERITYCODE0’ => ‘Error’)) called at [vendor/magento/module-paypal/Model/Api/Nvp.php:1243]
What causes the Payment has already been made for this InvoiceID error
In my case this error is likely a result of duplicate order numbers. The website was updated in a staging environment to fix a series of URL rewrite and other bacxkend issues. Orders on the live site weren’t migrated back to the dev server before being moved to production. These order IDs are now being reused.
In order to fix that you will need to choose to accept payments with the same Invoice ID and not to block payments when the Invoice ID was already used.
Go to your PayPal account setting and find the ‘block accidental payments‘ option to enable duplicate invoice payments.
Block accidental payments
Here’s the direct preferences link to switch the ‘No, allow multiple payments per invoice ID’ option on.
The old option to ‘Allow multiple payments per invoice ID’ used to be found under;
My Account > Profile > My Selling Tools > Credit Card Statement Name > “Allow multiple payments per invoice ID”.