refactor payment state machine