added check for valid invoice before attempting to pay invoice