function _doReportsRequest()
 {
     $xml_data = new Espresso_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 cart's xml to be sent to Google Checkout.
  * 
  * @return string the cart's xml
  */
 function GetXML()
 {
     require_once dirname(__FILE__) . '/xml-processing/gc_xmlbuilder.php';
     $xml_data = new Espresso_gc_XmlBuilder();
     $xml_data->Push('checkout-shopping-cart', array('xmlns' => $this->schema_url));
     $xml_data->Push('shopping-cart');
     //Add cart expiration if set
     if ($this->cart_expiration != "") {
         $xml_data->Push('cart-expiration');
         $xml_data->Element('good-until-date', $this->cart_expiration);
         $xml_data->Pop('cart-expiration');
     }
     //Add XML data for each of the items
     $xml_data->Push('items');
     foreach ($this->item_arr as $item) {
         $xml_data->Push('item');
         $xml_data->Element('item-name', $item->item_name);
         $xml_data->Element('item-description', $item->item_description);
         $xml_data->Element('unit-price', $item->unit_price, array('currency' => $this->currency));
         $xml_data->Element('quantity', $item->quantity);
         if ($item->merchant_private_item_data != '') {
             //          echo get_class($item->merchant_private_item_data);
             if (is_a($item->merchant_private_item_data, 'merchantprivate')) {
                 $item->merchant_private_item_data->AddMerchantPrivateToXML($xml_data);
             } else {
                 $xml_data->Element('merchant-private-item-data', $item->merchant_private_item_data);
             }
         }
         if ($item->merchant_item_id != '') {
             $xml_data->Element('merchant-item-id', $item->merchant_item_id);
         }
         if ($item->tax_table_selector != '') {
             $xml_data->Element('tax-table-selector', $item->tax_table_selector);
         }
         //      Carrier calculation
         if ($item->item_weight != '' && $item->numeric_weight !== '') {
             $xml_data->EmptyElement('item-weight', array('unit' => $item->item_weight, 'value' => $item->numeric_weight));
         }
         //      Digital Delivery Tags
         if ($item->digital_content) {
             $xml_data->Push('digital-content');
             if (!empty($item->digital_url)) {
                 $xml_data->Element('description', substr($item->digital_description, 0, Espresso_MAX_DIGITAL_DESC));
                 $xml_data->Element('url', $item->digital_url);
                 //            To avoid NULL key message in GC confirmation Page
                 if (!empty($item->digital_key)) {
                     $xml_data->Element('key', $item->digital_key);
                 }
             } else {
                 if (!empty($item->digital_description)) {
                     $xml_data->element('description', substr($item->digital_description, 0, Espresso_MAX_DIGITAL_DESC));
                 } else {
                     $xml_data->Element('email-delivery', $this->_GetBooleanValue($item->email_delivery, "true"));
                 }
             }
             $xml_data->pop('digital-content');
         }
         //      BETA Subscription Tags
         if ($item->subscription) {
             $sub = $item->subscription;
             $xml_data->Push('subscription', array('type' => $sub->subscription_type, 'period' => $sub->subscription_period, 'start-date' => $sub->subscription_start_date, 'no-charge-after' => $sub->subscription_no_charge_after));
             $xml_data->Push('payments');
             $xml_data->Push('subscription-payment', array('times' => $sub->subscription_payment_times));
             $xml_data->Element('maximum-charge', $sub->maximum_charge, array('currency' => $this->currency));
             $xml_data->Pop('subscription-payment');
             $xml_data->Pop('payments');
             if (!empty($sub->recurrent_item)) {
                 $recurrent_item = $sub->recurrent_item;
                 //Google Handled Subscriptions
                 if ($sub->subscription_type == 'google') {
                     $xml_data->Push('recurrent-item');
                     $xml_data->Element('item-name', $recurrent_item->item_name);
                     $xml_data->Element('item-description', $recurrent_item->item_description);
                     $xml_data->Element('unit-price', $recurrent_item->unit_price, array('currency' => $this->currency));
                     $xml_data->Element('quantity', $recurrent_item->quantity);
                     if ($recurrent_item->merchant_private_item_data != '') {
                         //          echo get_class($item->merchant_private_item_data);
                         if (is_a($recurrent_item->merchant_private_item_data, 'merchantprivate')) {
                             $recurrent_item->merchant_private_item_data->AddMerchantPrivateToXML($xml_data);
                         } else {
                             $xml_data->Element('merchant-private-item-data', $recurrent_item->merchant_private_item_data);
                         }
                     }
                     if ($recurrent_item->merchant_item_id != '') {
                         $xml_data->Element('merchant-item-id', $recurrent_item->merchant_item_id);
                     }
                     if ($recurrent_item->tax_table_selector != '') {
                         $xml_data->Element('tax-table-selector', $recurrent_item->tax_table_selector);
                     }
                     //     recurring Carrier calculation
                     if ($recurrent_item->item_weight != '' && $recurrent_item->numeric_weight !== '') {
                         $xml_data->EmptyElement('item-weight', array('unit' => $recurrent_item->item_weight, 'value' => $recurrent_item->numeric_weight));
                     }
                     //     recurring Digital Delivery Tags
                     if ($recurrent_item->digital_content) {
                         $xml_data->Push('digital-content');
                         if (!empty($recurrent_item->digital_url)) {
                             $xml_data->Element('description', substr($recurrent_item->digital_description, 0, Espresso_MAX_DIGITAL_DESC));
                             $xml_data->Element('url', $recurrent_item->digital_url);
                             //            To avoid NULL key message in GC confirmation Page
                             if (!empty($recurrent_item->digital_key)) {
                                 $xml_data->Element('key', $recurrent_item->digital_key);
                             }
                         } else {
                             if (!empty($item->digital_description)) {
                                 $xml_data->element('description', substr($item->digital_description, 0, Espresso_MAX_DIGITAL_DESC));
                             } else {
                                 $xml_data->Element('email-delivery', $this->_GetBooleanValue($recurrent_item->email_delivery, "true"));
                             }
                         }
                         $xml_data->pop('digital-content');
                     }
                     $xml_data->Pop('recurrent-item');
                 }
             }
             $xml_data->pop('subscription');
         }
         $xml_data->Pop('item');
     }
     $xml_data->Pop('items');
     if ($this->merchant_private_data != '') {
         if (is_a($this->merchant_private_data, 'merchantprivate')) {
             $this->merchant_private_data->AddMerchantPrivateToXML($xml_data);
         } else {
             $xml_data->Element('merchant-private-data', $this->merchant_private_data);
         }
     }
     $xml_data->Pop('shopping-cart');
     $xml_data->Push('checkout-flow-support');
     $xml_data->Push('merchant-checkout-flow-support');
     if ($this->edit_cart_url != '') {
         $xml_data->Element('edit-cart-url', $this->edit_cart_url);
     }
     if ($this->continue_shopping_url != '') {
         $xml_data->Element('continue-shopping-url', $this->continue_shopping_url);
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Push('shipping-methods');
     }
     //Add the shipping methods
     foreach ($this->shipping_arr as $ship) {
         //Pickup shipping handled in else part
         if ($ship->type == "flat-rate-shipping" || $ship->type == "merchant-calculated-shipping") {
             $xml_data->Push($ship->type, array('name' => $ship->name));
             $xml_data->Element('price', $ship->price, array('currency' => $this->currency));
             $shipping_restrictions = $ship->shipping_restrictions;
             if (isset($shipping_restrictions)) {
                 $xml_data->Push('shipping-restrictions');
                 if ($shipping_restrictions->allow_us_po_box === true) {
                     $xml_data->Element('allow-us-po-box', "true");
                 } else {
                     $xml_data->Element('allow-us-po-box', "false");
                 }
                 //Check if allowed restrictions specified
                 if ($shipping_restrictions->allowed_restrictions) {
                     $xml_data->Push('allowed-areas');
                     if ($shipping_restrictions->allowed_country_area != "") {
                         $xml_data->EmptyElement('us-country-area', array('country-area' => $shipping_restrictions->allowed_country_area));
                     }
                     foreach ($shipping_restrictions->allowed_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($shipping_restrictions->allowed_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     if ($shipping_restrictions->allowed_world_area === true) {
                         $xml_data->EmptyElement('world-area');
                     }
                     for ($i = 0; $i < count($shipping_restrictions->allowed_country_codes_arr); $i++) {
                         $xml_data->Push('postal-area');
                         $country_code = $shipping_restrictions->allowed_country_codes_arr[$i];
                         $postal_pattern = $shipping_restrictions->allowed_postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                     }
                     $xml_data->Pop('allowed-areas');
                 }
                 if ($shipping_restrictions->excluded_restrictions) {
                     if (!$shipping_restrictions->allowed_restrictions) {
                         $xml_data->EmptyElement('allowed-areas');
                     }
                     $xml_data->Push('excluded-areas');
                     if ($shipping_restrictions->excluded_country_area != "") {
                         $xml_data->EmptyElement('us-country-area', array('country-area' => $shipping_restrictions->excluded_country_area));
                     }
                     foreach ($shipping_restrictions->excluded_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($shipping_restrictions->excluded_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     for ($i = 0; $i < count($shipping_restrictions->excluded_country_codes_arr); $i++) {
                         $xml_data->Push('postal-area');
                         $country_code = $shipping_restrictions->excluded_country_codes_arr[$i];
                         $postal_pattern = $shipping_restrictions->excluded_postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                     }
                     $xml_data->Pop('excluded-areas');
                 }
                 $xml_data->Pop('shipping-restrictions');
             }
             if ($ship->type == "merchant-calculated-shipping") {
                 $address_filters = $ship->address_filters;
                 if (isset($address_filters)) {
                     $xml_data->Push('address-filters');
                     if ($address_filters->allow_us_po_box === true) {
                         $xml_data->Element('allow-us-po-box', "true");
                     } else {
                         $xml_data->Element('allow-us-po-box', "false");
                     }
                     //Check if allowed restrictions specified
                     if ($address_filters->allowed_restrictions) {
                         $xml_data->Push('allowed-areas');
                         if ($address_filters->allowed_country_area != "") {
                             $xml_data->EmptyElement('us-country-area', array('country-area' => $address_filters->allowed_country_area));
                         }
                         foreach ($address_filters->allowed_state_areas_arr as $current) {
                             $xml_data->Push('us-state-area');
                             $xml_data->Element('state', $current);
                             $xml_data->Pop('us-state-area');
                         }
                         foreach ($address_filters->allowed_zip_patterns_arr as $current) {
                             $xml_data->Push('us-zip-area');
                             $xml_data->Element('zip-pattern', $current);
                             $xml_data->Pop('us-zip-area');
                         }
                         if ($address_filters->allowed_world_area === true) {
                             $xml_data->EmptyElement('world-area');
                         }
                         for ($i = 0; $i < count($address_filters->allowed_country_codes_arr); $i++) {
                             $xml_data->Push('postal-area');
                             $country_code = $address_filters->allowed_country_codes_arr[$i];
                             $postal_pattern = $address_filters->allowed_postal_patterns_arr[$i];
                             $xml_data->Element('country-code', $country_code);
                             if ($postal_pattern != "") {
                                 $xml_data->Element('postal-code-pattern', $postal_pattern);
                             }
                             $xml_data->Pop('postal-area');
                         }
                         $xml_data->Pop('allowed-areas');
                     }
                     if ($address_filters->excluded_restrictions) {
                         if (!$address_filters->allowed_restrictions) {
                             $xml_data->EmptyElement('allowed-areas');
                         }
                         $xml_data->Push('excluded-areas');
                         if ($address_filters->excluded_country_area != "") {
                             $xml_data->EmptyElement('us-country-area', array('country-area' => $address_filters->excluded_country_area));
                         }
                         foreach ($address_filters->excluded_state_areas_arr as $current) {
                             $xml_data->Push('us-state-area');
                             $xml_data->Element('state', $current);
                             $xml_data->Pop('us-state-area');
                         }
                         foreach ($address_filters->excluded_zip_patterns_arr as $current) {
                             $xml_data->Push('us-zip-area');
                             $xml_data->Element('zip-pattern', $current);
                             $xml_data->Pop('us-zip-area');
                         }
                         for ($i = 0; $i < count($address_filters->excluded_country_codes_arr); $i++) {
                             $xml_data->Push('postal-area');
                             $country_code = $address_filters->excluded_country_codes_arr[$i];
                             $postal_pattern = $address_filters->excluded_postal_patterns_arr[$i];
                             $xml_data->Element('country-code', $country_code);
                             if ($postal_pattern != "") {
                                 $xml_data->Element('postal-code-pattern', $postal_pattern);
                             }
                             $xml_data->Pop('postal-area');
                         }
                         $xml_data->Pop('excluded-areas');
                     }
                     $xml_data->Pop('address-filters');
                 }
             }
             $xml_data->Pop($ship->type);
         } else {
             if ($ship->type == "carrier-calculated-shipping") {
                 //          $xml_data->Push($ship->type, array('name' => $ship->name));
                 $xml_data->Push($ship->type);
                 $xml_data->Push('carrier-calculated-shipping-options');
                 $CCSoptions = $ship->CarrierCalculatedShippingOptions;
                 foreach ($CCSoptions as $CCSoption) {
                     $xml_data->Push('carrier-calculated-shipping-option');
                     $xml_data->Element('price', $CCSoption->price, array('currency' => $this->currency));
                     $xml_data->Element('shipping-company', $CCSoption->shipping_company);
                     $xml_data->Element('shipping-type', $CCSoption->shipping_type);
                     $xml_data->Element('carrier-pickup', $CCSoption->carrier_pickup);
                     if (!empty($CCSoption->additional_fixed_charge)) {
                         $xml_data->Element('additional-fixed-charge', $CCSoption->additional_fixed_charge, array('currency' => $this->currency));
                     }
                     if (!empty($CCSoption->additional_variable_charge_percent)) {
                         $xml_data->Element('additional-variable-charge-percent', $CCSoption->additional_variable_charge_percent);
                     }
                     $xml_data->Pop('carrier-calculated-shipping-option');
                 }
                 $xml_data->Pop('carrier-calculated-shipping-options');
                 //          $ShippingPackage = $ship->ShippingPackage;
                 $xml_data->Push('shipping-packages');
                 $xml_data->Push('shipping-package');
                 $xml_data->Push('ship-from', array('id' => $ship->ShippingPackage->ship_from->id));
                 $xml_data->Element('city', $ship->ShippingPackage->ship_from->city);
                 $xml_data->Element('region', $ship->ShippingPackage->ship_from->region);
                 $xml_data->Element('postal-code', $ship->ShippingPackage->ship_from->postal_code);
                 $xml_data->Element('country-code', $ship->ShippingPackage->ship_from->country_code);
                 $xml_data->Pop('ship-from');
                 $xml_data->EmptyElement('width', array('unit' => $ship->ShippingPackage->unit, 'value' => $ship->ShippingPackage->width));
                 $xml_data->EmptyElement('length', array('unit' => $ship->ShippingPackage->unit, 'value' => $ship->ShippingPackage->length));
                 $xml_data->EmptyElement('height', array('unit' => $ship->ShippingPackage->unit, 'value' => $ship->ShippingPackage->height));
                 $xml_data->Element('delivery-address-category', $ship->ShippingPackage->delivery_address_category);
                 $xml_data->Pop('shipping-package');
                 $xml_data->Pop('shipping-packages');
                 $xml_data->Pop($ship->type);
             } else {
                 if ($ship->type == "pickup") {
                     $xml_data->Push('pickup', array('name' => $ship->name));
                     $xml_data->Element('price', $ship->price, array('currency' => $this->currency));
                     $xml_data->Pop('pickup');
                 }
             }
         }
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Pop('shipping-methods');
     }
     if ($this->request_buyer_phone != "") {
         $xml_data->Element('request-buyer-phone-number', $this->request_buyer_phone);
     }
     if ($this->merchant_calculations_url != "") {
         $xml_data->Push('merchant-calculations');
         $xml_data->Element('merchant-calculations-url', $this->merchant_calculations_url);
         if ($this->accept_merchant_coupons != "") {
             $xml_data->Element('accept-merchant-coupons', $this->accept_merchant_coupons);
         }
         if ($this->accept_gift_certificates != "") {
             $xml_data->Element('accept-gift-certificates', $this->accept_gift_certificates);
         }
         $xml_data->Pop('merchant-calculations');
     }
     //Set Third party Tracking
     if ($this->thirdPartyTackingUrl) {
         $xml_data->Push('parameterized-urls');
         $xml_data->Push('parameterized-url', array('url' => $this->thirdPartyTackingUrl));
         if (is_array($this->thirdPartyTackingParams) && count($this->thirdPartyTackingParams) > 0) {
             $xml_data->Push('parameters');
             foreach ($this->thirdPartyTackingParams as $tracking_param_name => $tracking_param_type) {
                 $xml_data->emptyElement('url-parameter', array('name' => $tracking_param_name, 'type' => $tracking_param_type));
             }
             $xml_data->pop('parameters');
         }
         $xml_data->pop('parameterized-url');
         $xml_data->pop('parameterized-urls');
     }
     //Set Default and Alternate tax tables
     if (count($this->alternate_tax_tables_arr) != 0 || count($this->default_tax_rules_arr) != 0) {
         if ($this->merchant_calculated_tax != "") {
             $xml_data->Push('tax-tables', array('merchant-calculated' => $this->merchant_calculated_tax));
         } else {
             $xml_data->Push('tax-tables');
         }
         if (count($this->default_tax_rules_arr) != 0) {
             $xml_data->Push('default-tax-table');
             $xml_data->Push('tax-rules');
             foreach ($this->default_tax_rules_arr as $curr_rule) {
                 if ($curr_rule->country_area != "") {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->EmptyElement('us-country-area', array('country-area' => $curr_rule->country_area));
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 foreach ($curr_rule->state_areas_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('us-state-area');
                     $xml_data->Element('state', $current);
                     $xml_data->Pop('us-state-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 foreach ($curr_rule->zip_patterns_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('us-zip-area');
                     $xml_data->Element('zip-pattern', $current);
                     $xml_data->Pop('us-zip-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 for ($i = 0; $i < count($curr_rule->country_codes_arr); $i++) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('postal-area');
                     $country_code = $curr_rule->country_codes_arr[$i];
                     $postal_pattern = $curr_rule->postal_patterns_arr[$i];
                     $xml_data->Element('country-code', $country_code);
                     if ($postal_pattern != "") {
                         $xml_data->Element('postal-code-pattern', $postal_pattern);
                     }
                     $xml_data->Pop('postal-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 if ($curr_rule->world_area === true) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->EmptyElement('world-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
             }
             $xml_data->Pop('tax-rules');
             $xml_data->Pop('default-tax-table');
         }
         if (count($this->alternate_tax_tables_arr) != 0) {
             $xml_data->Push('alternate-tax-tables');
             foreach ($this->alternate_tax_tables_arr as $curr_table) {
                 $xml_data->Push('alternate-tax-table', array('standalone' => $curr_table->standalone, 'name' => $curr_table->name));
                 $xml_data->Push('alternate-tax-rules');
                 foreach ($curr_table->tax_rules_arr as $curr_rule) {
                     if ($curr_rule->country_area != "") {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->EmptyElement('us-country-area', array('country-area' => $curr_rule->country_area));
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     foreach ($curr_rule->state_areas_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     foreach ($curr_rule->zip_patterns_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     for ($i = 0; $i < count($curr_rule->country_codes_arr); $i++) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('postal-area');
                         $country_code = $curr_rule->country_codes_arr[$i];
                         $postal_pattern = $curr_rule->postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     if ($curr_rule->world_area === true) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->EmptyElement('world-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                 }
                 $xml_data->Pop('alternate-tax-rules');
                 $xml_data->Pop('alternate-tax-table');
             }
             $xml_data->Pop('alternate-tax-tables');
         }
         $xml_data->Pop('tax-tables');
     }
     if ($this->rounding_mode != "" && $this->rounding_rule != "") {
         $xml_data->Push('rounding-policy');
         $xml_data->Element('mode', $this->rounding_mode);
         $xml_data->Element('rule', $this->rounding_rule);
         $xml_data->Pop('rounding-policy');
     }
     if ($this->analytics_data != '') {
         $xml_data->Element('analytics-data', $this->analytics_data);
     }
     $xml_data->Pop('merchant-checkout-flow-support');
     $xml_data->Pop('checkout-flow-support');
     $xml_data->Pop('checkout-shopping-cart');
     return $xml_data->GetXML();
 }