I am trying to post some details to mygate payment gateway. If i use a normal form and post to the url, it generates a token id for that specific session and internally redirects the page to the details capturing page. As i am using curl to do so, i get a success message but i am unable to get the required page. Is it possible to load the same page in a new tab using curl, I suspect that would help me in some way. Any other solution would also be appreciated. Code i have tried is:
1234567891011121314151617181920212223242526272829$ch = curl_init();//set the url, number of POST vars, POST datacurl_setopt($ch,CURLOPT_URL, $url);curl_setopt($ch,CURLOPT_POST, count($fields));curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);curl_setopt($ch, CURLOPT_VERBOSE,true);curl_setopt($ch, CURLOPT_SSLVERSION, 3);curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);//turning off the server and peer verification(TrustManager Concept).curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);$result = curl_exec($ch);if(!$result){echo curl_error($ch);}else{echo $result;}//close connectioncurl_close($ch);
Wednesday, 26 June 2013
CURL PHP MyGate Payment gateway
Subscribe to:
Post Comments
(
Atom
)
Since its redirecting to a page on success, You can get the location of the redirected url.
ReplyDeleteYou can get the redirect URL by setting some curl options.
?
1
2
3
4
5
6
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$a = curl_exec($ch);
if(preg_match('#Location: (.*)#', $a, $r))
$l = trim($r[1]);
$l would be the redirect location. You can get the url and redirect your page to the location.
$r will contain an array with location url.
learn more from www.drtuts.com
ReplyDelete