If the prisoner is admitted to bail and fails to appear and surrender according to the conditions of the bond or undertaking, the judge or magistrate, by proper order, shall declare the bond or undertaking forfeited, and order the immediate arrest of the prisoner if the prisoner is within this state. Recovery may be had on the bond or undertaking in the name of the state as in the case of other bonds or undertakings given by the accused in criminal proceedings within this state.