google payment code refactored to be more readable