Added Invalid payment state and some DRY things ;)