ecommerce calls the payment-gateway service when an order is made. The payment-gateway interfaces with the specific gateway packages.
Depending on your trigger strategy, take a look at ecommerce/tcl/ecommerce-scheduled-procs.tcl or ecommerce/tcl/ecommerce-credit-procs.tcl
cheers,
Torben