<?php
/**copyrights**/

$reefless -> loadClass( 'Actions' );
$reefless -> loadClass( 'CCAvenue', null, 'ccAvenue' );

$price = number_format( $price, 2 );

$data = $plan_id . '|' . $item_id . '|' . $account_id . '|' . $price . '|' . $callback_class . '|' . $callback_method . '|' . $cancel_url . '|' . $success_url . '|' . RL_LANG_CODE . '|' . $callback_plugin;
$data = base64_encode( $data );

$redirect_url = RL_PLUGINS_URL . 'ccAvenue/controllers/post.gateway.php';
//$payment_url = $GLOBALS['config']['ccavenue_currency'] == 'USD' ? 'https://world.ccavenue.com/servlet/ccw.CCAvenueController' : 'http://www.ccavenue.com/shopzone/cc_details.jsp'; 
$payment_url = 'http://www.alegrocart.com/gateway/ccavenue_test.php';
$txn_id = $reefless -> generateHash( 8, 'upper' );
$checksum = $rlCCAvenue -> getchecksum( $GLOBALS['config']['ccavenue_merchant_id'], $price, $txn_id, $redirect_url, $GLOBALS['config']['ccavenue_working_key'] );

$insert = array(
		'Txn_id' => $txn_id,
		'Item' => $data,
		'Date' => 'NOW()'
	);

$rlActions -> insertOne( $insert, 'ccavenue_transactions' );
?>
<form name="payment_form" action="<?php echo $payment_url; ?>" method="post">
	<input type="hidden" name="Merchant_Id" value="<?php echo $GLOBALS['config']['ccavenue_merchant_id']; ?>" />
	<input type="hidden" name="Amount" value="<?php echo $price; ?>" />
	<input type="hidden" name="Order_Id" value="<?php echo $txn_id; ?>" />
	<input type="hidden" name="Currency" value="<?php echo $GLOBALS['config']['ccavenue_currency']; ?>" />
    <input type="hidden" name="Redirect_Url" value="<?php echo $redirect_url; ?>" />
	<input type="hidden" name="TxnType" value="A" />
	<input type="hidden" name="actionID" value="TXN" />
	<input type="hidden" name="Checksum" value="<?php echo $checksum; ?>" />
</form>