function quote($method = '')
 {
     global $osC_Language, $osC_ShoppingCart;
     if (!empty($method) && isset($this->types[$method])) {
         $prod = $method;
     } else {
         if ($osC_ShoppingCart->getShippingAddress('country_iso_code_2') == 'CA') {
             $prod = 'STD';
         } else {
             $prod = 'GNDRES';
         }
     }
     if ($method) {
         $this->_upsAction('3');
     }
     // return a single quote
     $this->_upsProduct($prod);
     $this->_upsOrigin(SHIPPING_ORIGIN_ZIP, osC_Address::getCountryIsoCode2(SHIPPING_ORIGIN_COUNTRY));
     $this->_upsDest($osC_ShoppingCart->getShippingAddress('postcode'), $osC_ShoppingCart->getShippingAddress('country_iso_code_2'));
     $this->_upsRate(MODULE_SHIPPING_UPS_PICKUP);
     $this->_upsContainer(MODULE_SHIPPING_UPS_PACKAGE);
     $this->_upsWeight($osC_ShoppingCart->getWeight());
     $this->_upsRescom(MODULE_SHIPPING_UPS_RES);
     $upsQuote = $this->_upsGetQuote();
     if (is_array($upsQuote) && sizeof($upsQuote) > 0) {
         $this->quotes = array('id' => $this->_code, 'module' => $this->_title . ' (' . $osC_ShoppingCart->numberOfShippingBoxes() . ' x ' . $osC_ShoppingCart->getWeight() . 'lbs)');
         $methods = array();
         $allowed_methods = explode(",", MODULE_SHIPPING_UPS_TYPES);
         $std_rcd = false;
         $qsize = sizeof($upsQuote);
         for ($i = 0; $i < $qsize; $i++) {
             list($type, $cost) = each($upsQuote[$i]);
             if ($type == 'STD') {
                 if ($std_rcd) {
                     continue;
                 } else {
                     $std_rcd = true;
                 }
             }
             if (!in_array($type, $allowed_methods)) {
                 continue;
             }
             $methods[] = array('id' => $type, 'title' => $this->types[$type], 'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING) * $osC_ShoppingCart->numberOfShippingBoxes());
         }
         $this->quotes['methods'] = $methods;
         if ($this->tax_class > 0) {
             $this->quotes['tax_class_id'] = $this->tax_class;
         }
     } else {
         $this->quotes = array('module' => $this->_title, 'error' => 'We are unable to obtain a rate quote for UPS shipping.<br>Please contact the store if no other alternative is shown.');
     }
     if (!empty($this->icon)) {
         $this->quotes['icon'] = osc_image($this->icon, $this->_title);
     }
     return $this->quotes;
 }
示例#2
0
 function process()
 {
     global $osC_Database, $osC_Customer, $osC_Currencies, $osC_ShoppingCart, $osC_Language, $messageStack, $osC_CreditCard;
     $this->_verifyData();
     $this->_order_id = osC_Order::insert();
     $post_string = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<WIRECARD_BXML xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:noNamespaceSchemaLocation="wirecard.xsd">' . "\n" . '  <W_REQUEST>' . "\n" . '    <W_JOB>' . "\n" . '      <JobID>Job 1</JobID>' . "\n" . '      <BusinessCaseSignature>' . MODULE_PAYMENT_WIRECARD_CC_BUSINESS_SIGNATURE . '</BusinessCaseSignature>' . "\n" . '      <FNC_CC_PREAUTHORIZATION>' . "\n" . '        <FunctionID>Preauthorization 1</FunctionID>' . "\n" . '        <CC_TRANSACTION mode="' . MODULE_PAYMENT_WIRECARD_CC_TRANSACTION_MODE . '">' . "\n" . '          <TransactionID>' . $this->_order_id . '</TransactionID>' . "\n" . '          <CommerceType>eCommerce</CommerceType>' . "\n" . '          <Amount>' . $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $osC_Currencies->getCode()) * 100 . '</Amount>' . "\n" . '          <Currency>' . $osC_Currencies->getCode() . '</Currency>' . "\n" . '          <CountryCode>' . osC_Address::getCountryIsoCode2(STORE_COUNTRY) . '</CountryCode>' . "\n" . '          <Usage>' . STORE_NAME . '</Usage>' . "\n" . '          <RECURRING_TRANSACTION>' . "\n" . '            <Type>Single</Type>' . "\n" . '          </RECURRING_TRANSACTION>' . "\n" . '          <CREDIT_CARD_DATA>' . "\n" . '            <CreditCardNumber>' . $osC_CreditCard->getNumber() . '</CreditCardNumber>' . "\n";
     if (MODULE_PAYMENT_WIRECARD_CC_VERIFY_WITH_CVC == '1') {
         $post_string .= '            <CVC2>' . $osC_CreditCard->getCVC() . '</CVC2>' . "\n";
     }
     $post_string .= '            <ExpirationYear>' . $osC_CreditCard->getExpiryYear() . '</ExpirationYear>' . "\n" . '            <ExpirationMonth>' . $osC_CreditCard->getExpiryMonth() . '</ExpirationMonth>' . "\n" . '            <CardHolderName>' . $osC_CreditCard->getOwner() . '</CardHolderName>' . "\n" . '          </CREDIT_CARD_DATA>' . "\n" . '          <CONTACT_DATA>' . "\n" . '            <IPAddress>' . osc_get_ip_address() . '</IPAddress>' . "\n" . '          </CONTACT_DATA>' . "\n" . '          <CORPTRUSTCENTER_DATA>' . "\n" . '            <ADDRESS>' . "\n" . '              <FirstName>' . $osC_ShoppingCart->getBillingAddress('firstname') . '</FirstName>' . "\n" . '              <LastName>' . $osC_ShoppingCart->getBillingAddress('lastname') . '</LastName>' . "\n" . '              <Address1>' . $osC_ShoppingCart->getBillingAddress('street_address') . '</Address1>' . "\n" . '              <City>' . $osC_ShoppingCart->getBillingAddress('city') . '</City>' . "\n" . '              <ZipCode>' . $osC_ShoppingCart->getBillingAddress('postcode') . '</ZipCode>' . "\n";
     if (osc_empty($osC_ShoppingCart->getBillingAddress('zone_code')) === false) {
         $post_string .= '              <State>' . $osC_ShoppingCart->getBillingAddress('zone_code') . '</State>' . "\n";
     }
     $post_string .= '              <Country>' . $osC_ShoppingCart->getBillingAddress('country_iso_code_2') . '</Country>' . "\n" . '              <Phone>' . $osC_ShoppingCart->getBillingAddress('telephone_number') . '</Phone>' . "\n" . '              <Email>' . $osC_Customer->getEmailAddress() . '</Email>' . "\n" . '            </ADDRESS>' . "\n" . '          </CORPTRUSTCENTER_DATA>' . "\n" . '        </CC_TRANSACTION>' . "\n" . '      </FNC_CC_PREAUTHORIZATION>' . "\n" . '    </W_JOB>' . "\n" . '  </W_REQUEST>' . "\n" . '</WIRECARD_BXML>';
     $this->_transaction_response = $this->sendTransactionToGateway($this->_gateway_url, $post_string, array('Content-type: text/xml'));
     if (empty($this->_transaction_response) === false) {
         $osC_XML = new osC_XML($this->_transaction_response);
         $result = $osC_XML->toArray();
     } else {
         $result = array();
     }
     $error = false;
     if (isset($result['WIRECARD_BXML']['W_RESPONSE']['W_JOB']['FNC_CC_PREAUTHORIZATION']['CC_TRANSACTION']['PROCESSING_STATUS']['FunctionResult'])) {
         if ($result['WIRECARD_BXML']['W_RESPONSE']['W_JOB']['FNC_CC_PREAUTHORIZATION']['CC_TRANSACTION']['PROCESSING_STATUS']['FunctionResult'] != 'ACK') {
             $errno = $result['WIRECARD_BXML']['W_RESPONSE']['W_JOB']['FNC_CC_PREAUTHORIZATION']['CC_TRANSACTION']['PROCESSING_STATUS']['ERROR']['Number'];
             switch ($errno) {
                 case '14':
                 case '20109':
                     $error = $osC_Language->get('payment_wirecard_cc_error_unkown_card');
                     break;
                 case '33':
                 case '20071':
                     $error = $osC_Language->get('payment_wirecard_cc_error_' . (int) $errno);
                     break;
                 default:
                     $error = $osC_Language->get('payment_wirecard_cc_error_general');
                     break;
             }
         }
     } else {
         $error = $osC_Language->get('payment_wirecard_cc_error_general');
     }
     if ($error === false) {
         osC_Order::process($this->_order_id, $this->order_status);
         $Qtransaction = $osC_Database->query('insert into :table_orders_transactions_history (orders_id, transaction_code, transaction_return_value, transaction_return_status, date_added) values (:orders_id, :transaction_code, :transaction_return_value, :transaction_return_status, now())');
         $Qtransaction->bindTable(':table_orders_transactions_history', TABLE_ORDERS_TRANSACTIONS_HISTORY);
         $Qtransaction->bindInt(':orders_id', $this->_order_id);
         $Qtransaction->bindInt(':transaction_code', 1);
         $Qtransaction->bindValue(':transaction_return_value', $this->_transaction_response);
         $Qtransaction->bindInt(':transaction_return_status', 1);
         $Qtransaction->execute();
     } else {
         osC_Order::remove($this->_order_id);
         $messageStack->add_session('checkout_payment', $error, 'error');
         osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'payment&wirecard_cc_owner=' . $osC_CreditCard->getOwner() . '&wirecard_cc_expires_month=' . $osC_CreditCard->getExpiryMonth() . '&wirecard_cc_expires_year=' . $osC_CreditCard->getExpiryYear() . (MODULE_PAYMENT_WIRECARD_CC_VERIFY_WITH_CVC == '1' ? '&wirecard_cc_cvc=' . $osC_CreditCard->getCVC() : ''), 'SSL'));
     }
 }
示例#3
0
 function insert()
 {
     global $osC_Database, $osC_Customer, $osC_Language, $osC_Currencies, $osC_ShoppingCart, $osC_Tax;
     if (isset($_SESSION['prepOrderID'])) {
         $_prep = explode('-', $_SESSION['prepOrderID']);
         if ($_prep[0] == $osC_ShoppingCart->getCartID()) {
             return $_prep[1];
             // order_id
         } else {
             if (osC_Order::getStatusID($_prep[1]) === 4) {
                 osC_Order::remove($_prep[1]);
             }
         }
     }
     $customer_address = osC_AddressBook::getEntry($osC_Customer->getDefaultAddressID())->toArray();
     $Qorder = $osC_Database->query('insert into :table_orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_state_code, customers_country, customers_country_iso2, customers_country_iso3, customers_telephone, customers_email_address, customers_address_format, customers_ip_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_state_code, delivery_country, delivery_country_iso2, delivery_country_iso3, delivery_address_format, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_state_code, billing_country, billing_country_iso2, billing_country_iso3, billing_address_format, payment_method, payment_module, date_purchased, orders_status, currency, currency_value) values (:customers_id, :customers_name, :customers_company, :customers_street_address, :customers_suburb, :customers_city, :customers_postcode, :customers_state, :customers_state_code, :customers_country, :customers_country_iso2, :customers_country_iso3, :customers_telephone, :customers_email_address, :customers_address_format, :customers_ip_address, :delivery_name, :delivery_company, :delivery_street_address, :delivery_suburb, :delivery_city, :delivery_postcode, :delivery_state, :delivery_state_code, :delivery_country, :delivery_country_iso2, :delivery_country_iso3, :delivery_address_format, :billing_name, :billing_company, :billing_street_address, :billing_suburb, :billing_city, :billing_postcode, :billing_state, :billing_state_code, :billing_country, :billing_country_iso2, :billing_country_iso3, :billing_address_format, :payment_method, :payment_module, now(), :orders_status, :currency, :currency_value)');
     $Qorder->bindTable(':table_orders', TABLE_ORDERS);
     $Qorder->bindInt(':customers_id', $osC_Customer->getID());
     $Qorder->bindValue(':customers_name', $osC_Customer->getName());
     $Qorder->bindValue(':customers_company', $customer_address['entry_company']);
     $Qorder->bindValue(':customers_street_address', $customer_address['entry_street_address']);
     $Qorder->bindValue(':customers_suburb', $customer_address['entry_suburb']);
     $Qorder->bindValue(':customers_city', $customer_address['entry_city']);
     $Qorder->bindValue(':customers_postcode', $customer_address['entry_postcode']);
     $Qorder->bindValue(':customers_state', $customer_address['entry_state']);
     $Qorder->bindValue(':customers_state_code', osC_Address::getZoneCode($customer_address['entry_zone_id']));
     $Qorder->bindValue(':customers_country', osC_Address::getCountryName($customer_address['entry_country_id']));
     $Qorder->bindValue(':customers_country_iso2', osC_Address::getCountryIsoCode2($customer_address['entry_country_id']));
     $Qorder->bindValue(':customers_country_iso3', osC_Address::getCountryIsoCode3($customer_address['entry_country_id']));
     $Qorder->bindValue(':customers_telephone', $customer_address['entry_telephone']);
     $Qorder->bindValue(':customers_email_address', $osC_Customer->getEmailAddress());
     $Qorder->bindValue(':customers_address_format', osC_Address::getFormat($customer_address['entry_country_id']));
     $Qorder->bindValue(':customers_ip_address', osc_get_ip_address());
     $Qorder->bindValue(':delivery_name', $osC_ShoppingCart->getShippingAddress('firstname') . ' ' . $osC_ShoppingCart->getShippingAddress('lastname'));
     $Qorder->bindValue(':delivery_company', $osC_ShoppingCart->getShippingAddress('company'));
     $Qorder->bindValue(':delivery_street_address', $osC_ShoppingCart->getShippingAddress('street_address'));
     $Qorder->bindValue(':delivery_suburb', $osC_ShoppingCart->getShippingAddress('suburb'));
     $Qorder->bindValue(':delivery_city', $osC_ShoppingCart->getShippingAddress('city'));
     $Qorder->bindValue(':delivery_postcode', $osC_ShoppingCart->getShippingAddress('postcode'));
     $Qorder->bindValue(':delivery_state', $osC_ShoppingCart->getShippingAddress('state'));
     $Qorder->bindValue(':delivery_state_code', $osC_ShoppingCart->getShippingAddress('zone_code'));
     $Qorder->bindValue(':delivery_country', $osC_ShoppingCart->getShippingAddress('country_title'));
     $Qorder->bindValue(':delivery_country_iso2', $osC_ShoppingCart->getShippingAddress('country_iso_code_2'));
     $Qorder->bindValue(':delivery_country_iso3', $osC_ShoppingCart->getShippingAddress('country_iso_code_3'));
     $Qorder->bindValue(':delivery_address_format', $osC_ShoppingCart->getShippingAddress('format'));
     $Qorder->bindValue(':billing_name', $osC_ShoppingCart->getBillingAddress('firstname') . ' ' . $osC_ShoppingCart->getBillingAddress('lastname'));
     $Qorder->bindValue(':billing_company', $osC_ShoppingCart->getBillingAddress('company'));
     $Qorder->bindValue(':billing_street_address', $osC_ShoppingCart->getBillingAddress('street_address'));
     $Qorder->bindValue(':billing_suburb', $osC_ShoppingCart->getBillingAddress('suburb'));
     $Qorder->bindValue(':billing_city', $osC_ShoppingCart->getBillingAddress('city'));
     $Qorder->bindValue(':billing_postcode', $osC_ShoppingCart->getBillingAddress('postcode'));
     $Qorder->bindValue(':billing_state', $osC_ShoppingCart->getBillingAddress('state'));
     $Qorder->bindValue(':billing_state_code', $osC_ShoppingCart->getBillingAddress('zone_code'));
     $Qorder->bindValue(':billing_country', $osC_ShoppingCart->getBillingAddress('country_title'));
     $Qorder->bindValue(':billing_country_iso2', $osC_ShoppingCart->getBillingAddress('country_iso_code_2'));
     $Qorder->bindValue(':billing_country_iso3', $osC_ShoppingCart->getBillingAddress('country_iso_code_3'));
     $Qorder->bindValue(':billing_address_format', $osC_ShoppingCart->getBillingAddress('format'));
     $Qorder->bindValue(':payment_method', $osC_ShoppingCart->getBillingMethod('title'));
     $Qorder->bindValue(':payment_module', $GLOBALS['osC_Payment_' . $osC_ShoppingCart->getBillingMethod('id')]->getCode());
     $Qorder->bindInt(':orders_status', 4);
     $Qorder->bindValue(':currency', $osC_Currencies->getCode());
     $Qorder->bindValue(':currency_value', $osC_Currencies->value($osC_Currencies->getCode()));
     $Qorder->execute();
     $insert_id = $osC_Database->nextID();
     foreach ($osC_ShoppingCart->getOrderTotals() as $module) {
         $Qtotals = $osC_Database->query('insert into :table_orders_total (orders_id, title, text, value, class, sort_order) values (:orders_id, :title, :text, :value, :class, :sort_order)');
         $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
         $Qtotals->bindInt(':orders_id', $insert_id);
         $Qtotals->bindValue(':title', $module['title']);
         $Qtotals->bindValue(':text', $module['text']);
         $Qtotals->bindValue(':value', $module['value']);
         $Qtotals->bindValue(':class', $module['code']);
         $Qtotals->bindInt(':sort_order', $module['sort_order']);
         $Qtotals->execute();
     }
     $Qstatus = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)');
     $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
     $Qstatus->bindInt(':orders_id', $insert_id);
     $Qstatus->bindInt(':orders_status_id', 4);
     $Qstatus->bindInt(':customer_notified', '0');
     $Qstatus->bindValue(':comments', isset($_SESSION['comments']) ? $_SESSION['comments'] : '');
     $Qstatus->execute();
     foreach ($osC_ShoppingCart->getProducts() as $products) {
         $Qproducts = $osC_Database->query('insert into :table_orders_products (orders_id, products_id, products_model, products_name, products_price, products_tax, products_quantity) values (:orders_id, :products_id, :products_model, :products_name, :products_price, :products_tax, :products_quantity)');
         $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
         $Qproducts->bindInt(':orders_id', $insert_id);
         $Qproducts->bindInt(':products_id', osc_get_product_id($products['id']));
         $Qproducts->bindValue(':products_model', $products['model']);
         $Qproducts->bindValue(':products_name', $products['name']);
         $Qproducts->bindValue(':products_price', $products['price']);
         $Qproducts->bindValue(':products_tax', $osC_Tax->getTaxRate($products['tax_class_id']));
         $Qproducts->bindInt(':products_quantity', $products['quantity']);
         $Qproducts->execute();
         $order_products_id = $osC_Database->nextID();
         if ($osC_ShoppingCart->isVariant($products['item_id'])) {
             foreach ($osC_ShoppingCart->getVariant($products['item_id']) as $variant) {
                 /* HPDL
                             if (DOWNLOAD_ENABLED == '1') {
                               $Qattributes = $osC_Database->query('select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount, pad.products_attributes_filename from :table_products_options popt, :table_products_options_values poval, :table_products_attributes pa left join :table_products_attributes_download pad on (pa.products_attributes_id = pad.products_attributes_id) where pa.products_id = :products_id and pa.options_id = :options_id and pa.options_id = popt.products_options_id and pa.options_values_id = :options_values_id and pa.options_values_id = poval.products_options_values_id and popt.language_id = :popt_language_id and poval.language_id = :poval_language_id');
                               $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS);
                               $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES);
                               $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
                               $Qattributes->bindTable(':table_products_attributes_download', TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD);
                               $Qattributes->bindInt(':products_id', $products['id']);
                               $Qattributes->bindInt(':options_id', $attributes['options_id']);
                               $Qattributes->bindInt(':options_values_id', $attributes['options_values_id']);
                               $Qattributes->bindInt(':popt_language_id', $osC_Language->getID());
                               $Qattributes->bindInt(':poval_language_id', $osC_Language->getID());
                               $Qattributes->execute();
                             }
                 */
                 $Qvariant = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, group_title, value_title) values (:orders_id, :orders_products_id, :group_title, :value_title)');
                 $Qvariant->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS);
                 $Qvariant->bindInt(':orders_id', $insert_id);
                 $Qvariant->bindInt(':orders_products_id', $order_products_id);
                 $Qvariant->bindValue(':group_title', $variant['group_title']);
                 $Qvariant->bindValue(':value_title', $variant['value_title']);
                 $Qvariant->execute();
                 /*HPDL
                             if ((DOWNLOAD_ENABLED == '1') && (strlen($Qattributes->value('products_attributes_filename')) > 0)) {
                               $Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :download_maxdays, :download_count)');
                               $Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD);
                               $Qopd->bindInt(':orders_id', $insert_id);
                               $Qopd->bindInt(':orders_products_id', $order_products_id);
                               $Qopd->bindValue(':orders_products_filename', $Qattributes->value('products_attributes_filename'));
                               $Qopd->bindValue(':download_maxdays', $Qattributes->value('products_attributes_maxdays'));
                               $Qopd->bindValue(':download_count', $Qattributes->value('products_attributes_maxcount'));
                               $Qopd->execute();
                             }
                 */
             }
         }
     }
     $_SESSION['prepOrderID'] = $osC_ShoppingCart->getCartID() . '-' . $insert_id;
     return $insert_id;
 }