<?php
ini_set('soap.wsdl_cache_ttl', 1);
ini_set("soap.wsdl_cache_enabled", WSDL_CACHE_NONE);

$client = new SoapClient("https://ws.hipay.com/soap/payment-v2?wsdl",
    array('features' =>  SOAP_SINGLE_ELEMENT_ARRAYS, 'trace' => 1));

$parameters = new stdClass();
$freeData = array();
$aFreeData1 = new stdClass();
$aFreeData1->key = "keyOne";
$aFreeData1->value = "aValueOne";
    
$aFreeData2 = new stdClass();
$aFreeData2->key = "keyTwo";
$aFreeData2->value = "aValueTwo";
    
$freeData[] = $aFreeData1;
$freeData[] = $aFreeData2;

$affiliates = array();

$affiliate1 = new stdClass();
$affiliate1->name = "First Affiliate";
$affiliate1->hipayAccountId = "123786";
$affiliate1->amount = "10%";
        
$affiliates[] = $affiliate1;
        
$parameters->parameters = array(
	'wsLogin'			=>	'', 	// Your webservice login
	'wsPassword'		=>	'',  //  Your webservice password
   	'websiteId' 		=>  '',  // Your website id 
   	'categoryId' 		=>  '428', 		// Your site category id
   	'currency' 			=>  'EUR', 
   	'amount' 			=>  '20.55', 
   	'rating' 			=>  'ALL', 
   	'locale' 			=>  'fr_FR', 
   	'customerIpAddress' =>  '127.0.0.0', 
	'executionDate' 	=> 	date('Y-m-dTH:i:s', time()),
   	'manualCapture' 	=>  '0', 
   	'description' 		=> 	'My order description',
   	'customerEmail' 	=>  'customer@mail.com', 
	'urlCallback' 		=>  'http://www.mysite.com/hipay/callback.php', 
   	'urlAccept' 		=>  'http://www.mysite.com/hipay/Accept.php', 
   	'urlDecline' 		=>  'http://www.mysite.com/hipay/Decline.php', 
   	'urlCancel' 		=>  'http://www.mysite.com/hipay/Cancel.php',
	'urlLogo' 			=>  'https://www.mysite.com/hipay/logo.png', 
	'merchantReference' => 	'REF123456',
	'merchantComment' 	=> 	'Order REF123456',
   	'emailCallback' 	=>  'callback@merchant.com', 
   	'freeData' 			=> 	$freeData,
   	'affiliates' 		=> 	$affiliates,
	
);

$response = $client->generate($parameters);

//header('Content-Type: text/xml; charset=UTF-8');
echo $client->__getLastRequest();
echo $client->__getLastResponse();

?>

