
<?php
	//http://stackoverflow.com/questions/18382740/cors-not-working-php
	if (isset($_SERVER['HTTP_ORIGIN'])) {
        header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Max-Age: 86400');    // cache for 1 day
    }


$_SESSION['ApiToken'] = $_GET["ApiToken"];
$_SESSION['PNRef'] = $_GET["PNRef"];
$_SESSION['Amount'] = $_GET["Amount"];
$_SESSION['AuthCode'] = $_GET["AuthCode"];
$_SESSION['AuthTime'] = $_GET["AuthTime"];
$_SESSION['CardHash'] = urlencode($_GET["CardHash"]);
$_SESSION['CardReference'] = $_GET["CardReference"];
$_SESSION['CardType'] = urlencode($_GET["CardType"]);
$_SESSION['ExpireDate'] = $_GET["ExpireDate"];
$_SESSION['MerchantName'] = urlencode($_GET["MerchantName"]);
$_SESSION['PanMasked'] = $_GET["PanMasked"];
$_SESSION['PanSequence'] = $_GET["PanSequence"];
$_SESSION['SignatureCaptured'] = $_GET["SignatureCaptured"];
$_SESSION['SignatureRequired'] = $_GET["SignatureRequired"];
$_SESSION['TransSource'] = $_GET["TransSource"];
$_SESSION['TransType'] = $_GET["TransType"];
$_SESSION['DeviceId'] = $_GET["DeviceId"];
$_SESSION['TerminalID'] = $_GET["TerminalID"];


//echo 'si viene '   .$_SESSION['CardHash'] ;

function httpGet($url)
{
    $ch = curl_init();  
 
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//  curl_setopt($ch,CURLOPT_HEADER, false); 
 
    $output=curl_exec($ch);
 
    curl_close($ch);
    return $output;
}
 




$ApiToken='6C82FAD8-09A3-84BA-D772-E803157B4B1D';
$PNRef='96a343ab-cd83-4d9d-868f-2b931c3c6593';
$Amount='10.00';
$AuthCode='898989';
$AuthTime='2017-02-14+08%3A08%3A55';
$CardEaseReference='';
$CardHash=$_SESSION['CardHash'] ;
$CardReference=$_SESSION['CardReference'] ;
$NameOnCard='';
$CardType='VISA+DEBIT';
$ExpireDate=$_SESSION['ExpireDate'];
 $MerchantName='Standard+Test+Merchant';
$PanMasked=$_SESSION['PanSequence'] ;
$PanSequence='01';
$Result='0';
$SignatureCaptured='False';
$SignatureRequired='False';
$TransSource='ICC';
$TransType='Sale';
$TransVerification='PIN+VERIFIED';
$DeviceModel='Ingenico-iPP350-RBA';
$DeviceId='2214324PT012653';
$LinkedTran='343';
$TerminalID='99963246';
$LogKey='00012';
$Receipt='';



//echo httpGet("https://demo.paycertify.net/ws/encgateway2.asmx/ProcessCreditCard?ApiToken=".$ApiToken.


$ApiToken='C8A9AE83-DF32-9258-2625-6A9103E99740';
$PNRef=$_SESSION['PNRef'];
$Amount=$_SESSION['Amount'];
$AuthCode=$_SESSION['AuthCode'];
$AuthTime=$_SESSION['AuthTime'];
$CardEaseReference='';
$CardHash=$_SESSION['CardHash'];
$CardReference=$_SESSION['CardReference'];
$NameOnCard='';
$CardType=$_SESSION['CardType'] ;
$ExpireDate=$_SESSION['ExpireDate'];
 $MerchantName=$_SESSION['MerchantName'];
$PanMasked=$_SESSION['PanMasked'];
$PanSequence='01';
$Result='0';
$SignatureCaptured='False';
$SignatureRequired='False';
$TransSource='ICC';
$TransType=$_SESSION['TransType'];
$TransVerification='';
$DeviceModel='Ingenico-iPP350-RBA';
$DeviceId=$_SESSION['DeviceId'];
$LinkedTran='';
$TerminalID=$_SESSION['TerminalID'];
$LogKey='00012';
$Receipt='';
 


   $result= httpGet("https://demo.paycertify.net/ws/trxdetail.asmx/CaptureReceipt?ApiToken=".$ApiToken.
"&PNRef=".$PNRef.
"&Amount=".$Amount.
"&AuthCode=".$AuthCode.
"&AuthTime=".$AuthTime.
"&CardEaseReference=".$CardEaseReference.
"&CardHash=".$CardHash.
"&CardReference=".$CardReference.
"&NameOnCard=".$NameOnCard.
"&CardType=".$CardType.
"&ExpireDate=".$ExpireDate.
"&MerchantName=".$MerchantName.
"&PanMasked=".$PanMasked.
"&PanSequence=".$PanSequence.
"&Result=".$Result.
"&SignatureCaptured=".$SignatureCaptured.
"&SignatureRequired=".$SignatureRequired.
"&TransSource=".$TransSource.
"&TransType=".$TransType.
"&TransVerification=".$TransVerification.
"&DeviceModel=".$DeviceModel.
"&DeviceId=".$DeviceId.
"&LinkedTran=".$LinkedTran.
"&TerminalID=".$TerminalID.
"&LogKey=".$LogKey.
"&Receipt=".$Receipt);

//echo $result;




 $xmlfile = $result;
$xmlparser = xml_parser_create();


xml_parse_into_struct($xmlparser, $xmlfile ,$values);

xml_parser_free($xmlparser);

//print_r($values);

 
//print_r($values[1]);

echo (array_values($values[1])[3]);
echo ','.(array_values($values[2])[3]);
echo ','.(array_values($values[3])[3]);
echo ','.(array_values($values[4])[3]);


?>






