$order = Mage::getModel('sales/order')->load($orderId); $payment = $order->getPayment(); $transactionId = $payment->getLastTransId();In this example, we load an order object using its ID, and then retrieve the payment object associated with the order. We then call the getLastTransId method on the payment object to retrieve the transaction ID for the payment. This code example is part of the Magento library package, as Varien_Object is a core component of the Magento framework.