How to fix «Please enter a transaction ID to authorize this payment» for Authorize.NET?

Authorize.NET provides 2 testing modes:

My fix is related only to the second case: test mode for live Authorize.NET accounts.
If you enable the test mode on the both Authorize.NET and Magento sides, you will get an error: «Please enter a transaction ID to authorize this payment».
It is because Authorize.NET does not return a transaction ID in the test mode, but Magento still wrongly requires it.

How to fix

Replace the line:

with the following one:

if (!$this->getResponse()->getXTestRequest() && !$this->getResponse()->getXTransId()) {