How to automate bitcoin wallet to send return payments to website subscribers? When a .onion website sells subscription log-in accounts, they ask for subscription payment and say that a return payment will be received immediately after, containing the payment code for creating a user account.
For example, the subscription might cost 0.001 BTC, so if the new subscriber pays that, and she receives 0.0002713 BTC afterwards as a return payment, then the new user can create their account by entering the following fields in the registration form:

Username
Password
Payment Code: 2713

How can a bitcoin wallet even be programmed to automatically respond to incoming payments with a return payment?
and further, disguise the payment code in the return payment amount such that the form will associate a unique code to each new user (unless maybe they are just fixing the payment code to be identical for all users)
How can a bitcoin wallet even be programmed to automatically respond to incoming payments with a return payment?

What is a bitcoin wallet, exactly? It can be just about anything that is programmed to create keys, check UTXOs and build/sign transactions... A bitcoin wallet can be programmed to do just about anything.
Your question is broad... You need to program it yourself. Build a database to keep track of addresses and payment codes and whatever else then build your site to interact with your database and your wallet, or build your own wallet.