function setup_checkout(ET_Order $order)
 {
     $order = clone $order;
     $order = $order->generate_data_to_pay();
     $setting = $this->_settings;
     $payment = new ET_GoogleCheckout();
     $currencyCodeType = isset($order['currencyCodeType']) ? $order['currencyCodeType'] : '';
     $pro = isset($order['products']) ? $order['products'] : array();
     $products = "";
     $itemamt = 0.0;
     $i = 0;
     if (isset($order['total_before_discount']) && $order['total_before_discount'] > $order['total']) {
         $pro[] = array('NAME' => __("Discount", ET_DOMAIN), 'L_DESC' => __("You have use a coupon code to get discount", ET_DOMAIN), 'AMT' => $order['total'] - $order['total_before_discount'], 'QTY' => 1);
     }
     // set digital url
     $key = $payment->get_digital_key($order['ID']);
     $url = $setting['return'];
     $returnURL = $url . '&token=' . $key;
     // general product string add to paypal url
     if (!empty($pro)) {
         $xml_data = new gc_XmlBuilder();
         $xml_data->Push('checkout-shopping-cart', array('xmlns' => GOOGLE_SCHEMA_URL));
         $xml_data->Push('shopping-cart');
         $xml_data->Push('items');
         foreach ($pro as $key => $value) {
             $xml_data->Push('item');
             $xml_data->Element('item-name', $value['NAME']);
             $xml_data->Element('item-description', $value['L_DESC']);
             $xml_data->Element('unit-price', $value['AMT'], array('currency' => $order['currencyCodeType']));
             $xml_data->Element('quantity', $value['QTY']);
             $xml_data->Push('digital-content');
             // digital url
             $xml_data->Element('url', $returnURL);
             // description when order success
             $xml_data->element('description', substr('You have completed order!', 0, 40));
             $xml_data->Pop('digital-content');
             $xml_data->Pop('item');
         }
         $xml_data->Pop('items');
     }
     $xml_data->Pop('shopping-cart');
     $xml_data->Push('checkout-flow-support');
     $xml_data->Push('merchant-checkout-flow-support');
     $xml_data->Element('continue-shopping-url', $setting['continue_shop']);
     $xml_data->Pop('merchant-checkout-flow-support');
     $xml_data->Pop('checkout-flow-support');
     $xml_data->Pop('checkout-shopping-cart');
     $nvpstr = $xml_data->GetXML();
     $data = $payment->set_checkout($nvpstr);
     return array('ACK' => true, 'url' => $data['url'], 'extend' => $data);
 }
Example #2
0
 function _doReportsRequest()
 {
     $xml_data = new gc_XmlBuilder();
     $xml_data->Push('notification-history-request', array('xmlns' => $this->schema_url));
     if (!empty($this->continue_token)) {
         $xml_data->Element('continue-token', trim($this->continue_token));
     } else {
         if (!empty($this->start_date)) {
             $xml_data->Element('start-time', trim($this->start_date));
         }
         if (!empty($this->end_date)) {
             $xml_data->Element('end-time', trim($this->end_date));
         }
         if (is_array($this->orders) && !empty($this->orders)) {
             $xml_data->Push('order-numbers');
             foreach ($this->orders as $order) {
                 if (trim($order) != '') {
                     $xml_data->Element('google-order-number', trim($order));
                 }
             }
             $xml_data->Pop('order-numbers');
         }
         if (is_array($this->notification_types) && !empty($this->notification_types)) {
             $xml_data->Push('notification-types');
             foreach ($this->notification_types as $notification_type) {
                 $xml_data->Element('notification-type', trim($notification_type));
             }
             $xml_data->Pop('notification-types');
         }
     }
     $xml_data->Pop('notification-history-request');
     return $this->sendRequest($this->reports_url, $this->getAuthenticationHeaders(), $xml_data->GetXML());
 }
 /**
  * Builds the merchant calculation response xml to be sent to
  * Google Checkout.
  * 
  * @return string the response xml
  */
 function GetXML()
 {
     require_once 'xml-processing/gc_xmlbuilder.php';
     $xml_data = new gc_XmlBuilder();
     $xml_data->Push('merchant-calculation-results', array('xmlns' => $this->schema_url));
     $xml_data->Push('results');
     foreach ($this->results_arr as $result) {
         if ($result->shipping_name != "") {
             $xml_data->Push('result', array('shipping-name' => $result->shipping_name, 'address-id' => $result->address_id));
             $xml_data->Element('shipping-rate', $result->ship_price, array('currency' => $this->currency));
             $xml_data->Element('shippable', $result->shippable);
         } else {
             $xml_data->Push('result', array('address-id' => $result->address_id));
         }
         if ($result->tax_amount != "") {
             $xml_data->Element('total-tax', $result->tax_amount, array('currency' => $this->currency));
         }
         if (count($result->coupon_arr) != 0 || count($result->giftcert_arr) != 0) {
             $xml_data->Push('merchant-code-results');
             foreach ($result->coupon_arr as $curr_coupon) {
                 $xml_data->Push('coupon-result');
                 $xml_data->Element('valid', $curr_coupon->coupon_valid);
                 $xml_data->Element('code', $curr_coupon->coupon_code);
                 $xml_data->Element('calculated-amount', $curr_coupon->coupon_amount, array('currency' => $this->currency));
                 $xml_data->Element('message', $curr_coupon->coupon_message);
                 $xml_data->Pop('coupon-result');
             }
             foreach ($result->giftcert_arr as $curr_gift) {
                 $xml_data->Push('gift-result');
                 $xml_data->Element('valid', $curr_gift->gift_valid);
                 $xml_data->Element('code', $curr_gift->gift_code);
                 $xml_data->Element('calculated-amount', $curr_gift->gift_amount, array('currency' => $this->currency));
                 $xml_data->Element('message', $curr_gift->gift_message);
                 $xml_data->Pop('gift-result');
             }
             $xml_data->Pop('merchant-code-results');
         }
         $xml_data->Pop('result');
     }
     $xml_data->Pop('results');
     $xml_data->Pop('merchant-calculation-results');
     return $xml_data->GetXML();
 }
 function GetXML()
 {
     require_once JPATH_SITE . '/components/com_dtregister/lib/payment/gcheckout/gc_xmlbuilder.php';
     $xml_data = new gc_XmlBuilder();
     $xml_data->Push('checkout-shopping-cart', array('xmlns' => $this->schema_url));
     $xml_data->Push('shopping-cart');
     $xml_data->Push('items');
     foreach ($this->_items as $item) {
         $xml_data->Push('item');
         $xml_data->Element('item-name', $item['name']);
         $xml_data->Element('item-description', $item['description']);
         $xml_data->Element('unit-price', $item['price'], array('currency' => $this->_currency));
         $xml_data->Element('quantity', $item['quantity']);
         $xml_data->Pop('item');
     }
     $xml_data->Pop('items');
     $xml_data->Element('merchant-private-data', $this->private_data);
     $xml_data->Pop('shopping-cart');
     $xml_data->Push('checkout-flow-support');
     $xml_data->Push('merchant-checkout-flow-support');
     $xml_data->Element('continue-shopping-url', $this->continue_url);
     $xml_data->Pop('merchant-checkout-flow-support');
     $xml_data->Pop('checkout-flow-support');
     $xml_data->Pop('checkout-shopping-cart');
     return $xml_data->GetXML();
 }
Example #5
0
 function GetTokenRequestXML()
 {
     require_once 'xml-processing/gc_xmlbuilder.php';
     $xml_data = new gc_XmlBuilder();
     $xml_data->Push('notification-data-token-request', array('xmlns' => $this->schema_url));
     $xml_data->Element('start-time', $this->start_time);
     $xml_data->Pop('notification-data-token-request');
     return $xml_data->GetXML();
 }
    /**
     * Builds the merchant calculation response xml to be sent to
     * Google Checkout.
     * 
     * @return string the response xml
     */
    function GetXML() {
      require_once('xml-processing/gc_xmlbuilder.php');

      $xml_data = new gc_XmlBuilder();
      $xml_data->Push('merchant-calculation-results', 
          array('xmlns' => $this->schema_url));
      $xml_data->Push('results');

      foreach($this->results_arr as $result) {
        if($result->shipping_name != "") {
          $xml_data->Push('result', array('shipping-name' => 
              $result->shipping_name, 'address-id' => $result->address_id));
          $xml_data->Element('shipping-rate', $result->ship_price, 
              array('currency' => $this->currency));
          $xml_data->Element('shippable', $result->shippable);
        } else
          $xml_data->Push('result', array('address-id' => $result->address_id));
	
		// total-tax seems mandatory - errors appear in the integration console
		// and shipping methods don't display on the google checkout form when 
		// it's not present, which occurs if tax_amount = 0.
		//
		// Google Console Error:	Merchant Calculations: We were looking for
		// data in your merchant-calculation-results, but were not able to find 
		// it: total-tax
		//
        // if($result->tax_amount != "")
        $xml_data->Element('total-tax', $result->tax_amount, 
              array('currency' => $this->currency));

        if((count($result->coupon_arr) != 0) || 
            (count($result->giftcert_arr) != 0) )  {
          $xml_data->Push('merchant-code-results');

          foreach($result->coupon_arr as $curr_coupon) {
            $xml_data->Push('coupon-result');  
            $xml_data->Element('valid', $curr_coupon->coupon_valid);
            $xml_data->Element('code', $curr_coupon->coupon_code);
            $xml_data->Element('calculated-amount', $curr_coupon->coupon_amount,
                array('currency'=> $this->currency));
            $xml_data->Element('message', $curr_coupon->coupon_message);
            $xml_data->Pop('coupon-result');  
          }
          foreach($result->giftcert_arr as $curr_gift) {
            $xml_data->Push('gift-certificate-result');  
            $xml_data->Element('valid', $curr_gift->gift_valid);
            $xml_data->Element('code', $curr_gift->gift_code);
            $xml_data->Element('calculated-amount', $curr_gift->gift_amount, 
                array('currency'=> $this->currency));
            $xml_data->Element('message', $curr_gift->gift_message);
            $xml_data->Pop('gift-certificate-result');  
          }
          $xml_data->Pop('merchant-code-results');
        }
        $xml_data->Pop('result');  
      }
      $xml_data->Pop('results');
      $xml_data->Pop('merchant-calculation-results'); 
      return $xml_data->GetXML();
    }