If you did $payment->setLastTransId and ->setCcTransId. , the transaction id will be saved to order payment when you saved the order.
Mangento order payment is EAV structure.
To retrieve the transaction_id for the payment:
FROM eav_attribute eav
INNER JOIN eav_entity_type etype ON etype.entity_type_id=eav.entity_type_id AND etype.entity_type_code='order_payment'
WHERE eav.attribute_code IN ('cc_trans_id','last_trans_id');
use the attribute_id received from the above query
SELECT * FROM sales_order_entity_varchar WHERE attribute_id IN (263,817);,
From the above query, you can see what transaction_id value saved to the order payment.