php - sending post/get request to another site without leaving current site -


i developing payment confirmation module. when buyer confirms payment, gateway redirects him/her success url as:

http://mysite.com/success.php?oid=p01&amt=100&refid=txn3456

the gateway has provision verify current transaction using transaction verification url as:

https://paymentgateway.com/epay/transverify.php?oid=p01&amt=100&refid=txn3456

this url accepts post/get requests , returns xml response as

<response> <status>success</status> </response> 

or

<response> <status>failed</status> </response> 

now problem how can send confirmation request gateway without leaving site, can update order payment status on successful verification response. solution tried send ajax request payment gateway, may due cross domain request limitation, not able so. other method send request , response?

ok per suggestion used curl response successfully, :)

my code:

<?php  $ch = curl_init();  curl_setopt($ch, curlopt_url, "https://paymentgateway.com/epay/transverify.php"); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_post, 1);  $data = array( 'oid' => 'p01', 'amt' => '100', 'rid' => 'txn3456' );  curl_setopt($ch, curlopt_postfields, $data);  $contents = curl_exec($ch);  curl_close($ch);  echo $contents; ?> 

i need simple thing now, how compare result success or failed? returned result ($contents) xml data? thanks!

use simplexml_load_file

<?php  $xml = simplexml_load_file($your url);  print_r($xml);  ?> 

simply got array response.


Comments