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

define('WS_GATEWAY','https://test-ws.hipay.com/soap/');
define('WS_LOGIN', 'd4a919efc4843389def7d56922c56c58'); // hipay@lrqdo.fr
define('WS_PSW', 'a2e33c6fdad9cbd3685cbf3fe8c868e0'); // hipay@lrqdo.fr
$request_id = $_REQUEST['request_id'];
$subaccount = $_REQUEST['marchand'];
$websiteid 	= $_REQUEST['websiteid'];
$email		= $_REQUEST['email'];
$amount		= $_REQUEST['amount'];

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

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


$parameters = new stdClass();
$parameters->parameters = array(
   'wsLogin' 			=>  WS_LOGIN,
   'wsPassword' 		=>  WS_PSW,
   'websiteId' 			=>  $websiteid, 
   'merchantReference' 	=>  'Order Reference', 
   'customerIpAddress' 			=>  '127.0.0.0', 
   'customerEmail' 		=>  $email, 
   'description' 		=>  'Order Label', 
   'amount' 			=>  $amount, 
   'currency' 			=>  'EUR', 
   'emailCallback'	 	=>  'callback@lrqdo.com', 
   'urlCallback' 		=>  'http://www.lrqdo.com/hipay/callback.php', 
   'urlAccept' 			=>  'http://www.lrqdo.com/hipay/Accept', 
   'urlDecline' 		=>  'http://www.lrqdo.com/hipay/Decline', 
   'urlCancel' 			=>  'http://www.lrqdo.com/hipay/Cancel',
   'categoryId' 		=>  '225', 
   'executionDate' 		=> 	date('Y-m-dTH:i:s', time()),
   'manualCapture' 		=>  '1', 
   'locale' 			=>  'fr_FR', 
   'rating' 			=>  'ALL', 
   'freeData' 			=> 	$freeData,
   'wsSubAccountId' 	=>  $subaccount,
   'merchantComment' 	=> 'Comment Test LRQDO' 
);

$response = $client->generate($parameters);
header("Location: " . $response->generateResult->redirectUrl);
?>
