By default, magento set the paypal invoice number (INVNUM
) equal to the order increment id. This is a good practice because it allows you to have a one to one mapping between your order and the transaction.
You may get this error message if you or your teammates have sent the same invoice number to paypal before using the same paypal sandbox account. I would suggest you to add the hostname and username as the prefix of the invoice number and add the timestamp as suffix, so that the invoice number will always be unique when you are testing your checkout process. For paypal express checkout, I added the following codes right before if it sends the request in the callSetExpressCheckout
method in app/code/community/Mage/Paypal/Model/Api/Nvp.php
:
// if it's in the testing mode, add a prefix to avoid duplicates
if (Mage::getStoreConfig('paypal/wpp/sandbox_flag')) {
$processUser = posix_getpwuid(posix_geteuid());
$request["INVNUM"] = gethostname().'-'.$processUser['name'].'-'.$request['INVNUM'].'-'.time();
}