Timeout handling and transaction reference updates

Updated to handle timeouts in requests, create a transaction record before processing and use the transaction ID in the gateway reference.

@supermario Could you please cast your eye over this and let me know if there are any issues? Thanks!