Пример #1
0
 function migrate_data()
 {
     return Tienda::dump($this->data);
 }
Пример #2
0
 function _process($data)
 {
     Tienda::load('TiendaModelOrders', 'models.orders');
     $model = new TiendaModelOrders();
     if (!$data['vs']) {
         // order is not valid
         return JText::_('TIENDA CARDPAY MESSAGE INVALID ORDER') . $this->_generateSignature($data, 2);
     }
     $errors = array();
     $send_email = false;
     if ($this->_generateSignature($data, 2) == $data['sign']) {
         switch ($data['res']) {
             case 'OK':
                 // OK
                 break;
             case 'TOUT':
                 // Time out
                 $errors[] = JText::_('TIENDA CARDPAY MESSAGE PAYMENT TIMEOUT');
                 break;
             default:
                 // something went wrong
             // something went wrong
             case 'FAIL':
                 // transaction failed
                 $errors[] = JText::_('TIENDA CARDPAY MESSAGE PAYMENT FAIL');
                 break;
         }
         $send_email = true;
         // send email!
     } else {
         $errors[] = JText::_('Tienda CARDPAY Message Invalid Signature');
     }
     // check that payment amount is correct for order_id
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load(array('order_id' => $data['vs']));
     unset($data['secure_key']);
     $orderpayment->transaction_details = Tienda::dump($data);
     $orderpayment->transaction_id = $data['vs'];
     $orderpayment->transaction_status = $data['res'];
     // set the order's new status and update quantities if necessary
     Tienda::load('TiendaHelperOrder', 'helpers.order');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($data['vs']);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     if (empty($errors)) {
         $return = JText::_('TIENDA CARDPAY MESSAGE PAYMENT SUCCESS');
         return $return;
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
Пример #3
0
 function getRate()
 {
     try {
         $this->response = $this->getClient()->getRates($this->getRequest());
         if ($this->response->HighestSeverity != 'FAILURE' && $this->response->HighestSeverity != 'ERROR') {
             $this->processResponse($this->response);
             return true;
         } else {
             $this->setError(Tienda::dump($this->response));
             return false;
         }
     } catch (SoapFault $exception) {
         $this->response = array();
         $this->setError('E2', (string) $exception);
         return false;
     }
 }
Пример #4
0
 protected function parseErrors($code, $response, &$errors)
 {
     // Error!
     if ($code != '200' || $code != '201') {
         $result = simplexml_load_string($response);
         foreach ($result as $r) {
             $errors[] = $r->internalReason . ' (' . $r->code . ' : ' . $r->location . ' )';
         }
         echo Tienda::dump($errors);
         die;
         return false;
     }
     return true;
 }
Пример #5
0
 function getRate()
 {
     try {
         $this->response = $this->getClient()->ProcessRate($this->getRequest());
         if ($this->response->Response->ResponseStatus->Code != '0') {
             $this->processResponse($this->response);
             return true;
         } else {
             $this->setError(Tienda::dump($this->response));
             return false;
         }
     } catch (SoapFault $exception) {
         $this->response = $this->getClient()->__getLastResponse();
         $this->setError((string) $exception . $this->getClient()->__getLastRequest());
         return false;
     }
 }
Пример #6
0
 /**
  * The main function for converting to an XML document.
  * Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
  *
  * @param  array $data
  * @param  string $rootNodeName - what you want the root node to be - defaultsto data.
  * @param  SimpleXMLElement $xml - should only be used recursively
  * @param  array $namespaces - the namespaces (like $namespace[] = array('url' => 'http://....', 'name' => 'xmlns:g')
  */
 public function toXml($data, $rootNodeName = 'data', &$xml = null, $namespaces = null, $root_ns = null)
 {
     // First call: create document and root node
     if (is_null($xml)) {
         $this->doc = new DOMDocument('1.0', 'utf8');
         // Root namespace
         if ($root_ns) {
             $root = $this->doc->createElementNS($root_ns, $rootNodeName);
         }
         $xml =& $root;
         $this->doc->appendChild($root);
         // Namespaces
         foreach (@$namespaces as $ns) {
             $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:' . $ns['name'], $ns['url']);
         }
     }
     // loop though the array
     foreach ($data as $key => $value) {
         // normal list of nodes
         if (is_numeric($key)) {
             $key = $rootNodeName;
         }
         // Attributes support
         if ($key == $this->attr_arr_string) {
             // Add attributes to node
             foreach ($value as $attr_name => $attr_value) {
                 $att = $this->doc->createAttribute($attr_name);
                 $xml->appendChild($att);
                 $att->appendChild($this->doc->createTextNode($attr_value));
             }
         } else {
             // Add the value if there was a value together with the att
             if ($key == $this->value_string) {
                 // Add value to node
                 $xml->appendChild($this->doc->createTextNode($value));
             } else {
                 // delete any char not allowed in XML element names
                 $key = preg_replace('/[^a-z0-9\\-\\_\\.\\:]/i', '', $key);
                 // if there is another array found recrusively call this function
                 if (is_array($value)) {
                     // create a new node unless this is an array of elements
                     if ($this->isAssoc($value)) {
                         $node = $this->doc->createElement($key);
                         $xml->appendChild($node);
                     } else {
                         $node = $xml;
                     }
                     // recrusive call - pass $key as the new rootNodeName
                     $this->toXml($value, $key, $node);
                 } else {
                     // Add a single value
                     $value = htmlentities($value);
                     $t = $this->doc->createElement($key);
                     $xml->appendChild($t);
                     $v = $this->doc->createTextNode($value);
                     $t->appendChild($v);
                 }
             }
         }
     }
     $this->doc->formatOutput = true;
     echo Tienda::dump($this->doc->saveXML());
     return $this->doc->saveXML();
 }
Пример #7
0
 /**
  * Proceeds the simple payment
  * 
  * @param string $resp
  * @param array $submitted_values
  * @return object Message object
  * @access protected
  */
 function _evaluateSimplePaymentResponse($resp, $submitted_values)
 {
     $object = new JObject();
     $object->message = '';
     $errors = array();
     $payment_status = '0';
     $order_status = '0';
     $posted = false;
     if (!($user = $this->_getUser($submitted_values))) {
         $errors[] = JText::_('Sagepayments Message Unknown User');
         $user = JFactory::getUser();
         $user->set('id', 0);
     }
     $send_email = false;
     // Evaluate a typical response from sagepayments.com
     $exploded = array();
     $exploded["approval_indicator"] = $resp[1];
     $exploded["approval_code"] = substr($resp, 2, 6);
     $exploded["approval_message"] = substr($resp, 8, 32);
     $exploded["frontend_indicator"] = substr($resp, 40, 2);
     $exploded["cvv_indicator"] = $resp[42];
     $exploded["avs_indicator"] = $resp[43];
     $exploded["risk_indicator"] = substr($resp, 44, 2);
     $exploded["reference"] = substr($resp, 46, 10);
     $exploded["field_separator"] = $resp[56];
     // ascii 28, chr(28)
     // explode the rest of the string by the field_separator
     $resp_string = substr($resp, 57, strpos($resp, chr(03)));
     $resp_array = explode($exploded["field_separator"], $resp_string);
     $exploded["order_number"] = $resp_array[0];
     foreach ($exploded as $key => $value) {
         if (empty($value)) {
             $value = "NO VALUE RETURNED";
         }
         $value = trim($value);
         switch ($key) {
             case 'approval_indicator':
                 // status in human-readable form
                 switch ($value) {
                     case 'A':
                         // approved
                         $payment_status = '1';
                         break;
                     case 'E':
                         // front-end declined
                     // front-end declined
                     case 'X':
                         // gateway declined
                         $payment_status = '0';
                         $errors[] = JText::sprintf("TIENDA SAGEPAYMENTS MESSAGE PAYMENT NOT APPROVED CODE %s", $value);
                         $errors[] = $exploded["approval_message"];
                         break;
                     default:
                         // if something went wrong
                         $errors[] = $value;
                         break;
                 }
                 break;
             case 'approval_code':
                 switch ($value) {
                     default:
                         //
                         break;
                 }
                 break;
             case 'cvv_indicator':
                 switch ($value) {
                     case 'M':
                         // matched & approved
                         break;
                     case 'N':
                         // no match
                         break;
                     case 'P':
                         // Not Processed
                         break;
                     case 'S':
                         // Merchant Has Indicated that CVV2 Is Not Present
                         break;
                     case 'U':
                         // Issuer is not certified and/or has not provided Visa Encryption Keys
                         break;
                     default:
                         // if something went wrong
                         $errors[] = $value;
                         break;
                 }
                 break;
             case 'avs_indicator':
                 switch ($value) {
                     default:
                         //
                         break;
                 }
                 break;
             case 'risk_indicator':
                 switch ($value) {
                     default:
                         //
                         break;
                 }
                 break;
                 //                case 'avs_indicator': // Response Code
                 //                    switch ($value)
                 //                    {
                 //                    	case "INVALID":
                 //                        case "MALFORMED":
                 //                    	case "ERROR":
                 //                            // Error
                 //                            $payment_status = '0';
                 //                            $order_status = '0';
                 //                            $errors[] = JText::_('Tienda Sagepayments Error processing payment');
                 //                          break;
                 //                        case "REJECTED":
                 //                            // Declined
                 //                            $payment_status = '0';
                 //                            $order_status = '0';
                 //                            $errors[] = JText::_('Tienda Sagepayments Card was declined');
                 //                          break;
                 //                        case "REGISTERED":
                 //                        case "OK":
                 //                        // Approved
                 //                            $payment_status = '1';
                 //                           break;
                 //                        default:
                 //                          break;
                 //                    }
                 //                  break;
         }
     }
     if ($posted) {
         // if the payment has been already processed, show the message only
         return count($errors) ? implode("\n", $errors) : '';
     }
     // =======================
     // verify & create payment
     // =======================
     // check that payment amount is correct for order_id
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load(array('order_id' => $submitted_values['T_ordernum']));
     $orderpayment->transaction_details = Tienda::dump($resp);
     $orderpayment->transaction_id = $exploded["reference"];
     $orderpayment->transaction_status = $exploded["approval_message"];
     // set the order's new status and update quantities if necessary
     Tienda::load('TiendaHelperOrder', 'helpers.order');
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($submitted_values['T_ordernum']);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     if (empty($errors)) {
         $return = JText::_('TIENDA SAGEPAYMENTS MESSAGE PAYMENT SUCCESS');
         return $return;
     }
     $vars = new JObject();
     $vars->message = implode("\n", $errors);
     $html = $this->_getLayout('fail', $vars);
     return $html;
 }
Пример #8
0
 /**
  * 
  * Enter description here ...
  * @param $address
  * @param $orderItems
  * @return unknown_type
  */
 function getRates($address, $orderItems)
 {
     $rates = array();
     if (empty($address->postal_code)) {
         return $rates;
     }
     require_once dirname(__FILE__) . '/shipping_usps/usps.php';
     // Use params to determine which of these is enabled
     $services = $this->getServices();
     $server_test = "http://testing.shippingapis.com/ShippingAPITest.dll";
     $server = "http://production.shippingapis.com/ShippingAPI.dll";
     $username = $this->params->get('username');
     $password = $this->params->get('password');
     $origin_zip = $this->shopAddress->zip;
     $container = $this->params->get('packaging');
     $country = $address->country_name;
     $totalWeight = 0;
     $packageCount = 0;
     $packages = array();
     foreach ($orderItems as $item) {
         $product = JTable::getInstance('Products', 'TiendaTable');
         $product->load($item->product_id);
         if ($product->product_ships) {
             $totalWeight = $totalWeight + $product->product_weight * $item->orderitem_quantity;
             $packageCount = $packageCount + 1 * $item->orderitem_quantity;
         }
     }
     //tienda bug 3207: the USPS API v2 only takes whole figures for the pounds field.
     // fix: calculate the pounds and ounces based on the total weight in pounds (LB)
     $totalPounds = floor($totalWeight);
     $totalOunces = ceil(($totalWeight - $totalPounds) * 16);
     foreach ($services as $service => $serviceName) {
         $usps = new TiendaUSPS();
         $usps->address = $address;
         $usps->setServer($server);
         $usps->setUserName($username);
         $usps->setPass($password);
         $usps->setService($service);
         $usps->setDestZip($address->postal_code);
         $usps->setOrigZip($origin_zip);
         $usps->setWeight($totalPounds, $totalOunces);
         $usps->setContainer($container);
         $usps->setCountry($country);
         $usps->setDebug($this->params->get('show_debug'));
         $price = $usps->getPrice();
         if (!empty($price->error) && is_object($price->error)) {
             if ($this->params->get('show_debug')) {
                 echo Tienda::dump($price->error);
             }
         } else {
             if (!empty($price->list)) {
                 foreach ($price->list as $p) {
                     if (get_class($p) == 'TiendaUSPSIntPrice') {
                         if ($totalWeight < $p->maxweight) {
                             $rate = array();
                             $rate['name'] = htmlspecialchars_decode($p->svcdescription . " (" . $p->svccommitments . ")");
                             $rate['code'] = $service;
                             $rate['price'] = $p->rate;
                             $rate['extra'] = "0.00";
                             $rate['total'] = $p->rate;
                             $rate['tax'] = "0.00";
                             $rate['element'] = $this->_element;
                             $rates[] = $rate;
                         }
                     } else {
                         $rate = array();
                         $rate['name'] = htmlspecialchars_decode($p->mailservice);
                         $rate['code'] = $service;
                         $rate['price'] = $p->rate;
                         $rate['extra'] = "0.00";
                         $rate['total'] = $p->rate;
                         $rate['tax'] = "0.00";
                         $rate['element'] = $this->_element;
                         $rates[] = $rate;
                     }
                 }
             }
         }
     }
     return $rates;
 }
Пример #9
0
 /**
  * Saves the properties for all attribute option values in list
  *
  * @return unknown_type
  */
 function saveattributeoptionvalues()
 {
     $error = false;
     $this->messagetype = '';
     $this->message = '';
     $model = $this->getModel('productattributeoptionvalues');
     $row = $model->getTable();
     $id = JRequest::getInt('id', 0, 'request');
     $cids = JRequest::getVar('cid', array(0), 'request', 'array');
     $field = JRequest::getVar('field', array(0), 'request', 'array');
     $operator = JRequest::getVar('operator', array(0), 'request', 'array');
     $value = JRequest::getVar('value', array(0), 'request', 'array');
     foreach (@$cids as $cid) {
         $row->load($cid);
         $row->productattributeoptionvalue_field = $field[$cid];
         $row->productattributeoptionvalue_operator = $operator[$cid];
         $row->productattributeoptionvalue_value = $value[$cid];
         echo Tienda::dump($row);
         if (!$row->check() || !$row->store()) {
             $this->message .= $row->getError();
             $this->messagetype = 'notice';
             $error = true;
         }
     }
     $row->reorder();
     $productModel = $this->getModel('products');
     $productModel->clearCache();
     if ($error) {
         $this->message = JText::_('COM_TIENDA_ERROR') . " - " . $this->message;
     } else {
         $this->message = "";
     }
     $redirect = "index.php?option=com_tienda&view=products&task=setattributeoptionvalues&id={$id}&tmpl=component";
     $redirect = JRoute::_($redirect, false);
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }
Пример #10
0
<?php

defined('_JEXEC') or die('Restricted access');
JHTML::_('script', 'tienda.js', 'media/com_tienda/js/');
$labels = @$vars->labels;
$order_id = @$vars->order_id;
echo Tienda::dump($vars->debug);
?>

<?php 
foreach ($labels as $item) {
    ?>
		    	       <div class="productfile">
				            <span class="productfile_image">
				                <a href="<?php 
    echo JRoute::_('index.php?option=com_tienda&task=doTask&element=shipping_unex&elementTask=downloadfile&format=raw&id=' . $order_id . "&filename=" . $item);
    ?>
">
				                    <img src="<?php 
    echo Tienda::getURL('images') . "download.png";
    ?>
" alt="<?php 
    echo JText::_('COM_TIENDA_DOWNLOAD');
    ?>
" style="height: 24px; padding: 5px; vertical-align: middle;" />
				                </a>
				            </span>            
				            <span class="productfile_link" style="vertical-align: middle;" >
				                <a href="<?php 
    echo JRoute::_('index.php?option=com_tienda&task=doTask&element=shipping_unex&elementTask=downloadfile&format=raw&id=' . $order_id . "&filename=" . $item);
    ?>
Пример #11
0
 function getPrice()
 {
     $countries = array('USA', 'United States', 'United States Minor Outlying Islands');
     if (in_array($this->country, $countries)) {
         // may need to urlencode xml portion
         $str = $this->server . "?API=RateV4&XML=<RateV4Request%20USERID=\"";
         $str .= $this->user . "\"%20PASSWORD=\"" . $this->pass . "\"><Package%20ID=\"0\"><Service>";
         if (strtolower($this->service) == 'first class') {
             $str .= "ONLINE</Service>";
             $str .= "<FirstClassMailType>" . $this->fcmailtype . "</FirstClassMailType>";
             $myFirstClass = 1;
         } else {
             $str .= $this->service . "</Service>";
         }
         $str .= "<ZipOrigination>" . $this->orig_zip . "</ZipOrigination>";
         $str .= "<ZipDestination>" . $this->dest_zip . "</ZipDestination>";
         $str .= "<Pounds>" . $this->pounds . "</Pounds><Ounces>" . $this->ounces . "</Ounces>";
         $str .= "<Container>" . urlencode($this->container) . "</Container><Size>" . $this->size . "</Size>";
         $str .= "<Machinable>" . $this->machinable . "</Machinable></Package></RateV4Request>";
     } else {
         $str = $this->server . "?API=IntlRate&XML=<IntlRateRequest%20USERID=\"";
         $str .= $this->user . "\"%20PASSWORD=\"" . $this->pass . "\"><Package%20ID=\"0\">";
         $str .= "<Pounds>" . $this->pounds . "</Pounds><Ounces>" . $this->ounces . "</Ounces>";
         $str .= "<MailType>Package</MailType><Country>" . urlencode($this->country) . "</Country></Package></IntlRateRequest>";
     }
     if ($this->show_debug) {
         $sendStr = JText::_('COM_TIENDA_SENT_REQUEST') . ": ";
         echo Tienda::dump($sendStr . $str);
     }
     $ch = curl_init();
     // set URL and other appropriate options
     curl_setopt($ch, CURLOPT_URL, $str);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // grab URL and pass it to the browser
     $ats = curl_exec($ch);
     // close curl resource, and free up system resources
     curl_close($ch);
     $xmlParser = new TiendaUSPSXmlParser();
     $array = $xmlParser->GetXMLTree($ats);
     //debug(222222, $array);
     //$xmlParser->printa($array);
     if (!empty($array['ERROR'])) {
         // If it is error
         $error = new TiendaUSPSError();
         $error->str = $str;
         $error->level = "1";
         $error->number = $array['ERROR'][0]['NUMBER'][0]['VALUE'];
         $error->source = $array['ERROR'][0]['SOURCE'][0]['VALUE'];
         $error->description = $array['ERROR'][0]['DESCRIPTION'][0]['VALUE'];
         $error->helpcontext = $array['ERROR'][0]['HELPCONTEXT'][0]['VALUE'];
         $error->helpfile = $array['ERROR'][0]['HELPFILE'][0]['VALUE'];
         $this->error = $error;
         $this->setError($error);
     } else {
         if (!empty($array['RATEV4RESPONSE'][0]['PACKAGE'][0]['ERROR'])) {
             $error = new TiendaUSPSError();
             $error->str = $str;
             $error->level = "2";
             $error->number = $array['RATEV4RESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['NUMBER'][0]['VALUE'];
             $error->source = $array['RATEV4RESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['SOURCE'][0]['VALUE'];
             $error->description = $array['RATEV4RESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['DESCRIPTION'][0]['VALUE'];
             $error->helpcontext = $array['RATEV4RESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['HELPCONTEXT'][0]['VALUE'];
             $error->helpfile = $array['RATEV4RESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['HELPFILE'][0]['VALUE'];
             $this->error = $error;
             $this->setError($error);
         } else {
             if (!empty($array['INTLRATERESPONSE'][0]['PACKAGE'][0]['ERROR'])) {
                 //if it is international shipping error
                 $error = new TiendaUSPSError();
                 $error->str = $str;
                 $error->level = "3";
                 $error->number = $array['INTLRATERESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['NUMBER'][0]['VALUE'];
                 $error->source = $array['INTLRATERESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['SOURCE'][0]['VALUE'];
                 $error->description = $array['INTLRATERESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['DESCRIPTION'][0]['VALUE'];
                 $error->helpcontext = $array['INTLRATERESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['HELPCONTEXT'][0]['VALUE'];
                 $error->helpfile = $array['INTLRATERESPONSE'][0]['PACKAGE'][0]['ERROR'][0]['HELPFILE'][0]['VALUE'];
                 $this->error = $error;
                 $this->setError($error);
             } else {
                 if (!empty($array['RATEV4RESPONSE'])) {
                     // if everything OK
                     $this->zone = $array['RATEV4RESPONSE'][0]['PACKAGE'][0]['ZONE'][0]['VALUE'];
                     foreach ($array['RATEV4RESPONSE'][0]['PACKAGE'][0]['POSTAGE'] as $value) {
                         //debug(99999992, $value);
                         /*					$curMailSvc = $value['MAILSERVICE'][0]['VALUE'];
                         					echo "<script language=javascript>alert('".$curMailSvc."')</script>";*/
                         if (empty($myFirstClass) || $value['MAILSERVICE'][0]['VALUE'] == "First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; Package") {
                             $price = new TiendaUSPSPrice();
                             $price->mailservice = $value['MAILSERVICE'][0]['VALUE'];
                             $price->rate = $value['RATE'][0]['VALUE'];
                             $this->list[] = $price;
                         }
                     }
                 } else {
                     if (!empty($array['INTLRATERESPONSE'][0]['PACKAGE'][0]['SERVICE'])) {
                         // if it is international shipping and it is OK
                         foreach ($array['INTLRATERESPONSE'][0]['PACKAGE'][0]['SERVICE'] as $value) {
                             $price = new TiendaUSPSIntPrice();
                             $price->id = $value['ATTRIBUTES']['ID'];
                             $price->pounds = $value['POUNDS'][0]['VALUE'];
                             $price->ounces = $value['OUNCES'][0]['VALUE'];
                             $price->mailtype = $value['MAILTYPE'][0]['VALUE'];
                             $price->country = $value['COUNTRY'][0]['VALUE'];
                             $price->rate = $value['POSTAGE'][0]['VALUE'];
                             $price->svccommitments = $value['SVCCOMMITMENTS'][0]['VALUE'];
                             $price->svcdescription = $value['SVCDESCRIPTION'][0]['VALUE'];
                             $price->maxdimensions = $value['MAXDIMENSIONS'][0]['VALUE'];
                             $price->maxweight = $value['MAXWEIGHT'][0]['VALUE'];
                             $this->list[] = $price;
                         }
                     }
                 }
             }
         }
     }
     if ($this->show_debug) {
         $msg = JText::_('COM_TIENDA_RESULT') . ": ";
         $msg .= $price->mailservice;
         $msg .= " - ";
         $msg .= $price->rate;
         $msg .= $error->description;
         echo $price || $error ? Tienda::dump($msg) : Tienda::dump(JText::_('COM_TIENDA_NO_RESULT'));
     }
     return $this;
 }