I currently have a custom shopping cart which sends straight to 2Checkout and need to use the same form for different payment methods.
To do this I need to get the form to submit to my own server first, then the server to redirect to the chosen payment gateway OR a page on my site detailing other payment options.
How would I go about redirecting the user with the variables as a post method in PHP (not javascript)?
My current code doesn't work as the user doesn't leave the page and they need to...
//$url = 'https://www.2checkout.com/checkout/spurchase'; $url = 'getpost.php'; //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1); // RETURN THE CONTENTS OF THE CALL //execute post $result = curl_exec($ch); //close connection curl_close($ch);