<?php
 if(isset($_GET['action']) && $_GET['action'] == 'get_session_id'){
   $creaturl = (defined('MODULE_PAYMENT_LOADEDPAYMENTS_TESTMODE') && MODULE_PAYMENT_LOADEDPAYMENTS_TESTMODE != 'Test') ? 'https://secure1.payleap.com/TransactServices.svc/CreateTransactionSession' : 'https://uat.payleap.com/TransactServices.svc/CreateTransactionSession'; 
   $creaturl.'?UserName='.$_POST['UserName'].'&Password='.$_POST['Password'];
   $curl_url = $creaturl.'?UserName='.urlencode($_POST['UserName']).'&Password='.urlencode($_POST['Password']);
   $crl = curl_init();
   curl_setopt($crl, CURLOPT_URL, $curl_url);
   curl_setopt($crl, CURLOPT_FRESH_CONNECT, true);
   curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
   $response = curl_exec($crl);
   if(!response){
      die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
   }
   curl_close($crl);
   $repdata = simplexml_load_string($response); 
   $encodedata = json_encode($repdata); 
   $dataarr = json_decode($encodedata, true); 
   if(isset($dataarr['SessionId']) && $dataarr['SessionId'] != ''){
     echo $dataarr['SessionId'];
   }else{
   echo 'ERROR';
   }
   exit;
 }



?>