config['sandbox'] = false; if($params) $this->config = array_merge( $this->config, $params ); if($folder == "base") { $serverpath = "."; } else { $serverpath = ".."; } if(defined('SE_ROOT')) { $serverpath = SE_ROOT; } // Include all the required files require_once( $serverpath . '/include/googlecheckout/library/googlecart.php' ); require_once( $serverpath . '/include/googlecheckout/library/googleitem.php' ); require_once( $serverpath . '/include/googlecheckout/library/googleshipping.php' ); require_once( $serverpath . '/include/googlecheckout/library/googletax.php' ); } /***** PAYMENT FUNCTION *****/ function checkout( &$cart ) { global $functions_payment; return true; } // SHOULD BE ONLY CALLED AFTER SUCCESSFULL checkout() function pay( $cart = null ) { global $functions_payment; return true; } function create_checkout_blob($cart) { global $url; $server_type = $this->config['sandbox'] ? "sandbox" : "Production"; // $server_type = "sandbox"; $currency = semods::get_setting('payment_currency'); $goocart = new GoogleCart($this->config['merchant_id'], $this->config['merchant_key'], $server_type, $currency); foreach($cart->cart_items as $cart_item) { switch($cart_item['cartitem_type']) { // subscription case 1: // nothing we can do here? break; // regular product case 0: default: $item = new GoogleItem( $cart_item['cartitem_name'], // Item name $cart_item['cartitem_shortdesc'], // Item description $cart_item['cartitem_quantity'], // Quantity $cart_item['cartitem_price'] ); // Unit price $item->SetMerchantPrivateItemData( new MerchantPrivateItemData( array( "order_id" => $cart_item['cartitem_cart_id'] ) ) ); $goocart->AddItem($item); break; } } // Add $goocart->SetMerchantPrivateData( new MerchantPrivateData( array( "order_id" => $cart_item['cartitem_cart_id'] ) ) ); // Specify "Return to xyz" link $goocart->SetContinueShoppingUrl( $url->url_base . 'payment.php?task=success' ); $blob = $goocart->CheckoutButtonCode("MEDIUM"); return array( 'checkout' => 0, 'blob' => $blob ); } } ?>