Exemple #1
0
 function insert($order_status = DEFAULT_ORDERS_STATUS_ID)
 {
     global $osC_Database, $osC_Customer, $osC_Language, $osC_Currencies, $osC_ShoppingCart, $osC_Tax, $toC_Wishlist;
     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]) === ORDERS_STATUS_PREPARING) {
                 osC_Order::remove($_prep[1]);
             }
         }
     }
     if (!class_exists(osC_Account)) {
         require_once 'includes/classes/account.php';
     }
     if (!$osC_Customer->isLoggedOn()) {
         osC_Order::createCustomer();
     } else {
         //insert billing address
         $billing_address = $osC_ShoppingCart->getBillingAddress();
         if (isset($billing_address['id']) && $billing_address['id'] == '-1') {
             osC_Account::createNewAddress($osC_Customer->getID(), $billing_address);
         }
         //insert shipping address
         if (!isset($billing_address['ship_to_this_address']) || isset($billing_address['ship_to_this_address']) && empty($billing_address['ship_to_this_address'])) {
             $shipping_address = $osC_ShoppingCart->getShippingAddress();
             if (isset($shipping_address['id']) && $shipping_address['id'] == '-1') {
                 osC_Account::createNewAddress($osC_Customer->getID(), $shipping_address);
             }
         }
     }
     $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_comment, 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_zone_id, delivery_state_code, delivery_country_id, delivery_country, delivery_country_iso2, delivery_country_iso3, delivery_address_format, delivery_telephone, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_zone_id, billing_state_code, billing_country_id, billing_country, billing_country_iso2, billing_country_iso3, billing_address_format, billing_telephone, payment_method, payment_module, uses_store_credit, store_credit_amount, date_purchased, orders_status, currency, currency_value, gift_wrapping, wrapping_message) values (:customers_id, :customers_name, :customers_company, :customers_street_address, :customers_suburb, :customers_city, :customers_postcode, :customers_state, :customers_comment, :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_zone_id, :delivery_state_code, :delivery_country_id, :delivery_country, :delivery_country_iso2, :delivery_country_iso3, :delivery_address_format, :delivery_telephone, :billing_name, :billing_company, :billing_street_address, :billing_suburb, :billing_city, :billing_postcode, :billing_state, :billing_zone_id, :billing_state_code, :billing_country_id, :billing_country, :billing_country_iso2, :billing_country_iso3, :billing_address_format, :billing_telephone, :payment_method, :payment_module, :uses_store_credit, :store_credit_amount, now(), :orders_status, :currency, :currency_value, :gift_wrapping, :wrapping_message)');
     $Qorder->bindTable(':table_orders', TABLE_ORDERS);
     $Qorder->bindInt(':customers_id', $osC_Customer->getID());
     $Qorder->bindValue(':customers_name', $osC_Customer->getName());
     $Qorder->bindValue(':customers_company', '');
     $Qorder->bindValue(':customers_street_address', '');
     $Qorder->bindValue(':customers_suburb', '');
     $Qorder->bindValue(':customers_city', '');
     $Qorder->bindValue(':customers_postcode', '');
     $Qorder->bindValue(':customers_state', '');
     $Qorder->bindValue(':customers_state_code', '');
     $Qorder->bindValue(':customers_country', '');
     $Qorder->bindValue(':customers_country_iso2', '');
     $Qorder->bindValue(':customers_country_iso3', '');
     $Qorder->bindValue(':customers_telephone', '');
     $Qorder->bindValue(':customers_email_address', $osC_Customer->getEmailAddress());
     $Qorder->bindValue(':customers_comment', $_SESSION['comments']);
     $Qorder->bindValue(':customers_address_format', '');
     $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_zone_id', $osC_ShoppingCart->getShippingAddress('zone_id'));
     $Qorder->bindValue(':delivery_state_code', $osC_ShoppingCart->getShippingAddress('zone_code'));
     $Qorder->bindValue(':delivery_country_id', $osC_ShoppingCart->getShippingAddress('country_id'));
     $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(':delivery_telephone', $osC_ShoppingCart->getShippingAddress('telephone_number'));
     $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_zone_id', $osC_ShoppingCart->getBillingAddress('zone_id'));
     $Qorder->bindValue(':billing_state_code', $osC_ShoppingCart->getBillingAddress('zone_code'));
     $Qorder->bindValue(':billing_country_id', $osC_ShoppingCart->getBillingAddress('country_id'));
     $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(':billing_telephone', $osC_ShoppingCart->getBillingAddress('telephone_number'));
     $Qorder->bindValue(':payment_method', implode(',', $osC_ShoppingCart->getCartBillingMethods()));
     $Qorder->bindValue(':payment_module', implode(',', $osC_ShoppingCart->getCartBillingModules()));
     $Qorder->bindInt(':uses_store_credit', $osC_ShoppingCart->isUseStoreCredit());
     $Qorder->bindValue(':store_credit_amount', $osC_ShoppingCart->isUseStoreCredit() ? $osC_ShoppingCart->getStoreCredit() : '0');
     $Qorder->bindInt(':orders_status', $order_status);
     $Qorder->bindValue(':currency', $osC_Currencies->getCode());
     $Qorder->bindValue(':currency_value', $osC_Currencies->value($osC_Currencies->getCode()));
     $Qorder->bindInt(':gift_wrapping', $osC_ShoppingCart->isGiftWrapping() ? '1' : '0');
     $Qorder->bindValue(':wrapping_message', isset($_SESSION['gift_wrapping_comments']) ? $_SESSION['gift_wrapping_comments'] : '');
     $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', $order_status);
     $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_type, products_sku, products_name, products_price, final_price, products_tax, products_quantity) values (:orders_id, :products_id, :products_type, :products_sku, :products_name, :products_price, :final_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_type', $products['type']);
         $Qproducts->bindValue(':products_sku', $products['sku']);
         $Qproducts->bindValue(':products_name', $products['name']);
         $Qproducts->bindValue(':products_price', $products['price']);
         $Qproducts->bindValue(':final_price', $products['final_price']);
         $Qproducts->bindValue(':products_tax', $osC_Tax->getTaxRate($products['tax_class_id'], $osC_ShoppingCart->getTaxingAddress('country_id'), $osC_ShoppingCart->getTaxingAddress('zone_id')));
         $Qproducts->bindInt(':products_quantity', $products['quantity']);
         $Qproducts->execute();
         $order_products_id = $osC_Database->nextID();
         if (!empty($products['customizations'])) {
             foreach ($products['customizations'] as $customization) {
                 $Qcustomization = $osC_Database->query('insert into :table_orders_products_customizations (orders_id, orders_products_id, quantity) values (:orders_id, :orders_products_id, :quantity)');
                 $Qcustomization->bindTable(':table_orders_products_customizations', TABLE_ORDERS_PRODUCTS_CUSTOMIZATIONS);
                 $Qcustomization->bindInt(':orders_id', $insert_id);
                 $Qcustomization->bindInt(':orders_products_id', $order_products_id);
                 $Qcustomization->bindInt(':quantity', $customization['qty']);
                 $Qcustomization->execute();
                 $orders_products_customizations_id = $osC_Database->nextID();
                 foreach ($customization['fields'] as $field) {
                     $Qfield = $osC_Database->query('insert into :table_orders_products_customizations_values (orders_products_customizations_id , customization_fields_id, customization_fields_name, customization_fields_type, customization_fields_value, cache_file_name) values (:orders_products_customizations_id, :customization_fields_id, :customization_fields_name, :customization_fields_type, :customization_fields_value, :cache_file_name)');
                     $Qfield->bindTable(':table_orders_products_customizations_values', TABLE_ORDERS_PRODUCTS_CUSTOMIZATIONS_VALUES);
                     $Qfield->bindInt(':orders_products_customizations_id', $orders_products_customizations_id);
                     $Qfield->bindInt(':customization_fields_id', $field['customization_fields_id']);
                     $Qfield->bindValue(':customization_fields_name', $field['customization_fields_name']);
                     $Qfield->bindInt(':customization_fields_type', $field['customization_type']);
                     $Qfield->bindValue(':customization_fields_value', $field['customization_value']);
                     $Qfield->bindValue(':cache_file_name', $field['cache_filename']);
                     $Qfield->execute();
                     if ($osC_Database->isError() === false) {
                         @copy(DIR_FS_CACHE . 'products_customizations/' . $field['cache_filename'], DIR_FS_CACHE . 'orders_customizations/' . $field['cache_filename']);
                     }
                 }
             }
         }
         if ($osC_ShoppingCart->hasVariants($products['id'])) {
             foreach ($osC_ShoppingCart->getVariants($products['id']) as $variants_id => $variants) {
                 $Qvariants = $osC_Database->query('select pvg.products_variants_groups_name, pvv.products_variants_values_name from :table_products_variants pv, :table_products_variants_entries pve, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_id = pve.products_variants_id and pve.products_variants_groups_id = :groups_id and pve.products_variants_values_id = :variants_values_id and pve.products_variants_groups_id = pvg.products_variants_groups_id and pve.products_variants_values_id = pvv.products_variants_values_id and pvg.language_id = :pvg_language_id and pvv.language_id = :pvv_language_id');
                 $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                 $Qvariants->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES);
                 $Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
                 $Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
                 $Qvariants->bindInt(':products_id', $products['id']);
                 $Qvariants->bindInt(':groups_id', $variants['groups_id']);
                 $Qvariants->bindInt(':variants_values_id', $variants['variants_values_id']);
                 $Qvariants->bindInt(':pvg_language_id', $osC_Language->getID());
                 $Qvariants->bindInt(':pvv_language_id', $osC_Language->getID());
                 $Qvariants->execute();
                 $Qopv = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values) values (:orders_id, :orders_products_id, :products_variants_groups_id, :products_variants_groups, :products_variants_values_id, :products_variants_values)');
                 $Qopv->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS);
                 $Qopv->bindInt(':orders_id', $insert_id);
                 $Qopv->bindInt(':orders_products_id', $order_products_id);
                 $Qopv->bindInt(':products_variants_groups_id', $variants['groups_id']);
                 $Qopv->bindValue(':products_variants_groups', $Qvariants->value('products_variants_groups_name'));
                 $Qopv->bindInt(':products_variants_values_id', $variants['variants_values_id']);
                 $Qopv->bindValue(':products_variants_values', $Qvariants->value('products_variants_values_name'));
                 $Qopv->execute();
             }
         }
         if ($products['type'] == PRODUCT_TYPE_DOWNLOADABLE) {
             $Qdownloadable = $osC_Database->query('select * from :table_products_downloadables where products_id = :products_id');
             $Qdownloadable->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
             $Qdownloadable->bindInt(':products_id', osc_get_product_id($products['id']));
             $Qdownloadable->execute();
             if ($osC_ShoppingCart->hasVariants($products['id'])) {
                 $variants_filename = $products['variant_filename'];
                 $variants_cache_filename = $products['variant_cache_filename'];
             } else {
                 $variants_filename = $Qdownloadable->value('filename');
                 $variants_cache_filename = $Qdownloadable->value('cache_filename');
             }
             $Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, orders_products_cache_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :orders_products_cache_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', $variants_filename);
             $Qopd->bindValue(':orders_products_cache_filename', $variants_cache_filename);
             $Qopd->bindValue(':download_maxdays', $Qdownloadable->valueInt('number_of_accessible_days'));
             $Qopd->bindValue(':download_count', $Qdownloadable->valueInt('number_of_downloads') * $products['quantity']);
             $Qopd->execute();
         }
         if ($products['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
             require_once 'gift_certificates.php';
             $Qgc = $osC_Database->query('insert into :table_gift_certificates (orders_id, orders_products_id, gift_certificates_type, amount, gift_certificates_code, recipients_name, recipients_email, senders_name, senders_email, messages) values (:orders_id, :orders_products_id, :gift_certificates_type, :amount, :gift_certificates_code, :recipients_name, :recipients_email, :senders_name, :senders_email, :messages)');
             $Qgc->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES);
             $Qgc->bindInt(':orders_id', $insert_id);
             $Qgc->bindInt(':gift_certificates_type', $products['gc_data']['type']);
             $Qgc->bindInt(':orders_products_id', $order_products_id);
             $Qgc->bindValue(':amount', $products['price']);
             $Qgc->bindValue(':gift_certificates_code', toC_Gift_Certificates::createGiftCertificateCode());
             $Qgc->bindValue(':recipients_name', $products['gc_data']['recipients_name']);
             $Qgc->bindValue(':recipients_email', $products['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL ? $products['gc_data']['recipients_email'] : '');
             $Qgc->bindValue(':senders_name', $products['gc_data']['senders_name']);
             $Qgc->bindValue(':senders_email', $products['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL ? $products['gc_data']['senders_email'] : '');
             $Qgc->bindValue(':messages', $products['gc_data']['message']);
             $Qgc->execute();
         }
     }
     if ($osC_ShoppingCart->isUseStoreCredit()) {
         $Qhistory = $osC_Database->query('insert into :table_customers_credits_history (customers_id, action_type, date_added, amount, comments) values (:customers_id, :action_type, now(), :amount, :comments)');
         $Qhistory->bindTable(':table_customers_credits_history', TABLE_CUSTOMERS_CREDITS_HISTORY);
         $Qhistory->bindInt(':customers_id', $osC_Customer->getID());
         $Qhistory->bindInt(':action_type', STORE_CREDIT_ACTION_TYPE_ORDER_PURCHASE);
         $Qhistory->bindValue(':amount', $osC_ShoppingCart->getStoreCredit() * -1);
         $Qhistory->bindValue(':comments', sprintf($osC_Language->get('store_credit_order_number'), $insert_id));
         $Qhistory->execute();
         $Qcustomer = $osC_Database->query('update :table_customers set customers_credits = (customers_credits + :customers_credits) where customers_id = :customers_id');
         $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcustomer->bindRaw(':customers_credits', $osC_ShoppingCart->getStoreCredit() * -1);
         $Qcustomer->bindInt(':customers_id', $osC_Customer->getID());
         $Qcustomer->execute();
         $Qcredit = $osC_Database->query('select customers_credits from :table_customers where customers_id = :customers_id');
         $Qcredit->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcredit->bindInt(':customers_id', $osC_Customer->getID());
         $Qcredit->execute();
         $osC_Customer->setStoreCredit($Qcredit->value('customers_credits'));
     }
     if ($osC_ShoppingCart->hasCoupon()) {
         include_once 'includes/classes/coupon.php';
         $toC_Coupon = new toC_Coupon($osC_ShoppingCart->getCouponCode());
         $Qcoupon = $osC_Database->query('insert into :table_coupons_redeem_history (coupons_id, customers_id, orders_id, redeem_amount, redeem_date, redeem_ip_address) values (:coupons_id, :customers_id, :orders_id, :redeem_amount, now(), :redeem_ip_address)');
         $Qcoupon->bindTable(':table_coupons_redeem_history', TABLE_COUPONS_REDEEM_HISTORY);
         $Qcoupon->bindInt(':coupons_id', $toC_Coupon->getID());
         $Qcoupon->bindInt(':customers_id', $osC_Customer->getID());
         $Qcoupon->bindInt(':orders_id', $insert_id);
         $Qcoupon->bindValue(':redeem_amount', $osC_ShoppingCart->getCouponAmount());
         $Qcoupon->bindValue(':redeem_ip_address', osc_get_ip_address());
         $Qcoupon->execute();
     }
     if ($osC_ShoppingCart->hasGiftCertificate()) {
         $gift_certificate_codes = $osC_ShoppingCart->getGiftCertificateRedeemAmount();
         foreach ($gift_certificate_codes as $gift_certificate_code => $amount) {
             $Qcertificate = $osC_Database->query('select gift_certificates_id from :table_gift_certificates where gift_certificates_code = :gift_certificates_code');
             $Qcertificate->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES);
             $Qcertificate->bindValue(':gift_certificates_code', $gift_certificate_code);
             $Qcertificate->execute();
             $Qinsert = $osC_Database->query('insert into :table_gift_certificates_redeem_history (gift_certificates_id, customers_id, orders_id, redeem_date, redeem_amount, redeem_ip_address) values (:gift_certificates_id, :customers_id, :orders_id, now(), :redeem_amount, :redeem_ip_address)');
             $Qinsert->bindTable(':table_gift_certificates_redeem_history', TABLE_GIFT_CERTIFICATES_REDEEM_HISTORY);
             $Qinsert->bindInt(':gift_certificates_id', $Qcertificate->valueInt(gift_certificates_id));
             $Qinsert->bindInt(':customers_id', $osC_Customer->getID());
             $Qinsert->bindInt(':orders_id', $insert_id);
             $Qinsert->bindValue(':redeem_amount', $amount);
             $Qinsert->bindValue(':redeem_ip_address', osc_get_ip_address());
             $Qinsert->execute();
         }
     }
     $_SESSION['prepOrderID'] = $osC_ShoppingCart->getCartID() . '-' . $insert_id;
     return $insert_id;
 }
Exemple #2
0
 function process()
 {
     global $osC_Database, $osC_Language, $osC_MessageStack;
     $this->_verifyData();
     $params = array('DATA' => $_GET['DATA'], 'SIGNATURE' => $_GET['SIGNATURE']);
     $post_string = '';
     foreach ($params as $key => $value) {
         $post_string .= $key . '=' . urlencode(trim($value)) . '&';
     }
     $post_string = substr($post_string, 0, -1);
     $this->_transaction_response = $this->sendTransactionToGateway('http://support.saferpay.de/scripts/VerifyPayConfirm.asp', $post_string);
     $error = false;
     if (substr($this->_transaction_response, 0, 3) != 'OK:') {
         $error = true;
     }
     /* HPDL; performs capture
           if (substr($this->_transaction_response, 0, 3) == 'OK:') {
             $result = array();
             parse_str(substr($this->_transaction_response, 3), $result);
     
             $params = array('ACCOUNTID' => MODULE_PAYMENT_SAFERPAY_CC_ACCOUNT_ID,
                             'ID' => $result['ID'],
                             'TOKEN' => $result['TOKEN']);
     
             $post_string = '';
     
             foreach ($params as $key => $value) {
               $post_string .= $key . '=' . urlencode(trim($value)) . '&';
             }
     
             $post_string = substr($post_string, 0, -1);
     
             $this->_transaction_response = $this->sendTransactionToGateway('http://support.saferpay.de/scripts/PayComplete.asp', $post_string);
     
             if ($this->_transaction_response != 'OK') {
               $error = true;
             }
           } else {
             $error = true;
           }
     */
     if ($error === false) {
         $osC_XML = new osC_XML($_GET['DATA']);
         $result = $osC_XML->toArray();
         $this->_order_id = $result['IDP attr']['ORDERID'];
         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', $_GET['DATA']);
         $Qtransaction->bindInt(':transaction_return_status', 1);
         $Qtransaction->execute();
     } else {
         osC_Order::remove($this->_order_id);
         $osC_MessageStack->add('checkout_payment', $osC_Language->get('payment_saferpay_vt_error_general'), 'error');
         osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'payment', 'SSL'));
     }
 }
Exemple #3
0
 function process()
 {
     global $osC_Database, $osC_Customer, $osC_Currencies, $osC_ShoppingCart, $osC_Language, $osC_MessageStack, $osC_CreditCard;
     $this->_verifyData();
     $this->_order_id = osC_Order::insert();
     $params = array('spPassword' => MODULE_PAYMENT_SAFERPAY_CC_PASSWORD, 'ACCOUNTID' => MODULE_PAYMENT_SAFERPAY_CC_ACCOUNT_ID, 'ORDERID' => $this->_order_id, 'NAME' => $osC_CreditCard->getOwner(), 'PAN' => $osC_CreditCard->getNumber(), 'EXP' => $osC_CreditCard->getExpiryMonth() . substr($osC_CreditCard->getExpiryYear(), -2), 'AMOUNT' => $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $osC_Currencies->getCode()) * 100, 'CURRENCY' => $osC_Currencies->getCode());
     if (MODULE_PAYMENT_SAFERPAY_CC_VERIFY_WITH_CVC == '1') {
         $params['CVC'] = $osC_CreditCard->getCVC();
     }
     $post_string = '';
     foreach ($params as $key => $value) {
         $post_string .= $key . '=' . urlencode(trim($value)) . '&';
     }
     $post_string = substr($post_string, 0, -1);
     $this->_transaction_response = $this->sendTransactionToGateway('https://support.saferpay.de/scripts/Execute.asp', $post_string);
     $error = false;
     if (substr($this->_transaction_response, 0, 3) == 'OK:') {
         $this->_transaction_response = trim(substr($this->_transaction_response, 3));
         $osC_XML = new osC_XML($this->_transaction_response);
         $result = $osC_XML->toArray();
         switch ($result['IDP attr']['RESULT']) {
             case '0':
                 //success
                 break;
             case '62':
             case '63':
             case '64':
                 $error = $osC_Language->get('payment_saferpay_cc_error_' . (int) $result['IDP attr']['RESULT']);
                 break;
             default:
                 $error = $osC_Language->get('payment_saferpay_cc_error_general');
                 break;
         }
     } else {
         $error = $osC_Language->get('payment_saferpay_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);
         $osC_MessageStack->add('checkout_payment', $error, 'error');
         osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'payment&saferpay_cc_owner=' . $osC_CreditCard->getOwner() . '&saferpay_cc_expires_month=' . $osC_CreditCard->getExpiryMonth() . '&saferpay_cc_expires_year=' . $osC_CreditCard->getExpiryYear() . (MODULE_PAYMENT_SAFERPAY_CC_VERIFY_WITH_CVC == '1' ? '&saferpay_cc_cvc=' . $osC_CreditCard->getCVC() : ''), 'SSL'));
     }
 }
 function process()
 {
     global $osC_Database, $osC_MessageStack, $osC_Customer, $osC_Language, $osC_Currencies, $osC_ShoppingCart;
     $this->_verifyData();
     $this->_order_id = osC_Order::insert();
     $params = array('x_version' => '3.1', 'x_delim_data' => 'TRUE', 'x_delim_char' => ',', 'x_encap_char' => '"', 'x_relay_response' => 'FALSE', 'x_login' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_LOGIN_ID, 'x_tran_key' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TRANSACTION_KEY, 'x_amount' => $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $osC_Currencies->getCode()), 'x_currency_code' => $osC_Currencies->getCode(), 'x_method' => 'ECHECK', 'x_bank_aba_code' => $_POST['authorizenet_echeck_routing_code'], 'x_bank_acct_num' => $_POST['authorizenet_echeck_account_number'], 'x_bank_acct_type' => $_POST['authorizenet_echeck_account_type'], 'x_bank_name' => $_POST['authorizenet_echeck_bank_name'], 'x_bank_acct_name' => $_POST['authorizenet_echeck_owner'], 'x_echeck_type' => 'WEB', 'x_type' => 'AUTH_ONLY', 'x_first_name' => $osC_ShoppingCart->getBillingAddress('firstname'), 'x_last_name' => $osC_ShoppingCart->getBillingAddress('lastname'), 'x_company' => $osC_ShoppingCart->getBillingAddress('company'), 'x_address' => $osC_ShoppingCart->getBillingAddress('street_address'), 'x_city' => $osC_ShoppingCart->getBillingAddress('city'), 'x_state' => $osC_ShoppingCart->getBillingAddress('state'), 'x_zip' => $osC_ShoppingCart->getBillingAddress('postcode'), 'x_country' => $osC_ShoppingCart->getBillingAddress('country_iso_code_2'), 'x_cust_id' => $osC_Customer->getID(), 'x_customer_ip' => osc_get_ip_address(), 'x_invoice_num' => $this->_order_id, 'x_email' => $osC_Customer->getEmailAddress(), 'x_email_customer' => 'FALSE', 'x_ship_to_first_name' => $osC_ShoppingCart->getShippingAddress('firstname'), 'x_ship_to_last_name' => $osC_ShoppingCart->getShippingAddress('lastname'), 'x_ship_to_company' => $osC_ShoppingCart->getShippingAddress('company'), 'x_ship_to_address' => $osC_ShoppingCart->getShippingAddress('street_address'), 'x_ship_to_city' => $osC_ShoppingCart->getShippingAddress('city'), 'x_ship_to_state' => $osC_ShoppingCart->getShippingAddress('state'), 'x_ship_to_zip' => $osC_ShoppingCart->getShippingAddress('postcode'), 'x_ship_to_country' => $osC_ShoppingCart->getShippingAddress('country_iso_code_2'));
     if (ACCOUNT_TELEPHONE > -1) {
         $params['x_phone'] = $osC_ShoppingCart->getBillingAddress('telephone_number');
     }
     if (MODULE_PAYMENT_AUTHORIZENET_ECHECK_TRANSACTION_TEST_MODE == '1') {
         $params['x_test_request'] = 'TRUE';
     }
     if (MODULE_PAYMENT_AUTHORIZENET_ECHECK_VERIFY_WITH_WF_SS == '1') {
         $params['x_customer_organization_type'] = $_POST['authorizenet_echeck_org_type'];
         $params['x_customer_tax_id'] = $_POST['authorizenet_echeck_tax_id'];
     }
     $post_string = '';
     foreach ($params as $key => $value) {
         $post_string .= $key . '=' . urlencode(trim($value)) . '&';
     }
     $post_string = substr($post_string, 0, -1);
     $this->_transaction_response = $this->sendTransactionToGateway($this->_gateway_url, $post_string);
     if (empty($this->_transaction_response) === false) {
         $regs = preg_split("/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/", $this->_transaction_response);
         foreach ($regs as $key => $value) {
             $regs[$key] = substr($value, 1, -1);
             // remove double quotes
         }
     } else {
         $regs = array('-1', '-1', '-1');
     }
     $error = false;
     if ($regs[0] == '1') {
         if (!osc_empty(MODULE_PAYMENT_AUTHORIZENET_ECHECK_MD5_HASH)) {
             if (strtoupper($regs[37]) != strtoupper(md5(MODULE_PAYMENT_AUTHORIZENET_ECHECK_MD5_HASH . MODULE_PAYMENT_AUTHORIZENET_ECHECK_LOGIN_ID . $regs[6] . $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $osC_Currencies->getCode())))) {
                 $error = $osC_Language->get('payment_authorizenet_echeck_error_general');
             }
         }
     } else {
         switch ($regs[2]) {
             case '9':
                 $error = $osC_Language->get('payment_authorizenet_echeck_error_invalid_routing_code');
                 break;
             case '10':
                 $error = $osC_Language->get('payment_authorizenet_echeck_error_invalid_account');
                 break;
             case '77':
                 $error = $osC_Language->get('payment_authorizenet_echeck_error_invalid_tax_id');
                 break;
             default:
                 $error = $osC_Language->get('payment_authorizenet_echeck_error_general');
                 break;
         }
     }
     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);
         $osC_MessageStack->add('checkout_payment', $error, 'error');
         osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'payment&authorizenet_echeck_owner=' . $_POST['authorizenet_echeck_owner'] . '&authorizenet_echeck_account_type=' . $_POST['authorizenet_echeck_account_type'] . '&authorizenet_echeck_bank_name=' . $_POST['authorizenet_echeck_bank_name'] . '&authorizenet_echeck_routing_code=' . $_POST['authorizenet_echeck_routing_code'], 'SSL'));
     }
 }
Exemple #5
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'));
     }
 }
Exemple #6
0
 function callback()
 {
     global $osC_Database, $osC_ShoppingCart;
     if (empty($_GET['order_id']) || empty($_GET['order_code'])) {
         // Invalid request
     } else {
         $sOrderId = $_GET['order_id'];
         $sOrderCode = $_GET['order_code'];
         $sql = "SELECT `transaction_status`, `transaction_url` FROM `" . DB_TABLE_PREFIX . "transactions` WHERE (`order_id` = '" . addslashes($sOrderId) . "') AND (`order_code` = '" . addslashes($sOrderCode) . "') ORDER BY `id` DESC LIMIT 1;";
         $oQuery = $osC_Database->query($sql);
         $oRecordset = $oQuery->execute();
         if (mysql_num_rows($oRecordset)) {
             $oRecord = mysql_fetch_assoc($oRecordset);
             $iOrderId = (int) $sOrderId;
             $sTransactionStatus = $oRecord['transaction_status'];
             $sTransactionUrl = $oRecord['transaction_url'];
             if (osC_Order::exists($iOrderId)) {
                 if (strcmp($sTransactionStatus, 'SUCCESS') === 0) {
                     // Update order status
                     osC_Order::process($iOrderId, MODULE_PAYMENT_IDEAL_SUCCESS_ORDER_STATUS_ID);
                     $osC_ShoppingCart->reset(true);
                     // Redirect
                     osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'success', 'SSL'));
                 } elseif (strcmp($sTransactionStatus, 'PENDING') === 0) {
                     // Update order status
                     osC_Order::process($iOrderId, MODULE_PAYMENT_IDEAL_PENDING_ORDER_STATUS_ID);
                     $osC_ShoppingCart->reset(true);
                     // Redirect
                     osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'success', 'SSL'));
                 } elseif (strcmp($sTransactionStatus, 'OPEN') === 0) {
                     // Update order status
                     osC_Order::process($iOrderId, MODULE_PAYMENT_IDEAL_OPEN_ORDER_STATUS_ID);
                     if ($sTransactionUrl) {
                         // Redirect
                         osc_redirect($sTransactionUrl);
                     }
                 } elseif (strcmp($sTransactionStatus, 'CANCELLED') === 0) {
                     if (MODULE_PAYMENT_IDEAL_REMOVE_ORDER_ON_CANCELLED) {
                         // Remove Order
                         osC_Order::remove($iOrderId);
                     } else {
                         // Update order status
                         osC_Order::process($iOrderId, MODULE_PAYMENT_IDEAL_CANCELLED_ORDER_STATUS_ID);
                     }
                     // Redirect
                     osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'payment', 'SSL'));
                 } elseif (strcmp($sTransactionStatus, 'EXPIRED') === 0) {
                     // Update order status
                     osC_Order::process($iOrderId, MODULE_PAYMENT_IDEAL_EXPIRED_ORDER_STATUS_ID);
                 } elseif (strcmp($sTransactionStatus, 'FAILURE') === 0) {
                     // Update order status
                     osC_Order::process($iOrderId, MODULE_PAYMENT_IDEAL_FAILURE_ORDER_STATUS_ID);
                 }
                 // Redirect
                 osc_redirect(HTTPS_SERVER . DIR_WS_HTTPS_CATALOG . '/ext/payments/ideal/setup.php?order_id=' . $sOrderId . '&order_code=' . $sOrderCode);
             }
         }
     }
     echo 'Cannot verify your order and/or payment. Please contact the webmaster.';
     exit;
 }
Exemple #7
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_EFT_BUSINESS_SIGNATURE . '</BusinessCaseSignature>' . "\n" . '      <FNC_FT_DEBIT>' . "\n" . '        <FunctionID>Debit 1</FunctionID>' . "\n" . '        <FT_TRANSACTION mode="' . MODULE_PAYMENT_WIRECARD_EFT_TRANSACTION_MODE . '">' . "\n" . '          <TransactionID>' . $this->_order_id . '</TransactionID>' . "\n" . '          <EXTERNAL_ACCOUNT>' . "\n" . '            <FirstName>' . $_POST['wirecard_eft_owner_first'] . '</FirstName>' . "\n" . '            <LastName>' . $_POST['wirecard_eft_owner_last'] . '</LastName>' . "\n" . '            <AccountNumber>' . $_POST['wirecard_eft_account'] . '</AccountNumber>' . "\n" . '            <AccountType>' . $_POST['wirecard_eft_account_type'] . '</AccountType>' . "\n" . '            <BankCode>' . $_POST['wirecard_eft_bank_code'] . '</BankCode>' . "\n" . '            <Country>' . $osC_ShoppingCart->getBillingAddress('country_iso_code_2') . '</Country>' . "\n" . '            <CheckNumber>' . $_POST['wirecard_eft_check_number'] . '</CheckNumber>' . "\n";
     if ($osC_ShoppingCart->getBillingAddress('country_iso_code_2') == 'IT') {
         $post_string .= '            <COUNTRY_SPECIFIC>' . "\n" . '              <IdentificationNumber>' . $_POST['wirecard_eft_id_number'] . '</IdentificationNumber>' . "\n" . '            </COUNTRY_SPECIFIC>' . "\n";
     }
     $post_string .= '          </EXTERNAL_ACCOUNT>' . "\n" . '          <Amount>' . $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $osC_Currencies->getCode()) * 100 . '</Amount>' . "\n" . '          <Currency>' . $osC_Currencies->getCode() . '</Currency>' . "\n" . '          <CORPTRUSTCENTER_DATA>' . "\n" . '            <ADDRESS>' . "\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" . '        </FT_TRANSACTION>' . "\n" . '      </FNC_FT_DEBIT>' . "\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_FT_DEBIT']['FT_TRANSACTION']['PROCESSING_STATUS']['FunctionResult'])) {
         if ($result['WIRECARD_BXML']['W_RESPONSE']['W_JOB']['FNC_FT_DEBIT']['FT_TRANSACTION']['PROCESSING_STATUS']['FunctionResult'] != 'ACK') {
             //          $errno = $result['WIRECARD_BXML']['W_RESPONSE']['W_JOB']['FNC_FT_DEBIT']['FT_TRANSACTION']['PROCESSING_STATUS']['DETAIL']['ReturnCode'];
             //          switch ($errno) {
             //            default:
             $error = $osC_Language->get('payment_wirecard_eft_error_general');
             //              break;
             //          }
         }
     } else {
         $error = $osC_Language->get('payment_wirecard_eft_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_eft_owner_first=' . $_POST['wirecard_eft_owner_first'] . '&wirecard_eft_owner_last=' . $_POST['wirecard_eft_owner_last'] . '&wirecard_eft_account_type=' . $_POST['wirecard_eft_account_type'] . '&wirecard_eft_bank=' . $_POST['wirecard_eft_bank'] . '&wirecard_eft_check_number=' . $_POST['wirecard_eft_check_number'] . ($osC_ShoppingCart->getBillingAddress('country_iso_code_2') == 'IT' ? '&wirecard_eft_id_number=' . $_POST['wirecard_eft_id_number'] : ''), 'SSL'));
     }
 }
Exemple #8
0
 function process()
 {
     global $osC_Database, $osC_Customer, $osC_Currencies, $osC_ShoppingCart, $osC_Language, $messageStack;
     $this->_verifyData();
     $this->_order_id = osC_Order::insert();
     $params = array('spPassword' => MODULE_PAYMENT_SAFERPAY_CC_PASSWORD, 'ACCOUNTID' => MODULE_PAYMENT_SAFERPAY_CC_ACCOUNT_ID, 'ORDERID' => $this->_order_id, 'NAME' => $_POST['saferpay_elv_owner'], 'TRACK2' => ';59' . $_POST['saferpay_elv_bank'] . '=' . str_pad($_POST['saferpay_elv_account'], 10, '0', STR_PAD_LEFT), 'AMOUNT' => $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $osC_Currencies->getCode()) * 100, 'CURRENCY' => $osC_Currencies->getCode());
     $post_string = '';
     foreach ($params as $key => $value) {
         $post_string .= $key . '=' . urlencode(trim($value)) . '&';
     }
     $post_string = substr($post_string, 0, -1);
     $this->_transaction_response = $this->sendTransactionToGateway('https://support.saferpay.de/scripts/Execute.asp', $post_string);
     $error = false;
     if (substr($this->_transaction_response, 0, 3) == 'OK:') {
         $this->_transaction_response = trim(substr($this->_transaction_response, 3));
         $osC_XML = new osC_XML($this->_transaction_response);
         $result = $osC_XML->toArray();
         switch ($result_array['IDP attr']['RESULT']) {
             case '0':
                 //success
                 break;
             default:
                 $error = $osC_Language->get('payment_saferpay_elv_error_general');
                 break;
         }
     } else {
         $error = $osC_Language->get('payment_saferpay_elv_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&saferpay_elv_owner=' . $_POST['saferpay_elv_owner'] . '&saferpay_elv_bank=' . $_POST['saferpay_elv_bank'], 'SSL'));
     }
 }
Exemple #9
0
 function process()
 {
     global $osC_Customer, $osC_Language, $osC_Currencies, $osC_ShoppingCart, $_POST, $_GET, $osC_Database, $messageStack;
     // get data from pasargad
     $tref = $_GET['tref'];
     //TransactionReferenceID
     $iNumber = $_GET['iN'];
     //invoiceNumber
     $iDate = $_GET['iD'];
     //invoiceDate
     $this->_order_id = osC_Order::insert(ORDERS_STATUS_PREPARING);
     $order = $this->_order_id;
     if (MODULE_PAYMENT_BPI_CURRENCY == 'Selected Currency') {
         $currency = $osC_Currencies->getCode();
     } else {
         $currency = MODULE_PAYMENT_BPI_CURRENCY;
     }
     $amount = round($osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $currency), 2);
     require_once 'ext/bpiclass/parser.php';
     $result = post2https($tref, 'https://pep.shaparak.ir/CheckTransactionResult.aspx');
     $array = makeXMLTree($result);
     $state = strtolower($array["resultObj"]["result"]);
     $action = $array["resultObj"]["action"];
     $invoiceNumber = $array["resultObj"]["invoiceNumber"];
     $invoiceDate = $array["resultObj"]["invoiceDate"];
     $merchantCode = $array["resultObj"]["merchantCode"];
     $terminalCode = $array["resultObj"]["terminalCode"];
     $traceNumber = $array["resultObj"]["traceNumber"];
     $referenceNumber = $array["resultObj"]["referenceNumber"];
     $transactionDate = $array["resultObj"]["transactionDate"];
     if ($state == "true" and $action == "1003" and $merchantCode == MODULE_PAYMENT_BPI_MERCHANT_CODE and $terminalCode == MODULE_PAYMENT_BPI_TERMINAL_CODE and $invoiceDate == $iDate and $invoiceNumber == $order) {
         // here we update our order state
         $this->_order_id = osC_Order::insert();
         $comments = $osC_Language->get('payment_bpi_transaction_id') . '[' . $tref . ']' . $osC_Language->get('payment_bpi_reference_id') . '[' . $referenceNumber . ']';
         osC_Order::process($this->_order_id, $this->order_status, $comments);
         // here we save our database
         $osC_Database->simpleQuery("insert into `" . DB_TABLE_PREFIX . "online_transactions`\n\t\t\t\t\t  \t\t(orders_id,receipt_id,transaction_method,transaction_date,transaction_amount,transaction_id) values\n\t\t                    ('{$order}','{$referenceNumber}','bpi','{$transactionDate}','{$amount}','{$tref}')\n\t\t\t\t\t         ");
         //
         $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', $order);
         $Qtransaction->bindInt(':transaction_code', 1);
         $Qtransaction->bindValue(':transaction_return_value', $referenceNumber);
         $Qtransaction->bindInt(':transaction_return_status', 1);
         $Qtransaction->execute();
     } else {
         osC_Order::remove($this->_order_id);
         if ($state == "false" and $merchantCode == MODULE_PAYMENT_BPI_MERCHANT_CODE and $terminalCode == MODULE_PAYMENT_BPI_TERMINAL_CODE and $invoiceDate == $iDate and $invoiceNumber == $order) {
             $messageStack->add_session('checkout', $osC_Language->get('payment_bpi_unsuccessful_payment'), 'error');
         } elseif ($state == "false" and ($merchantCode != MODULE_PAYMENT_BPI_MERCHANT_CODE or $terminalCode != MODULE_PAYMENT_BPI_TERMINAL_CODE or $invoiceDate != $iDate or $invoiceNumber != $order)) {
             $messageStack->add_session('checkout', $osC_Language->get('payment_bpi_contradictory_in_information'), 'error');
         } else {
             $messageStack->add_session('checkout', $osC_Language->get('payment_bpi_payment_not_confirmed'), 'error');
         }
         osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
     }
 }
Exemple #10
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();
     $params = array('action' => 'ns_quicksale_cc', 'acctid' => MODULE_PAYMENT_PAYQUAKE_CC_ACCOUNT_ID, 'amount' => $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), 'USD'), 'ccname' => $osC_CreditCard->getOwner(), 'expmon' => $osC_CreditCard->getExpiryMonth(), 'expyear' => $osC_CreditCard->getExpiryYear(), 'authonly' => '1', 'ci_companyname' => $osC_ShoppingCart->getBillingAddress('company'), 'ci_billaddr1' => $osC_ShoppingCart->getBillingAddress('street_address'), 'ci_billcity' => $osC_ShoppingCart->getBillingAddress('city'), 'ci_billstate' => $osC_ShoppingCart->getBillingAddress('zone_code'), 'ci_billzip' => $osC_ShoppingCart->getBillingAddress('postcode'), 'ci_billcountry' => $osC_ShoppingCart->getBillingAddress('country_title'), 'ci_shipaddr1' => $osC_ShoppingCart->getShippingAddress('street_address'), 'ci_shipcity' => $osC_ShoppingCart->getShippingAddress('city'), 'ci_shipstate' => $osC_ShoppingCart->getShippingAddress('zone_code'), 'ci_shipzip' => $osC_ShoppingCart->getShippingAddress('postcode'), 'ci_shipcountry' => $osC_ShoppingCart->getShippingAddress('country_title'), 'ci_phone' => $osC_ShoppingCart->getBillingAddress('telephone_number'), 'ci_email' => $osC_Customer->getEmailAddress(), 'email_from' => STORE_OWNER_EMAIL_ADDRESS, 'ci_ipaddress' => osc_get_ip_address(), 'merchantordernumber' => $osC_Customer->getID(), 'pocustomerrefid' => $this->_order_id);
     if (!osc_empty(MODULE_PAYMENT_PAYQUAKE_CC_3DES)) {
         $key = pack('H48', MODULE_PAYMENT_PAYQUAKE_CC_3DES);
         $data = bin2hex(mcrypt_encrypt(MCRYPT_3DES, $key, $osC_CreditCard->getNumber(), MCRYPT_MODE_ECB));
         $params['ccnum'] = $data;
         unset($key);
         unset($data);
     } else {
         $params['ccnum'] = $osC_CreditCard->getNumber();
     }
     if (MODULE_PAYMENT_PAYQUAKE_CC_VERIFY_WITH_CVC == '1') {
         $params['cvv2'] = $osC_CreditCard->getCVC();
     }
     if (!osc_empty(MODULE_PAYMENT_PAYQUAKE_CC_MERCHANT_PIN)) {
         $params['merchantPIN'] = MODULE_PAYMENT_PAYQUAKE_CC_MERCHANT_PIN;
     }
     $post_string = '';
     foreach ($params as $key => $value) {
         $post_string .= $key . '=' . urlencode(trim($value)) . '&';
     }
     $post_string = substr($post_string, 0, -1);
     $this->_transaction_response = $this->sendTransactionToGateway('https://trans.merchantpartners.com/cgi-bin/process.cgi', $post_string);
     $error = false;
     if (!empty($this->_transaction_response)) {
         $regs = explode("\n", trim($this->_transaction_response));
         array_shift($regs);
         $result = array();
         foreach ($regs as $response) {
             $res = explode('=', $response, 2);
             $result[strtolower(trim($res[0]))] = trim($res[1]);
         }
         if ($result['status'] != 'Accepted') {
             $error = explode(':', $result['reason'], 3);
             $error = $error[2];
             if (empty($error)) {
                 $error = $osC_Language->get('payment_payquake_cc_error_general');
             }
         }
     } else {
         $error = $osC_Language->get('payment_payquake_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&payquake_cc_owner=' . $osC_CreditCard->getOwner() . '&payquake_cc_expires_month=' . $osC_CreditCard->getExpiryMonth() . '&payquake_cc_expires_year=' . $osC_CreditCard->getExpiryYear() . (MODULE_PAYMENT_PAYQUAKE_CC_VERIFY_WITH_CVC == '1' ? '&payquake_cc_cvc=' . $osC_CreditCard->getCVC() : ''), 'SSL'));
     }
 }
 function process()
 {
     global $osC_Database, $osC_Customer, $osC_Currencies, $osC_ShoppingCart, $osC_Language, $messageStack, $osC_CreditCard;
     $this->_verifyData();
     $this->_order_id = osC_Order::insert();
     $params = array('orderID' => $this->_order_id, 'PSPID' => MODULE_PAYMENT_OGONE_DIRECTLINK_CC_MERCHANT_ID, 'PSWD' => MODULE_PAYMENT_OGONE_DIRECTLINK_CC_PASSWORD, 'amount' => $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $osC_Currencies->getCode()) * 100, 'currency' => $osC_Currencies->getCode(), 'CARDNO' => $osC_CreditCard->getNumber(), 'ED' => $osC_CreditCard->getExpiryMonth() . '/' . substr($osC_CreditCard->getExpiryYear(), -2), 'CVC' => $osC_CreditCard->getCVC(), 'CN' => $osC_CreditCard->getOwner(), 'EMAIL' => $osC_Customer->getEmailAddress(), 'Owneraddress' => $osC_ShoppingCart->getBillingAddress('street_address'), 'OwnerZip' => $osC_ShoppingCart->getBillingAddress('postcode'), 'Ecom_Payment_Card_Verification' => $osC_CreditCard->getCVC(), 'Operation' => 'RES', 'REMOTE_ADDR' => osc_get_ip_address(), 'COM' => 'Customer ID: ' . $osC_Customer->getID());
     if (osc_empty(MODULE_PAYMENT_OGONE_DIRECTLINK_CC_USER_ID) === false) {
         $params['USERID'] = MODULE_PAYMENT_OGONE_DIRECTLINK_CC_USER_ID;
     }
     if (osc_empty(MODULE_PAYMENT_OGONE_DIRECTLINK_CC_SHA1_SIGNATURE) === false) {
         $params['SHASign'] = sha1($this->_order_id . $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $osC_Currencies->getCode()) * 100 . $osC_Currencies->getCode() . $osC_CreditCard->getNumber() . MODULE_PAYMENT_OGONE_DIRECTLINK_CC_MERCHANT_ID . 'RES' . MODULE_PAYMENT_OGONE_DIRECTLINK_CC_SHA1_SIGNATURE);
     }
     $post_string = '';
     foreach ($params as $key => $value) {
         $post_string .= $key . '=' . urlencode(trim($value)) . '&';
     }
     $post_string = substr($post_string, 0, -1);
     $this->_transaction_response = $this->sendTransactionToGateway($this->_gateway_url, $post_string);
     if (empty($this->_transaction_response) === false) {
         $osC_XML = new osC_XML($this->_transaction_response);
         $result = $osC_XML->toArray();
     } else {
         $result = array('ncresponse attr' => array('STATUS' => ''));
     }
     switch ($result['ncresponse attr']['STATUS']) {
         case '':
         case '0':
         case '2':
             osC_Order::remove($this->_order_id);
             $messageStack->add_session('checkout_payment', $osC_Language->get('payment_ogone_directlink_cc_error_general'), 'error');
             osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'payment&ogone_directlink_cc_owner=' . $osC_CreditCard->getOwner() . '&ogone_directlink_cc_expires_month=' . $osC_CreditCard->getExpiryMonth() . '&ogone_directlink_cc_expires_year=' . $osC_CreditCard->getExpiryYear() . (MODULE_PAYMENT_OGONE_DIRECTLINK_CC_VERIFY_WITH_CVC == '1' ? '&ogone_directlink_cc_cvc=' . $osC_CreditCard->getCVC() : ''), 'SSL'));
             break;
     }
     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();
 }
Exemple #12
0
 function process()
 {
     global $osC_Database, $osC_Customer, $osC_Currencies, $osC_ShoppingCart, $_POST, $_GET, $osC_Language, $messageStack;
     require_once 'ext/lib/nusoap.php';
     $ResNum = $_POST['ResNum'];
     $RefNum = $_POST['RefNum'];
     $State = $_POST['State'];
     // get amount & order Id
     if (MODULE_PAYMENT_ENBANK_CURRENCY == 'Selected Currency') {
         $currency = $osC_Currencies->getCode();
     } else {
         $currency = MODULE_PAYMENT_ENBANK_CURRENCY;
     }
     $amount = round($osC_Currencies->formatRaw($osC_ShoppingCart->getTotal(), $currency), 2);
     //
     if ($State != 'OK' and $RefNum == '') {
         // here we update our database
         osC_Order::remove($this->_order_id);
         $messageStack->add_session('checkout', check_enbank_state_error($State), 'error');
         osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
     } else {
         $soapclient = new nusoap_client('https://pna.shaparak.ir/ref-payment/jax/merchantAuth?wsdl', 'wsdl');
         //	$soapclient->debug_flag=true;
         $soapProxy = $soapclient->getProxy();
         //	if($err=$soapclient->getError())
         //		echo $err ;
         //	echo $soapclient->debug_str;
         //	$i = 5; //to garantee the connection and verify, this process should be repeat maximum 5 times
         //	do{
         $res = $soapProxy->verifyTransaction($RefNum, MODULE_PAYMENT_ENBANK_MERCHANT_ID);
         //reference number and sellerid
         //		$i -= 1;
         //  } while((!$res) and ($i>0));
         $err = $soapProxy->getError();
         if ($err) {
             osC_Order::remove($this->_order_id);
             $messageStack->add_session('checkout', 'خطا در تایید تراکنش ، مبلغ تراکنش با موفقیت به حساب شما برگشت داده خواهد شد.', 'error');
             osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
             die;
         }
         if ($res <= 0) {
             // this is a unsucccessfull payment
             // we update our DataBase
             osC_Order::remove($this->_order_id);
             $messageStack->add_session('checkout', check_enbank_res_error($res), 'error');
             osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
         } else {
             if ($res == $amount) {
                 // this is a succcessfull payment
                 // we update our DataBase
                 // insert ref id in database
                 $osC_Database->simpleQuery("insert into `" . DB_TABLE_PREFIX . "online_transactions`\n\t\t\t\t\t  \t\t(orders_id,receipt_id,transaction_method,transaction_date,transaction_amount,transaction_id) values\n\t\t                    ('{$ResNum}','{$RefNum}','enbank','" . date("YmdHis") . "','{$amount}','{$RefNum}')\n\t\t\t\t\t  ");
                 //
                 $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', $ResNum);
                 $Qtransaction->bindInt(':transaction_code', 1);
                 $Qtransaction->bindValue(':transaction_return_value', $RefNum);
                 $Qtransaction->bindInt(':transaction_return_status', 1);
                 $Qtransaction->execute();
                 //
                 $this->_order_id = osC_Order::insert();
                 $comments = $osC_Language->get('payment_enbank_method_authority') . '[' . $RefNum . ']';
                 osC_Order::process($this->_order_id, $this->order_status, $comments);
             } else {
                 osC_Order::remove($this->_order_id);
                 $messageStack->add_session('checkout', 'خطا در تاييد مبلغ تراکنش ، مبلغ تراکنش با موفقيت به حساب شما برگشت داده خواهد شد.', 'error');
                 osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
             }
         }
     }
 }
Exemple #13
0
 function process()
 {
     global $osC_Language, $osC_Customer, $osC_ShoppingCart, $_POST, $_GET, $messageStack, $osC_Database;
     $authority = $_REQUEST['au'];
     $status = $_REQUEST['rs'];
     $this->_order_id = osC_Order::insert(ORDERS_STATUS_PREPARING);
     $order = $this->_order_id;
     // order id for reversal
     if ($authority) {
         // here we update our database
         if ($status == '0') {
             //curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
             //$page = curl_exec ($ch);
             if (MODULE_PAYMENT_PEC_GATEWAY == 'pec-shaparak') {
                 $client = new nusoap_client('https://pec.shaparak.ir/pecpaymentgateway/eshopservice.asmx?wsdl', 'wsdl');
             } elseif (MODULE_PAYMENT_PEC_GATEWAY == 'pec24') {
                 $client = new nusoap_client('https://www.pec24.com/pecpaymentgateway/eshopservice.asmx?wsdl', 'wsdl');
             } else {
                 $client = new nusoap_client('https://www.pecco24.com:27635/pecpaymentgateway/eshopservice.asmx?wsdl', 'wsdl');
             }
             ///////////////// INQUIRY REQUEST
             $inquiryauthority = $authority;
             $inquirystatus = 1;
             // default status
             // Check for an error
             $err = $client->getError();
             if ($err) {
                 echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
                 die;
             }
             $parameters = array('pin' => MODULE_PAYMENT_PEC_PIN, 'authority' => $inquiryauthority, 'status' => $inquirystatus);
             // Call the SOAP method
             $result = $client->call('PinPaymentEnquiry', $parameters);
             // Check for a fault
             if ($client->fault) {
                 echo '<h2>Fault1</h2><pre>';
                 print_r($result);
                 echo '</pre>';
                 die;
             } else {
                 $resultStr = $result;
                 $status = $resultStr['status'];
                 if ($status == '0') {
                     //$status==0 --> $status==a2l2i for test
                     // this is a succcessfull payment
                     // we update our DataBase
                     //  save transaction_id to database
                     $osC_Database->simpleQuery("update `" . DB_TABLE_PREFIX . "online_transactions` set transaction_id = '{$authority}',transaction_date = '" . date("YmdHis") . "' where 1 and ( receipt_id = '{$authority}' )");
                     //
                     $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', $order);
                     $Qtransaction->bindInt(':transaction_code', 1);
                     $Qtransaction->bindValue(':transaction_return_value', $authority);
                     $Qtransaction->bindInt(':transaction_return_status', 1);
                     $Qtransaction->execute();
                     //
                     $this->_order_id = osC_Order::insert();
                     $comments = $osC_Language->get('payment_pec_method_authority') . '[' . $authority . ']';
                     osC_Order::process($this->_order_id, $this->order_status, $comments);
                 } else {
                     $err = $client->getError();
                     if ($err) {
                         //$err --> $err='ali' for test
                         ///////////////// REVERSAL REQUEST
                         $order = $this->_order_id;
                         // order id for reversal
                         $orderid = $order;
                         $reversaltoreversal = $order;
                         $reversalstatus = 1;
                         // default status
                         // Check for an error
                         $err = $client->getError();
                         if ($err) {
                             echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
                             die;
                         }
                         $parameters = array('pin' => MODULE_PAYMENT_PEC_PIN, 'orderId' => $orderid, 'orderToReversal' => $reversaltoreversal, 'status' => $reversalstatus);
                         // Call the SOAP method
                         $result = $client->call('PinReversal', $parameters);
                         // Check for a fault
                         if ($client->fault) {
                             echo '<h2>Fault3</h2><pre>';
                             print_r($result);
                             echo '</pre>';
                             die;
                         } else {
                             $resultStr = $result;
                             $err = $client->getError();
                             if ($err) {
                                 // Display the error
                                 echo '<h2>Error</h2><pre>' . $err . '</pre>';
                                 die;
                             } else {
                                 // Update Table, Save Reversal Status
                                 // Note: Successful Reversal means that sale is reversed.
                                 //echo "<script>alert('Reversal Response is : " . $resultStr . "');</script>";
                                 //	echo "Reversal Response is : " . $resultStr;
                                 //  delete receipt id from database
                                 $osC_Database->simpleQuery("delete from `" . DB_TABLE_PREFIX . "online_transactions` where 1 and ( receipt_id = '{$authority}' ) and ( orders_id = '{$order}' )");
                                 //
                                 osC_Order::remove($this->_order_id);
                                 $messageStack->add_session('checkout', 'خطا در تایید تراکنش ، مبلغ تراکنش با موفقیت به حساب شما برگشت داده شد.', 'error');
                                 osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
                                 //
                             }
                             // end Display the result
                         }
                         // end Check for errors
                     }
                     //  delete receipt id from database
                     $osC_Database->simpleQuery("delete from `" . DB_TABLE_PREFIX . "online_transactions` where 1 and ( receipt_id = '{$authority}' ) and ( orders_id = '{$order}' )");
                     //
                     osC_Order::remove($this->_order_id);
                     $messageStack->add_session('checkout', check_pec_state_error($status), 'error');
                     osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
                     //
                 }
             }
         } else {
             //  delete receipt id from database
             $osC_Database->simpleQuery("delete from `" . DB_TABLE_PREFIX . "online_transactions` where 1 and ( receipt_id = '{$authority}' ) and ( orders_id = '{$order}' )");
             //
             // this is a UNsucccessfull payment
             osC_Order::remove($this->_order_id);
             $messageStack->add_session('checkout', check_pec_state_error($status), 'error');
             osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
         }
     } else {
         //  delete receipt id from database
         $osC_Database->simpleQuery("delete from `" . DB_TABLE_PREFIX . "online_transactions` where 1 and ( orders_id = '{$order}' )");
         //
         // this is a UNsucccessfull payment
         osC_Order::remove($this->_order_id);
         $messageStack->add_session('checkout', check_pec_state_error($status), 'error');
         osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true));
     }
 }
 function process()
 {
     global $osC_Currencies, $osC_ShoppingCart, $messageStack, $osC_Customer, $osC_Tax, $osC_CreditCard;
     $this->_verifyData();
     $orders_id = osC_Order::insert();
     $params = array('x_login' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_API_LOGIN_ID, 0, 20), 'x_tran_key' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_API_TRANSACTION_KEY, 0, 16), 'x_version' => '3.1', 'x_delim_data' => 'TRUE', 'x_delim_char' => ',', 'x_encap_char' => '"', 'x_relay_response' => 'FALSE', 'x_first_name' => substr($osC_ShoppingCart->getBillingAddress('firstname'), 0, 50), 'x_last_name' => substr($osC_ShoppingCart->getBillingAddress('lastname'), 0, 50), 'x_company' => substr($osC_ShoppingCart->getBillingAddress('company'), 0, 50), 'x_address' => substr($osC_ShoppingCart->getBillingAddress('street_address'), 0, 60), 'x_city' => substr($osC_ShoppingCart->getBillingAddress('city'), 0, 40), 'x_state' => substr($osC_ShoppingCart->getBillingAddress('state'), 0, 40), 'x_zip' => substr($osC_ShoppingCart->getBillingAddress('postcode'), 0, 20), 'x_country' => substr($osC_ShoppingCart->getBillingAddress('country_iso_code_2'), 0, 60), 'x_cust_id' => substr($osC_Customer->getID(), 0, 20), 'x_customer_ip' => osc_get_ip_address(), 'x_invoice_num' => $order_id, 'x_email' => substr($osC_Customer->getEmailAddress(), 0, 255), 'x_description' => substr(STORE_NAME, 0, 255), 'x_amount' => substr($osC_Currencies->formatRaw($osC_ShoppingCart->getTotal()), 0, 15), 'x_currency_code' => substr($osC_Currencies->getCode(), 0, 3), 'x_method' => 'CC', 'x_type' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD == 'Capture' ? 'AUTH_CAPTURE' : 'AUTH_ONLY', 'x_card_num' => $osC_CreditCard->getNumber(), 'x_exp_date' => $osC_CreditCard->getExpiryMonth() . $osC_CreditCard->getExpiryYear());
     if (ACCOUNT_TELEPHONE > -1) {
         $params['x_phone'] = $osC_ShoppingCart->getBillingAddress('telephone_number');
     }
     if (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_VERIFY_WITH_CVC == '1') {
         $params['x_card_code'] = $osC_CreditCard->getCVC();
     }
     if ($osC_ShoppingCart->hasShippingAddress()) {
         $params['x_ship_to_first_name'] = substr($osC_ShoppingCart->getShippingAddress('firstname'), 0, 50);
         $params['x_ship_to_last_name'] = substr($osC_ShoppingCart->getShippingAddress('lastname'), 0, 50);
         $params['x_ship_to_company'] = substr($osC_ShoppingCart->getShippingAddress('company'), 0, 50);
         $params['x_ship_to_address'] = substr($osC_ShoppingCart->getShippingAddress('street_address'), 0, 60);
         $params['x_ship_to_city'] = substr($osC_ShoppingCart->getShippingAddress('city'), 0, 40);
         $params['x_ship_to_state'] = substr($osC_ShoppingCart->getShippingAddress('zone_code'), 0, 40);
         $params['x_ship_to_zip'] = substr($osC_ShoppingCart->getShippingAddress('postcode'), 0, 20);
         $params['x_ship_to_country'] = substr($osC_ShoppingCart->getShippingAddress('country_iso_code_2'), 0, 60);
     }
     if (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE == 'Test') {
         $params['x_test_request'] = 'TRUE';
     }
     $shipping_tax = $osC_ShoppingCart->getShippingMethod('cost') * ($osC_Tax->getTaxRate($osC_ShoppingCart->getShippingMethod('tax_class_id'), $osC_ShoppingCart->getTaxingAddress('country_id'), $osC_ShoppingCart->getTaxingAddress('zone_id')) / 100);
     $total_tax = $osC_ShoppingCart->getTax() - $shipping_tax;
     if ($total_tax > 0) {
         $params['x_tax'] = $osC_Currencies->formatRaw($total_tax);
     }
     $params['x_freight'] = $osC_Currencies->formatRaw($osC_ShoppingCart->getShippingMethod('cost'));
     $post_string = '';
     foreach ($params as $key => $value) {
         $post_string .= $key . '=' . urlencode(trim($value)) . '&';
     }
     $post_string = substr($post_string, 0, -1);
     if ($osC_ShoppingCart->hasContents()) {
         $i = 1;
         foreach ($osC_ShoppingCart->getProducts() as $product) {
             $post_string .= '&x_line_item=' . urlencode($i) . '<|>' . urlencode(substr($product['name'], 0, 31)) . '<|>' . urlencode(substr($product['name'], 0, 255)) . '<|>' . urlencode($product['quantity']) . '<|>' . urlencode($osC_Currencies->formatRaw($product['final_price'])) . '<|>' . urlencode($product['tax_class_id'] > 0 ? 'YES' : 'NO');
             $i++;
         }
     }
     switch (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER) {
         case 'Live':
             $gateway_url = 'https://secure.authorize.net/gateway/transact.dll';
             break;
         default:
             $gateway_url = 'https://test.authorize.net/gateway/transact.dll';
             break;
     }
     $transaction_response = $this->sendTransactionToGateway($gateway_url, $post_string);
     if (!empty($transaction_response)) {
         $regs = preg_split("/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/", $transaction_response);
         foreach ($regs as $key => $value) {
             $regs[$key] = substr($value, 1, -1);
             // remove double quotes
         }
     } else {
         $regs = array('-1', '-1', '-1');
     }
     $error = false;
     if ($regs[0] == '1') {
         if (!osc_empty(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH)) {
             if (strtoupper($regs[37]) != strtoupper(md5(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH . MODULE_PAYMENT_AUTHORIZENET_CC_AIM_API_LOGIN_ID . $regs[6] . $osC_Currencies->formatRaw($osC_ShoppingCart->getTotal())))) {
                 $error = 'general';
             }
         }
     } else {
         switch ($regs[2]) {
             case '7':
                 $error = 'invalid_expiration_date';
                 break;
             case '8':
                 $error = 'expired';
                 break;
             case '6':
             case '17':
             case '28':
                 $error = 'declined';
                 break;
             case '78':
                 $error = 'cvc';
                 break;
             default:
                 $error = 'general';
                 break;
         }
     }
     if ($error != false) {
         osC_Order::remove($orders_id);
         osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&error=' . $error, 'SSL'));
     } else {
         osC_Order::process($orders_id, $this->_order_status, $transaction_response);
     }
 }
Exemple #15
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;
 }