function setup_checkout(ET_Order $order)
 {
     //$order				=	clone	$this->_order;
     $order = $order->generate_data_to_pay();
     $settings = $this->_settings;
     $payment = new ET_Paypal($settings, 1);
     $url = $settings['return'];
     $cancel_url = $settings['cancel'];
     $currencyCodeType = isset($order['currencyCodeType']) ? $order['currencyCodeType'] : '';
     $pro = isset($order['products']) ? $order['products'] : array();
     $products = "";
     $itemamt = 0.0;
     $i = 0;
     // general product string add to paypal url
     if (!empty($pro)) {
         $length = count($pro);
         if ($length > 1) {
             foreach ($pro as $key => $value) {
                 $products .= "&item_name_{$i}=" . $value['NAME'];
                 $products .= "&amount_{$i}=" . $value['AMT'];
                 $products .= "&item_number_{$i}=" . $value['QTY'];
                 $itemamt += doubleval($value['AMT'] * $value['QTY']);
                 $i++;
             }
         } else {
             foreach ($pro as $key => $value) {
                 $products .= "&item_name=" . $value['NAME'];
                 $products .= "&amount=" . $value['AMT'];
                 $products .= "&item_number=" . $value['QTY'];
                 $itemamt += doubleval($value['AMT'] * $value['QTY']);
                 $i++;
             }
         }
         $products .= "&invoice=" . $order['ID'];
         $products .= "&custom=" . $order['ID'];
     }
     $total = '&upload=1&amount=' . $order['total'];
     $returnURL = '&return=' . urlencode($url);
     $notifyURL = '&notify_url=' . urlencode(add_query_arg('paypalListener', 'paypal_appengine_IPN', trailingslashit(home_url())));
     $cancelURL = '&cancel_return=' . urlencode("{$cancel_url}");
     $currency = '&currency_code=' . $currencyCodeType;
     $nvpstr = $notifyURL . $returnURL . $cancelURL . $products . $total . $currency;
     #set session
     et_write_session('ad_id', $order['ID']);
     return array('url' => $payment->set_checkout($nvpstr, 'SIMPLEPAYPAL'), 'ACK' => true, 'extend' => false);
 }