<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
</head>
<body>
	<?php 
		echo $this->lang->line('js_text_processing');
		
		$merchat_id = PG_SUREPAY_SGD_MERCHANT_ID;
		$api_key = PG_SUREPAY_SGD_KEY;
		$post_url = PG_SUREPAY_SGD_PAY_URL;
		$currency_code = 'SGD';
		switch($order['payment_method']) {
			case 19: $merchat_id = PG_SUREPAY_THB_MERCHANT_ID; $api_key = PG_SUREPAY_THB_KEY; $post_url = PG_SUREPAY_THB_PAY_URL; $currency_code = 'THB'; break;
			default: $merchat_id = PG_SUREPAY_SGD_MERCHANT_ID; $api_key = PG_SUREPAY_SGD_KEY; $post_url = PG_SUREPAY_SGD_PAY_URL; $currency_code = 'SGD'; break;
		}
				
		$amount = (isset($order['transaction_amount']) ? number_format($order['transaction_amount'], 2, '.', '') : '0.00');
		$language = 'en';
		$bank = (isset($order['bank_code']) ? $order['bank_code'] : '');
		$ip = $this->input->ip_address();
		$token = '';
		
		if(isset($order['order_no']) && isset($order['to_member_username'])) {
			$token = md5($merchat_id . $amount . $order['order_no'] . $order['to_member_username'] . $api_key . $currency_code . $ip);
		}
	?>
	<form id='paysubmit' name='paysubmit' method="post" action="<?php echo $post_url;?>" style="display: none;"> 
		<input type="hidden" name="merchant" value="<?php echo $merchat_id;?>" />
		<input type="hidden" name="amount" value="<?php echo $amount;?>" />
		<input type="hidden" name="refid" value="<?php echo (isset($order['order_no']) ? $order['order_no'] : '');?>" />
		<input type="hidden" name="token" value="<?php echo $token;?>" />
		<input type="hidden" name="customer" value="<?php echo (isset($order['to_member_username']) ? $order['to_member_username'] : '');?>" />
		<input type="hidden" name="currency" value="<?php echo $currency_code;?>" />
		<input type="hidden" name="language" value="<?php echo $language;?>" />
		<input type="hidden" name="bankcode" value="<?php echo $bank;?>" />
		<input type="hidden" name="clientip" value="<?php echo $ip;?>" /> 
		<input type="hidden" name="post_url" value="<?php echo base_url() . 'callback/notify/' . $order['payment_method'] . '/';?>" /> 
		<input type="hidden" name="failed_return_url" value="<?php echo base_url() . 'callback/failed/' . $order['payment_method'] . '/';?>" /> 
		<input type="hidden" name="return_url" value="<?php echo base_url() . 'callback/success/' . $order['payment_method'] . '/';?>" /> 
	</form>
	<script style="text/javascript">document.forms['paysubmit'].submit();</script>
</body>
</html>