<?php

ini_set('display_errors','On');
$wsdl = 'https://test-ws.hipay.com/soap/subscription?wsdl';
$options = array(
	'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
	'cache_wsdl' => WSDL_CACHE_NONE,
);
try{
	$client = new SoapClient($wsdl, $options);
	//$result = $client->__soapCall('process', array(
	$result = $client->process(array(
		'wsLogin' => 'aa24730301681c867a22a66302d9051f',
		'wsPassword' => '8ea1cf040c69680a22a08e5b7c74848e',
		'websiteId' => '317107',
		'categoryId' => '149',
		'customerEmail' => 'arnaudpons@gemperles.com',
		'currency' => 'EUR',
		'rating' => 'ALL',
		'locale' => 'fr_BE',
		'label' => 'Test Order for Gemperles', 
		'customerIpAddress' => $_SERVER['SERVER_ADDR'], 
		'merchantReference' => '50287375028737',
		'merchantDatas' => 'Affiliation',
		'urlCallback' => 'http://sbu2.magentoprojects.net/hipay/notification.php',
		'urlAccept' => 'http://sbu2.magentoprojects.net/hipay/test.php',
		'urlDecline' => 'http://sbu2.magentoprojects.net/hipay/test.php',
		'urlCancel' => 'http://sbu2.magentoprojects.net/hipay/test.php',

		'payments' => array(
			'initial' => array(
				'name' => 'Paiement N°1',
				'amount' => 5,
				'recurrence' => array(
					'frequency' => 1,
					'duration' => 'month',
				),
				'description' => 'Paiement récurrent 01',
				'periodType' => 'normal',
				'manualCapture' => 'no',
			),

		   'repayment' => array(
				array(
					'name' => 'Paiement N°2',
					'description' => 'Paiement récurrent 02',
					'amount' => 5,
					'executionTimestamp' => '2016-03-09T09:00:00+00:00',
				)
			),
		),
	));
}catch(SoapFault $fault) {
    trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}

if (isset($result->redirectUrl))
{
	echo '<a href="' . $result->redirectUrl . '" target="_blank">$result: ' . $result->redirectUrl . '</a>';
}
print_r($result);

?>
