<?
ob_start();session_start();
include("include/db.inc.php");
include("include/bit_functions.inc.php");
$db1=new db;
$db1->open();

//***********google checkout *************///////////
  require_once('library/googlecart.php');
  require_once('library/googleitem.php');
  require_once('library/googleshipping.php');
  require_once('library/googletax.php');
//*******************************************///////


mysql_query("SET NAMES 'utf8'");
$currency_symbol_new=symbol_currency();
$uid=$_SESSION['uid'];

$oid="";
$sold_price=0;

if(is_array($_POST['productIdArr']))
{
	 foreach($_POST['productIdArr'] as $key=>$payid) {

		$oid.=$payid."_";
	 }

 $oid = substr($oid,0,-1);
}

$total_pro_qty = count($_POST['productIdArr']);
$sold_price = $_POST['pay_value'];

$google_pay = mysql_fetch_array(mysql_query("select google_pay_id,google_key from admin where type='superadmin'"));
$google_pay_id = $google_pay['google_pay_id'];
$google_pay_key = $google_pay['google_key'];

$package_name = "Product Payment";

Usecase($google_pay_id , $google_pay_key ,$sold_price , $package_name , $oid);

function Usecase($google_pay_id , $google_pay_key ,$total , $package_name , $order_id)
{

  $merchant_id = $google_pay_id;  // Your Merchant ID
  $merchant_key = $google_pay_key;  // Your Merchant Key
  $server_type = "Production";

	//$merchant_id = "838300569379539";  // Your Merchant ID
	//$merchant_key = "ATvXTWlBco72cEKUGWrOng";  // Your Merchant Key
	//$server_type = "sandbox";

  $currency = "USD";
  $cart = new GoogleCart($merchant_id, $merchant_key, $server_type,$currency);
  $total_count = 1;

  $item_1 = new GoogleItem($package_name,      // Item name
						   $package_name, // Item      description
						   $total_count, // Quantity
						   $total); // Unit price



  $item_1->SetMerchantItemId($order_id);

  $cart->AddItem($item_1);

  // Add shipping options
  if($total_count < 3){
		 $ship_1 = new GoogleFlatRateShipping("USPS Priority Mail", 4.55);
  }else{
		 $ship_1 = new GoogleFlatRateShipping("USPS Priority Mail", 6.2);
  }
  //$Gfilter = new GoogleShippingFilters();
  //$Gfilter->SetAllowedCountryArea('CONTINENTAL_48');

  //$ship_1->AddShippingRestrictions($Gfilter);

  //$cart->AddShipping($ship_1);

  // Add tax rules
  $tax_rule = new GoogleDefaultTaxRule(0.05);
  $tax_rule->SetStateAreas(array("MA"));
  $cart->AddDefaultTaxRules($tax_rule);

  // Specify <edit-cart-url>
  $cart->SetEditCartUrl(_BASEURL_."/buybids/index.html");

  // Specify "Return to xyz" link
  //$cart->SetContinueShoppingUrl("https://www.example.com/goods/");

  // Request buyer's phone number
  $cart->SetRequestBuyerPhone(true);

  // Display Google Checkout button
  $cart->CheckoutButtonCode("SMALL");
}


?>
