Please make sure these is no data output or blank spaces above wp_redirect( $final_url ); exit;
otherwise this warning will always appear.
Also optionally you can use
<?php
//Php code
?>
<script type="text/javascript">
document.location.href="http://example.com";
</script>
<?php
//php code
?>