Here is a minimal javascript answer from a PHP Programmer like myself:
/** This is the script that will redraw current screen and submit to bank. */
echo '<script>'."\n" ;
echo 'function serverNotifySelected()'."\n" ;
echo '{'."\n" ;
echo ' window.open(\'\', \'BankPaymentScreen\');'."\n" ;
echo ' document.forms[\'bank_form\'].submit();'."\n" ;
echo ' document.forms[\'server_responder\'].submit();'."\n" ;
echo '}'."\n" ;
echo '</script>'."\n" ;
/** This form will be opened in a new window called BankPaymentScreen. */
echo '<form action="https://www.sandbox.bank.com/cgi-bin/webscr" name="bank_form" method="post" target="BankPaymentScreen">'."\n" ;
echo '<input type="hidden" name="cmd" value="_s-xclick">'."\n" ;
echo '<input type="hidden" name="custom" value="'.$transaction_start.'">'."\n" ;
echo '<input type="hidden" name="hosted_button_id" value="'.$single_product->hosted_button_id.'">'."\n" ;
echo '<table>'."\n" ;
echo ' <tr>'."\n";
echo ' <td><input type="hidden" name="'.$single_product->hide_name_a.'" value="'.$single_product->hide_value_a.'">Local</td>'."\n" ;
echo ' </tr>'."\n" ;
echo ' <tr>'."\n" ;
echo ' <td>'."\n" ;
echo ' <input type="hidden" name="'.$single_product->hide_name_b.'" value="'.$single_product->hide_value_b.'" />'.$single_product->short_desc.' $'.$adj_price.' USD'."\n" ;
echo ' </td>'."\n" ;
echo ' </tr>'."\n" ;
echo '</table>'."\n" ;
echo '<input type="hidden" name="currency_code" value="USD">'."\n" ;
echo '</form>'."\n" ;
/** This form will redraw the current page for approval. */
echo '<form action="ProductApprove.php" name="server_responder" method="post" target="_top">'."\n" ;
echo '<input type="hidden" name="trans" value="'.$transaction_start.'">'."\n" ;
echo '<input type="hidden" name="prod_id" value="'.$this->product_id.'">'."\n" ;
echo '</form>'."\n" ;
/** No form here just an input and a button. onClick will handle all the forms */
echo '<input type="image" src="https://www.sandbox.bank.com/en_US/i/btn/btn_purchaseimmediateCC_LG.gif" border="0" alt="This Bank - The safer, easier way to pay!" onclick="serverNotifySelected()">'."\n" ;
echo '<img alt="" border="0" src="https://www.sandbox.bank.com/en_US/i/scr/pixel.gif" width="1" height="1">'."\n" ;
This is the code for one button. The button will redraw the current page to go from purchasing to pre-approval AND also open a new window, give the new window focus and pass the new focused window to the payment provider.
This also prevents Chrome from blocking the new page from getting focus.