doPayment dupeCheck will always return FALSE
This is the line in CRM_Core_Payment_AuthorizeNetCommon::doPayment()
that checks for duplicate contributions:
// Authorize.Net will not refuse duplicates, so we should check if the user already submitted this transaction
if ($this->checkDupe($this->getInvoiceNumber($propertyBag), $params['contributionID'] ?? NULL)) {
However, getInvoiceNumber()
truncates the invoice number to 20 characters, then compares it with the unabridged value stored on the contribution. So it will never return TRUE
.
Now I only discovered this because I was working with the legacy processor, which doesn't use a PropertyBag, and had a different bug. The fact that this hasn't come up in any production usage suggests that the duplicate check has outlived its purpose. But this if
block should either be removed or getInvoiceNumber()
replaced with a more suitable function.