state machine for payments