@QMcKay posted a great tutorial about script processor usage.
That demonstrates how to receive payment info, do something, send info back or break payment process operation.
PS: I have to say you’ll need some JScript code to be able to fulfill your requirements. Maybe you should evaluate Command based solutions first but you won’t have much control on how payments processed.