﻿<?php

#Create Post Information
// Account vars
$vars =  array();


$vars['Oparation'] = "SetModules";
$vars["UserName"] = "SuppUserName"; // delar user name
$vars["Password"] ="SuppPassword"; // delar password 
$vars["Secret"] = "SuppSecret"; // delar Secret 
$vars['codepage'] = '65001'; // unicode


// ******************
// Terminal Info 
// ******************
// Req :
$vars['TerminalInfo.TerminalNumber'] = '1000'; //  

// ******************
// Modules to set
// ******************

$vars['TerminalInfo.ModuleList1.ModuleID'] = 'Module1'; 
$vars['TerminalInfo.ModuleList2.ModuleID'] = 'Module2'; 



// Send Data To Bill Gold Server
$r = PostVars($vars,'https://secure.cardcom.solutions/Interface/CompanyOperations.aspx');

//echo $r;

parse_str($r,$responseArray);
if($responseArray['ResponseCode']==0)
{
  // Save In DB:
    echo "Description: " . $responseArray['Description'];
}
else
{
    echo "ResponseCode : " . $responseArray['ResponseCode'];
    echo "<br/>";
    echo "Developer  Error ! send email alert : " . $responseArray['Description'];
}


function PostVars($vars,$PostVarsURL)
{
  $urlencoded = http_build_query($vars);
  #init curl connection
  if( function_exists( "curl_init" )) 
  { 
     $CR = curl_init();
    curl_setopt($CR, CURLOPT_URL, $PostVarsURL);
    curl_setopt($CR, CURLOPT_POST, 1);
    curl_setopt($CR, CURLOPT_FAILONERROR, true);
    curl_setopt($CR, CURLOPT_POSTFIELDS, $urlencoded );
    curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($CR, CURLOPT_FAILONERROR,true);
    #actual curl execution perfom
    $r = curl_exec( $CR );
    $error = curl_error ( $CR );
    # some error , send email to developer
    if( !empty( $error )) {

      echo $error;

      die();
    }
   curl_close( $CR );
   return $r;
 }
  else
 {
  echo "No curl_init" ;
  die();
  }
}

?>