<?php 
  session_start();
    //header("Access-Control-Allow-Headers: Authorization, Content-Type");
    header("Access-Control-Allow-Origin: *");
   // header('Access-Control-Allow-Origin: http://74.208.84.251:8221/', true);
		$message=array();
		$message['msisdn']="22997977578";
		$message['amount']="1000 XOF";
		$message['firstname']="IITECH";
		$message['lastname']="BENIN";
		$message['transref']=time();
		$message['clientid']="UBHQ";
        $message['comment']="null";
 
//////////////////////////////////////////////////////////
		function callAPI($method, $url, $data){
   $curl = curl_init();
   switch ($method){
      case "POST":
         curl_setopt($curl, CURLOPT_POST, 1);
         if ($data)
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
         break;
      case "PUT":
         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
         if ($data)
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);                         
         break;
      default:
         if ($data)
            $url = sprintf("%s?%s", $url, http_build_query($data));
   }
   // OPTIONS:
   curl_setopt($curl, CURLOPT_URL, $url);
   curl_setopt($curl, CURLOPT_HTTPHEADER, array(
      //'APIKEY: 111111111111111111111',
      'Content-Type: application/json',
      'Authorization: Basic '. base64_encode("USR06:YG739G5XFVPYYV4ADJVW")
   ));
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
   // EXECUTE:
   $result = curl_exec($curl);
   if(!$result){die("Connection Failure");}
   curl_close($curl);
   return $result;
}
////////////////////////////////////////////////////////////////////////////////
 $make_call = callAPI(
	'POST',
 	'http://74.208.84.251:8221/QosicBridge/user/requestpayment',
	json_encode($message)
 	);

 $response = json_decode($make_call, true);
 
 echo $response;
/////////////////////////////////////////////////////////////////

  $_SESSION['transref']=$response['transref'];
  $_SESSION['clientid']=$message['clientid'];
?>