Section 40. Power to Acquire Own Shares.— Provided that the corporation has unrestricted retained earnings in its books to cover the shares to be purchased or acquired, a stock corporation shall have the power to purchase or acquire its own shares for a legitimate corporate purpose or purposes, including the following cases:
To eliminate fractional shares arising out of stock dividends;
To collect or compromise an indebtedness to the corporation, arising out of unpaid subscription, in a delinquency sale, and to purchase delinquent shares sold during said sale; and
To pay dissenting or withdrawing stockholders entitled to payment for their shares under the provisions of this Code.