moved logic from wepayapi controller to model