<?php
include_once('system/lib/config.php');

$sys = new System();

// 変数宣言部
$rtn			= NO_STRING;
$xml			= NO_STRING;
$accountType	= NO_STRING;

try {

// 	$uid = $sys -> createUId();

	$uid = '25672fb0956a48dba87751407c220864';
	//XMLデータの生成（共通項目）
	$xml =	'<?xml version="1.0" encoding="UTF-8"?>'
				. '<R>'
				. '<R1>' . $uid . '</R1>'
				. '<R2></R2>'
				. '<R3>840</R3>'
				. '<R4>1000</R4>'
				. '<R5>FirstName</R5>'
				. '<R6></R6>'
				. '<R7>LastName</R7>'
				. '<R8>GROUND FLOOR 2 WOODBERRY</R8>'
				. '<R9>GROVE ENGLAND </R9>'
				. '<R10>LONDON</R10>'
				. '<R11></R11>'
				. '<R12>N12 0DR</R12>'
				. '<R13>GB</R13>'
				. '<R14>NotificationURL</R14>'
				. '<R15>https://test.iwl.world/test_payment_receive?u_id=' . $uid . '</R15>'
				. '<R16>https://test.iwl.world/test_payment_receive?u_id=' . $uid . '</R16>'
				. '<udf>PFS|435</udf>'
				. '</R>';

	// 送信データの生成
	$post = array('Username'	=> 'iPaymentsAPI'
			, 'Password'		=> 'ow9F4WqiA'
			, 'APISignature'	=> 'registerpayment'
			, 'MessageID'		=> $uid
			, 'Data'			=> $xml
	);
// echo $xml;
	// 接続URL
	$url = 'https://staging.prepaidfinancialservices.com/acqapi/service.ashx';

	http_build_query($post);

	// ポスト送信
	header("Content-type: application/xml");

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	$result = curl_exec($ch);
	curl_close($ch);
print_r($result);
return;
	// データ取り出し部
	$result = simplexml_load_string($result);

	$sys -> accessModify('INSERT_PAYMENT_CARD', array($uid));

	// データの取り出し
	header("Content-type: text/html;charset=UTF-8");
	header('Location: ' . $result -> R4);

} catch(Exception $e) {
	echo $e -> getMessage();
}

?>