On the confirm page, the hidden form element that sets the transaction ID is the cartId element, by default, this will be set to use the session ID:
<input type="hidden" name="cartId" id="cartId" value="<?php echo session_id() ?>" />
this variable is also returned by the payment response:
pr5201.html
In the store order summary, use the session ID as the cart ID and use the cartId variable from the payment response to determine which record to update.