Cleaned up code for saving payments to db