<?php

/******************************************************************************
 *
 *	PROJECT: Flynax Classifieds Software
 *	VERSION: 4.X
 *	LICENSE: FL0M2SG681CQ - http://www.flynax.com/license-agreement.html
 *	PRODUCT: Pets Classifieds
 *	DOMAIN: pupsnshop.com
 *	FILE: PRE.GATEWAY.PHP
 *
 *	The software is a commercial product delivered under single, non-exclusive, 
 *	non-transferable license for one domain or IP address. Therefore distribution, 
 *	sale or transfer of the file in whole or in part without permission of Flynax 
 *	respective owners is considered to be illegal and breach of Flynax License End 
 *	User Agreement. 
 *
 *	You are not allowed to remove this information from the file without permission
 *	of Flynax respective owners.
 *
 *	Flynax Classifieds Software 2014 |  All copyrights reserved. 
 *
 *	http://www.flynax.com/
 *
 ******************************************************************************/

$merchant_id = $config['googleCheckout_merchant_id'];
$currency = $config['googleCheckout_currency'];
$test_mode = $config['googleCheckout_test_mode'];

$crypted_price = crypt(sprintf("%.2f",$price), str_replace('http://', '', RL_URL_HOME));

$data = $plan_id .'|'. $item_id .'|'. $account_id .'|'. $crypted_price .'|'. $callback_class .'|'. $callback_method .'|'. str_replace('&amp;', '&', $cancel_url) .'|'. str_replace('&amp;', '&', $success_url) .'|'. RL_LANG_CODE .'|'. $callback_plugin; // $callback_plugin from v4.0.2
$item = urlencode(base64_encode($data));

$continue_url = $config['mod_rewrite'] ? SEO_BASE  : RL_URL_HOME;
$notify_url = RL_PLUGINS_URL .'googleCheckout/controllers/post.gateway.php?item='. $item . '&flsessid=' . session_id() . '&total='. $price;
if ( $test_mode )
{
	$host = 'https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/'. $merchant_id;
}
else
{
	$host = 'https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/'. $merchant_id;
}

/* generate payment form */
?>
<form method="post" name="payment_form" action="<?php echo $host; ?>" accept-charset="utf-8">
	<input type="hidden" name="item_name_1" value="<?php echo $item_name; ?>" />
	<input type="hidden" name="item_description_1" value="<?php echo str_replace('{domain}', $rlValid -> getDomain(RL_URL_HOME), $lang['googleCheckout_order_description']); ?>" />
	<input type="hidden" name="item_price_1" value="<?php echo $price; ?>" />
	<input type="hidden" name="item_currency_1" value="<?php echo $currency; ?>" />
	<input type="hidden" name="item_quantity_1" value="1" />
	<input type="hidden" name="continue_url" value="<?php echo $continue_url; ?>" />
	<input type="hidden" name="shopping-cart.items.item-1.digital-content.display-disposition" value="OPTIMISTIC" />
	<input type="hidden" name="shopping-cart.items.item-1.digital-content.description" value="<?php echo $lang['googleCheckout_order_page_notice']; ?>" />
	<input type="hidden" name="shopping-cart.items.item-1.digital-content.url" value="<?php echo $notify_url; ?>" />
	<input type="hidden" name="_charset_" />
</form>