Manol Posted January 10, 2014 Posted January 10, 2014 I'm trying to implement a pay method, this is the code I pasted into a pw page. The problem is when I click at the bottom image (tpvirtual.jpg) I get a new blank window, but when I do it without pw as a normal php file under xampp it works ok. <?PHP // If form is submitted with all required data then show the form // else show error page empty($Formulario) ? ShowForm($Ds_Merchant_Amount,$Ds_Merchant_Currency,$prod) : ShowError(); exit; ?> <?PHP function ShowError () { echo "<html><head><title>Results</title></head><body><table width=100% height=50%><tr><td><p><h2><center>Compruebe que todos los datos del formulario son correctos!!</center></h2></p></td></tr></table></body></html>\n"; } # End of function ShowError function ShowForm ($amount,$currency,$producto) { // Posted data global $HTTP_POST_VARS; // Valores constantes del comercio $url_tpvv='https://sis-t.redsys.es:25443/sis/realizarPago'; $clave='qwertyasdf0123456789'; $name='Comercio Pruebas'; $code='272043225'; $terminal='1'; $order=date('ymdHis'); $amount='25'; $currency='978'; $transactionType='0'; $urlMerchant='http://www.redsys.es'; $producto='Zapatos'; // Now, print the HTML script echo "<html><head><title>Comercio Simulador</title></head> <script language=JavaScript> function calc() { vent=window.open('','tpv','width=725,height=600,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no'); document.forms[0].submit();} </script> <body bgcolor=white> <form name=compra action=$url_tpvv method=post target=tpv> <pre> <table> <tr><td> <h2>Comercio de prueba.</h2> </td></tr><tr><td> Comercio: <font color=blue>$name</font> </td></tr><tr><td> FUC: <font color=blue>$code</font> </td></tr><tr><td> Terminal: <font color=blue>$terminal</font> </td></tr><tr><td> Pedido: <font color=blue>$order</font> </td></tr><tr><td> Producto: <font color=blue>$producto</font> </td></tr><tr><td> Importe: <font color=blue>$amount</font> </td></tr><tr><td> Tipo de Operacion: <font color=blue>$transactionType (Autorización)</font> </td></tr><tr><td> URL del comercio: <font color=blue>$urlMerchant</font> </td></tr><tr><td>"; // Currency strings if ($currency == "978") { echo "Moneda: <font color=blue>Euros</font>"; } echo "</td> </tr><tr><td> <input type=hidden name=Ds_Merchant_Amount value='$amount'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_Currency value='$currency'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_Order value='$order'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_MerchantCode value='$code'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_Terminal value='$terminal'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_TransactionType value='$transactionType'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_MerchantURL value='$urlMerchant'> </td></tr><tr><td>"; // Compute hash to sign form data // $signature=sha1_hex($amount,$order,$code,$currency,$clave); $message = $amount.$order.$code.$currency.$transactionType.$urlMerchant.$clave; $signature = strtoupper(sha1($message)); echo "<input type=hidden name=Ds_Merchant_MerchantSignature value='$signature'> </td></tr> </table> <center><a href='javascript:calc()'><img src='/tpvirtual.jpg' border=0 ALT='TPV Virtual'></a></center> </pre> </form> </body></html>"; } # End of function ShowForm ?> Any ideas?, thanks
RyanJ Posted January 10, 2014 Posted January 10, 2014 calc function is causing it to open a new window with vent=window.open('','tpv','width=725,height=600,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no'); Try replacing it with vent=window.open('','tpv','_self','scrollbars,resizable,status=yes,menubar=no,location=no'); 1
Manol Posted January 11, 2014 Author Posted January 11, 2014 Still not working, maybe something to do with htaccess?
RyanJ Posted January 11, 2014 Posted January 11, 2014 I am confident it is the window.open method. Check out a this or this you could also try to pass _self like so. <a href='javascript:calc('_self')
fmgujju Posted January 11, 2014 Posted January 11, 2014 try this vent=window.open('tpv','_self','width=725,height=600,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no'); based on the window.open syntax: window.open(URL,name,specs,replace) For details of window.open syntax check out this link: http://www.w3schools.com/jsref/met_win_open.asp 1
matafoc Posted February 27, 2014 Posted February 27, 2014 I'm trying to implement a pay method, this is the code I pasted into a pw page. The problem is when I click at the bottom image (tpvirtual.jpg) I get a new blank window, but when I do it without pw as a normal php file under xampp it works ok. Screen Shot 2014-01-10 at 13.00.54.pngScreen Shot 2014-01-10 at 13.00.41.png <?PHP // If form is submitted with all required data then show the form // else show error page empty($Formulario) ? ShowForm($Ds_Merchant_Amount,$Ds_Merchant_Currency,$prod) : ShowError(); exit; ?> <?PHP function ShowError () { echo "<html><head><title>Results</title></head><body><table width=100% height=50%><tr><td><p><h2><center>Compruebe que todos los datos del formulario son correctos!!</center></h2></p></td></tr></table></body></html>\n"; } # End of function ShowError function ShowForm ($amount,$currency,$producto) { // Posted data global $HTTP_POST_VARS; // Valores constantes del comercio $url_tpvv='https://sis-t.redsys.es:25443/sis/realizarPago'; $clave='qwertyasdf0123456789'; $name='Comercio Pruebas'; $code='272043225'; $terminal='1'; $order=date('ymdHis'); $amount='25'; $currency='978'; $transactionType='0'; $urlMerchant='http://www.redsys.es'; $producto='Zapatos'; // Now, print the HTML script echo "<html><head><title>Comercio Simulador</title></head> <script language=JavaScript> function calc() { vent=window.open('','tpv','width=725,height=600,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no'); document.forms[0].submit();} </script> <body bgcolor=white> <form name=compra action=$url_tpvv method=post target=tpv> <pre> <table> <tr><td> <h2>Comercio de prueba.</h2> </td></tr><tr><td> Comercio: <font color=blue>$name</font> </td></tr><tr><td> FUC: <font color=blue>$code</font> </td></tr><tr><td> Terminal: <font color=blue>$terminal</font> </td></tr><tr><td> Pedido: <font color=blue>$order</font> </td></tr><tr><td> Producto: <font color=blue>$producto</font> </td></tr><tr><td> Importe: <font color=blue>$amount</font> </td></tr><tr><td> Tipo de Operacion: <font color=blue>$transactionType (Autorización)</font> </td></tr><tr><td> URL del comercio: <font color=blue>$urlMerchant</font> </td></tr><tr><td>"; // Currency strings if ($currency == "978") { echo "Moneda: <font color=blue>Euros</font>"; } echo "</td> </tr><tr><td> <input type=hidden name=Ds_Merchant_Amount value='$amount'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_Currency value='$currency'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_Order value='$order'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_MerchantCode value='$code'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_Terminal value='$terminal'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_TransactionType value='$transactionType'> </td></tr><tr><td> <input type=hidden name=Ds_Merchant_MerchantURL value='$urlMerchant'> </td></tr><tr><td>"; // Compute hash to sign form data // $signature=sha1_hex($amount,$order,$code,$currency,$clave); $message = $amount.$order.$code.$currency.$transactionType.$urlMerchant.$clave; $signature = strtoupper(sha1($message)); echo "<input type=hidden name=Ds_Merchant_MerchantSignature value='$signature'> </td></tr> </table> <center><a href='javascript:calc()'><img src='/tpvirtual.jpg' border=0 ALT='TPV Virtual'></a></center> </pre> </form> </body></html>"; } # End of function ShowForm ?> Any ideas?, thanks Hi Manol! I have the same problem. In some computers I can open de windows without problem, but in others, always show de about:blank window. I don't know what can I do :-( Can you help me? Is your tpv working now?? Thanks for all I'm form spain, so, if you want, you can reply in spanish ;-) Matafoc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now