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)); // 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(); }
/** * Builds the merchant calculation response xml to be sent to * Google Checkout. * * @return string the response xml */ function GetXML() { require_once dirname(__FILE__) . '/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->taxable) { if ($result->tax_amount == "") { $xml_data->Element('total-tax', 0, array('currency' => $this->currency)); } else { $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(); }
/** * Builds the cart's xml to be sent to Google Checkout. * * @return string the cart's xml */ function GetXML() { require_once 'xml-processing/gc_xmlbuilder.php'; $xml_data = new 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)); } // New 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, 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 { $xml_data->element('email-delivery', $this->_GetBooleanValue($item->email_delivery, "true")); } $xml_data->pop('digital-content'); } $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(); }
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); }
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(); }
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(); }
/** * Returns the generated XMl from item specifications * To use this function, you need to specify the item currency * @param void * @return string XML cart */ function GetXML() { require_once 'xml-processing/gc_xmlbuilder.php'; $xml_data = new gc_XmlBuilder(); $xml_data->Push('item'); $xml_data->Element('item-name', $this->item_name); $xml_data->Element('item-description', $this->item_description); $xml_data->Element('unit-price', $this->unit_price, array('currency' => $this->currency)); $xml_data->Element('quantity', $this->quantity); if ($this->merchant_private_item_data != '') { // echo get_class($item->merchant_private_item_data); if (is_a($this->merchant_private_item_data, 'merchantprivate')) { $this->merchant_private_item_data->AddMerchantPrivateToXML($xml_data); } else { $xml_data->Element('merchant-private-item-data', $this->merchant_private_item_data); } } if ($this->merchant_item_id != '') { $xml_data->Element('merchant-item-id', $this->merchant_item_id); } if ($this->tax_table_selector != '') { $xml_data->Element('tax-table-selector', $this->tax_table_selector); } // recurring Carrier calculation if ($this->item_weight != '' && $this->numeric_weight !== '') { $xml_data->EmptyElement('item-weight', array('unit' => $this->item_weight, 'value' => $this->numeric_weight)); } // recurring Digital Delivery Tags if ($this->digital_content) { $xml_data->Push('digital-content'); if (!empty($this->digital_url)) { $xml_data->Element('description', substr($this->digital_description, 0, MAX_DIGITAL_DESC)); $xml_data->Element('url', $this->digital_url); // To avoid NULL key message in GC confirmation Page if (!empty($this->digital_key)) { $xml_data->Element('key', $this->digital_key); } } else { if (!empty($item->digital_description)) { $xml_data->element('description', substr($item->digital_description, 0, MAX_DIGITAL_DESC)); } else { $xml_data->Element('email-delivery', $this->_GetBooleanValue($this->email_delivery, "true")); } } $xml_data->pop('digital-content'); } $xml_data->Pop('item'); return $xml_data->GetXML(); }