How to create a new payment gateway

Hi all,



I am trying to implement a new payment gateway (Sparkassen-Internetkasse, Austria). The client is sent to an external bank page in order to enter his/her credit card data (callback = “N” in payment_processors in DB). After this, the client is sent back to my site and a page that I gave the bank earlier in the process. I´ve got all this working.



The bank requires that this landing page contains nothing more than a link to a page on my site (order success/failure etc).



Now, my question is, how do I



(1) Create the order and assign the “P” processed status

(2) Give the user a message (“the green box”)

(3) Empty the shopping cart



I´ve dedicated too many hours and I just cant seem to find a solution. I´ve tried many things like:



fn_finish_payment($order_id, $pp_response);

fn_order_placement_routines($order_id);

fn_change_order_status(‘436’, ‘P’, ‘’, false);



but I dont really understand the finish_payment and order_placement parts.



The PHP code above has to go before the link that I mentioned earlier, I suppose.



Furthermore I dont understand the “if (defined(‘PAYMENT_NOTIFICATION’))”. When/how is this triggered?



Enormously thankful for ANY help!