PHP :: Emulate
, forwarding user to page

curlphpprotx

I'm working on a PHP application that links into the Protx VSP Direct payment gateway. To handle "3D Secure" requests from the credit card processing company, I need to forward the user to a different website, mimicking a form that has been posted. I'm trying to use the cURL libraries, but seem to have hit a problem. My code is the following:

<?php  
$ch = curl_init();  
// Set the URL  
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/');  
// Perform a POST  
curl_setopt($ch, CURLOPT_POST, 1);  
// If not set, curl prints output to the browser  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);   
// Set the "form fields"  
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);  
$output = curl_exec($ch);  
curl_close($ch);  
?>  

All this does is grab the content of the URL passed through, and doesn't forward the user anywhere. I've tried Googling and reading up as much as I can, but can't figure out what i'm missing. Any ideas? I don't want to have to create a HTML form that auto-submits itself if I can avoid it.

Thanks for any help 🙂

Best Solution

The 3D Secure API doesn't allow you to do the request in the background. You need to forward the user to the 3D secure site. Use javascript to automatically submit your form. Here's what our provider suggests:

<html> 
    <head> 
        <title>Processing your request...</title> 
    </head> 
    <body OnLoad="OnLoadEvent();"> 
        <form name="downloadForm" action="<%=RedirURL%>" method="POST"> 
            <noscript> 
                <br> 
                <br> 
                <div align="center"> 
                    <h1>Processing your 3-D Secure Transaction</h1> 
                    <h2>JavaScript is currently disabled or is not supported by your browser.</h2><BR> 
                    <h3>Please click Submit to continue the processing of your 3-D Secure transaction.</h3><BR> 
                    <input type="submit" value="Submit"> 
                </div> 
            </noscript> 
            <input type="hidden" name="PaReq" value="<%=PAREQ%>"> 
            <input type="hidden" name="MD" value="<%=TransactionID%>"> 
            <input type="hidden" name="TermUrl" value="<%=TermUrl%>"> 
        </form> 
        <SCRIPT LANGUAGE="Javascript"> 
            <!-- 
            function OnLoadEvent() { 
                document.downloadForm.submit(); 
            } 
            //--> 
        </SCRIPT> 
    </body> 
</html>
Related Question