<?php
	define('API_ENDPOINT', 'https://stage-secure-gateway.allopass.com/rest/v1');
	define('API_USERNAME', '94651717.api.allopass.com');
	define('API_PASSWORD', 'KYhTnhUHxQMrWnhiUqM3Eg0x');
	$credentials = API_USERNAME.':'.API_PASSWORD;
	$resource = API_ENDPOINT.'/hpayment';

	$curl = curl_init();

	// Request Parameters
	$data = array(
		'orderid' 			=> 'Pack500Karats',
		'operation' 		=> 'Sale',
		'payment_product' 	=> 'visa',
		'description'		=> 'Pack de 500 Karats',
		'currency'			=> 'EUR',
		'amount'			=> '10',
		'cid'				=> '100386',
	);
	
	$header = array(
	    'User-Agent: ' .$_SERVER['HTTP_USER_AGENT'],
	    'Accept: application/json', // 'text/xml' 'application/json'
	    'Accept-Language: ' . $_SERVER['HTTP_ACCEPT_LANGUAGE'],
	    'Accept-Charset:' .  $_SERVER['HTTP_ACCEPT_CHARSET']
	);

	// Options
	$options = array(
		CURLOPT_URL => $resource,
		CURLOPT_USERPWD => $credentials,
		CURLOPT_HTTPHEADER => $header,
		CURLOPT_RETURNTRANSFER => TRUE,
		CURLOPT_FAILONERROR => FALSE,
		CURLOPT_HEADER => FALSE,
		CURLOPT_POST => TRUE,
		CURLOPT_POSTFIELDS => http_build_query($data)
	);

	foreach ($options as $option => $value) 
	{
		curl_setopt($curl, $option, $value);
	}

	$result = curl_exec($curl);
	var_dump($result);
	$status = (int)curl_getinfo($curl, CURLINFO_HTTP_CODE);
	$response = json_decode($result);

	echo '<br />Payment Reference:'.$response->transactionReference;

	curl_close($curl);
?>
