The continuous penetration of distributed energy resources (DER) in the electric power grid is driving a new paradigm shift towards transactive energy system (TES), an active and more sustainable system characterized by distributed generation and energy exchanges among consumers and producers in the network. This transition, however, comes with challenges such as dealing with the nonlinear and non-convex power flows of the system, determining an optimal transaction price to maximize overall system welfare, and ensuring fairness for all participants. In this paper, we propose a three-stage transactive energy framework that aims to address these challenges. In the first stage, the cost without trading is calculated which will serve as the reference in the profit maximization problem in the next stage. DER dispatch, power flows and initial transaction payments/incentives of the participants will then be determined in the second stage. A benefit allocation algorithm is applied in the third control stage to determine the optimal transaction price and final payments/incentives that will ensure fairness for trading participants. The proposed framework was tested in an IEEE 33-bus system and results show that fair benefits are given for all participants during trading and the system operates within the network and economic constraints.