Implemented the GetPurchases method

And code cleanup