Hi!

I can't seem to find any documentation on writing payment-modules.
I've been working on one lately, but I'm stuck at this point:

I want to forward the user to the external terminal after he hits the "confirm order" button, then when he comes back, insert the order.

I can manage to get the order registered before the user goes to the terminal, but that will not do if the user cancels the payment. He will then have registered the order without payment and gets confirmation mail.

Is there any detailed explanation on the payment module functions (pre_confirmation_check(), confirmation(), process_button(), before_process(), after_process() etc.)?