First of all you need to create a 2CO account from : https://www.2checkout.com
To setup the callback process for 2CheckOut to automatically mark invoices paid, go to the Look & Feel section of your 2CheckOut account and set "Direct Return" to Yes and the "Approved URL" to http://www.yourdomain.com/whmcs/modules/gateways/callback/2checkout.php
For added security, on the same page you can set a "Secret Word". If you set this, in the payment gateway configuration page of your WHMCS system, enter the same secret word so that WHMCS can verify that the callbacks it receives are coming from 2CheckOut.
Please note when using demo mode, that all callbacks will fail with the error MD5 Hash Failure if a secret word is specified. This is done intentionally by 2Checkout to protect those who sell digital goods from fraudulent purchases through the demo mode.