I still think this can be done somehow (riding on intuition here) by calling an external file, that would trigger the mail, or by creating a class to help perform the task.
What exactly do you want done? We've told you that you have to use the mail() function to send an email. Fine. Now you want to integrate with a merchant service. Well which service? Is it something like PayPal with IPN (which they've documented) or is it something else?
Have you ran your own test to do the following:
1.) Send payment to the merchant (from yourself to yourself)
2.) have the merchant service post-back to your script
3.) Dump out all the variables (POST, GET, Cookie, Session) to see what's there?
Most likely that will solve your problems, but you haven't said exactly what you're trying to do, and every time you say it, it changes to something different than Befor 😉 ( I crack myself up some times....)
this email will verify if the merchant postback is made shortly afterward -- it will serve as a cue to look for the postback(not much leeway for a real-time e-service, which this is). Also, my gateway only makes a single postback attempt, another reason I'm starting to become email-reliant.
Sounds like PayPal's IPN service. You would want the merchant service to return the user to your script which will look for the posted information and send an email. Or something like that.