function process_button() { global $order, $currencies, $currency; $my_currency = MODULE_PAYMENT_PAYPAL_CURRENCY; if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD'))) { $my_currency = 'USD'; } $currencyObject = new currencies(); $process_button_string = tep_draw_hidden_field('cmd', '_xclick') . tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) . tep_draw_hidden_field('item_name', STORE_NAME) . tep_draw_hidden_field('rm', '2') . tep_draw_hidden_field('no_shipping', '1') . tep_draw_hidden_field('PHPSESSID', session_id()) . tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencyObject->get_value($my_currency), $currencyObject->get_decimal_places($my_currency))) . tep_draw_hidden_field('currency_code', $my_currency) . tep_draw_hidden_field('return', tep_href_link("checkout_process.php?sess_id=" . session_id(), '', 'SSL')) . tep_draw_hidden_field('cancel_return', tep_href_link("checkout_payment.php", '', 'SSL')); return $process_button_string; }
function process_button() { global $order, $currencies, $currency; $my_language = MODULE_PAYMENT_MONEYBOOKERS_LANGUAGE; $my_currency = MODULE_PAYMENT_MONEYBOOKERS_CURRENCY; if (!in_array($my_currency, array('EUR', 'USD', 'GBP', 'HKD', 'SGD', 'JPY', 'CAD', 'AUD', 'CHF', 'DKK', 'SEK', 'NOK', 'ILS', 'MYR', 'NZD', 'TWD', 'THB', 'CZK', 'HUF', 'SKK', 'ISK', 'INR'))) { $my_currency = 'USD'; } $currencyObject = new currencies(); $process_button_string = tep_draw_hidden_field('pay_to_email', MODULE_PAYMENT_MONEYBOOKERS_ID) . tep_draw_hidden_field('language', $my_language) . tep_draw_hidden_field('amount', number_format($order->info['total'] * $currencyObject->get_value($my_currency), $currencyObject->get_decimal_places($my_currency))) . tep_draw_hidden_field('currency', $my_currency) . tep_draw_hidden_field('detail1_description', STORE_NAME) . tep_draw_hidden_field('detail1_text', 'Order - ' . date('d. M Y - H:i')) . tep_draw_hidden_field('firstname', $order->billing['firstname']) . tep_draw_hidden_field('lastname', $order->billing['lastname']) . tep_draw_hidden_field('address', $order->billing['street_address']) . tep_draw_hidden_field('postal_code', $order->billing['postcode']) . tep_draw_hidden_field('city', $order->billing['city']) . tep_draw_hidden_field('country', $order->billing['country']['moneybookers']) . tep_draw_hidden_field('pay_from_email', $order->customer['email_address']) . tep_draw_hidden_field('status_url', tep_href_link("checkout_process.php?sess_id=" . session_id(), '', 'SSL')) . tep_draw_hidden_field('cancel_url', tep_href_link("checkout_payment.php", '', 'SSL')); return $process_button_string; }
tep_db_query("update " . TABLE_PRODUCTS_INFO . " set products_status = '" . (int) $product_new_status . "' where products_id = '" . (int) $product_check['products_id'] . "'"); if (tep_db_table_exists($shops['shops_database'], 'temp_' . TABLE_PRODUCTS)) { tep_db_query("update temp_" . TABLE_PRODUCTS . " set products_status = '" . (int) $product_new_status . "' where products_id = '" . (int) $product_check['products_id'] . "'"); } if (tep_db_table_exists($shops['shops_database'], 'temp_' . TABLE_PRODUCTS_INFO)) { tep_db_query("update temp_" . TABLE_PRODUCTS_INFO . " set products_status = '" . (int) $product_new_status . "' where products_id = '" . (int) $product_check['products_id'] . "'"); } } tep_db_select_db(DB_DATABASE); // tep_db_query("update " . TABLE_PRODUCTS_TYPES . " set products_last_modified = now() where products_types_id = '1'"); die('OK'); } } die('FAIL'); } elseif ($HTTP_GET_VARS['action'] == 'get_currency_value') { die($currencies->get_value($HTTP_GET_VARS['currency'])); } elseif ($HTTP_GET_VARS['action'] == 'get_product_price') { $product_info_query = tep_db_query("select if(s.specials_new_products_price>'0', s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on (s.products_id = p.products_id and s.status = '1' and s.specials_new_products_price > 0 and s.language_id = '" . (int) $languages_id . "') where p.products_code = 'bbk" . sprintf('%010d', (int) $HTTP_GET_VARS['code']) . "' and p.products_types_id = '" . (int) $HTTP_GET_VARS['type'] . "'"); $product_info = tep_db_fetch_array($product_info_query); die($product_info['products_price']); } $http_r = preg_replace('/^https?:\\/\\//i', '', str_replace('www.', '', $_SERVER['HTTP_REFERER'])); $http_s = preg_replace('/^https?:\\/\\//i', '', str_replace('www.', '', HTTP_SERVER . DIR_WS_CATALOG)); if ($HTTP_GET_VARS['link'] == 'mail') { $allow_action = true; } elseif (strpos($http_r, $http_s) !== false) { $allow_action = true; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox/1.5') !== false) { $allow_action = true; } else { $allow_action = false;
$customers_state_error = false; } if (strlen($customers_country) < 2) { $error = true; $entry_country_error = true; } else { $entry_country_error = false; } if (strlen($customers_email_address) < 2) { $error = true; $entry_email_address_error = true; } else { $entry_email_address_error = false; } if ($error == false) { $boards_currency_value = $currencies->get_value($boards_currency); $currency_check_query = tep_db_query("select boards_currency, boards_currency_value from " . TABLE_BOARDS . " where boards_id = '" . (int) $boards_id . "'"); $currency_check = tep_db_fetch_array($currency_check_query); if ($currency_check['boards_currency'] == $boards_currency) { $boards_currency_value = $currency_check['boards_currency_value']; } $price = str_replace(',', '.', $boards_price / $boards_currency_value); $sql_data_array = array('customers_name' => $customers_name, 'customers_email_address' => $customers_email_address, 'customers_telephone' => $customers_telephone, 'customers_other_contacts' => $customers_other_contacts, 'customers_country' => $customers_country, 'customers_state' => $customers_state, 'customers_city' => $customers_city, 'boards_name' => $boards_name, 'boards_description' => $boards_description, 'boards_status' => $boards_status, 'boards_price' => $price, 'boards_currency' => $boards_currency, 'boards_currency_value' => $boards_currency_value, 'boards_quantity' => $boards_quantity, 'boards_condition' => $boards_condition, 'last_modified' => 'now()'); tep_db_perform(TABLE_BOARDS, $sql_data_array, 'update', "boards_id = '" . (int) $boards_id . "'"); $prev_image_query = tep_db_query("select boards_image from " . TABLE_BOARDS . " where boards_id = '" . (int) $boards_id . "'"); $prev_image = tep_db_fetch_array($prev_image_query); $prev_images_array = explode("\n", $prev_image['boards_image']); if (!is_array($prev_images_array)) { $prev_images_array = array(); } $boards_images = array();
$billing_suburb = !empty($_POST['update_billing_suburb']) && $_POST['update_billing_suburb'] != $order->billing['suburb'] ? tep_db_prepare_input($_POST['update_billing_suburb']) : $order->billing['suburb']; $billing_city = !empty($_POST['update_customer_city']) && $_POST['update_customer_city'] != $order->billing['city'] ? tep_db_prepare_input($_POST['update_customer_city']) : $order->billing['city']; $billing_state = !empty($_POST['update_customer_state']) && $_POST['update_customer_state'] != $order->billing['state'] ? tep_db_prepare_input($_POST['update_customer_state']) : $order->billing['state']; $billing_postcode = !empty($_POST['update_customer_postcode']) && $_POST['update_customer_postcode'] != $order->billing['postcode'] ? tep_db_prepare_input($_POST['update_customer_postcode']) : $order->billing['postcode']; $billing_country = !empty($_POST['update_customer_country']) && $_POST['update_customer_country'] != $order->billing['country'] ? tep_db_prepare_input($_POST['update_customer_country']) : $order->billing['country']; $delivery_name = !empty($_POST['update_delivery_name']) && $_POST['update_delivery_name'] != $order->delivery['name'] ? tep_db_prepare_input($_POST['update_delivery_name']) : $order->delivery['name']; $delivery_company = !empty($_POST['update_delivery_company']) && $_POST['update_delivery_company'] != $order->delivery['company'] ? tep_db_prepare_input($_POST['update_delivery_company']) : $order->delivery['company']; $delivery_street_address = !empty($_POST['update_delivery_street_address']) && $_POST['update_delivery_street_address'] != $order->delivery['street_address'] ? tep_db_prepare_input($_POST['update_delivery_street_address']) : $order->delivery['street_address']; $delivery_suburb = !empty($_POST['update_delivery_suburb']) && $_POST['update_delivery_suburb'] != $order->delivery['suburb'] ? tep_db_prepare_input($_POST['update_delivery_suburb']) : $order->delivery['suburb']; $delivery_city = !empty($_POST['update_delivery_city']) && $_POST['update_delivery_city'] != $order->delivery['city'] ? tep_db_prepare_input($_POST['update_delivery_city']) : $order->delivery['city']; $delivery_postcode = !empty($_POST['update_delivery_postcode']) && $_POST['update_delivery_postcode'] != $order->delivery['postcode'] ? tep_db_prepare_input($_POST['update_delivery_postcode']) : $order->delivery['postcode']; $delivery_state = !empty($_POST['update_delivery_state']) && $_POST['update_delivery_state'] != $order->delivery['state'] ? tep_db_prepare_input($_POST['update_delivery_state']) : $order->delivery['state']; $delivery_country = !empty($_POST['update_delivery_country']) && $_POST['update_delivery_country'] != $order->delivery['country'] ? tep_db_prepare_input($_POST['update_delivery_country']) : $order->delivery['country']; $update_shipping_method = !empty($_POST['update_shipping_method']) ? tep_db_prepare_input($_POST['update_shipping_method']) : $order->info['shipping_method']; $update_currency = !empty($_POST['update_currency']) ? tep_db_prepare_input($_POST['update_currency']) : $order->info['update_currency']; $update_orders_array = array('customers_name' => $customers_name, 'customers_company' => $customers_company, 'customers_street_address' => $customers_street_address, 'customers_suburb' => $customers_suburb, 'customers_city' => $customers_city, 'customers_postcode' => $customers_postcode, 'customers_state' => $customers_state, 'customers_country' => $customers_country, 'customers_telephone' => $customers_telephone, 'customers_email_address' => $customers_email_address, 'billing_name' => $billing_name, 'billing_company' => $billing_company, 'billing_street_address' => $billing_street_address, 'billing_suburb' => $billing_suburb, 'billing_city' => $billing_city, 'billing_state' => $billing_state, 'billing_postcode' => $billing_postcode, 'billing_country' => $billing_country, 'delivery_name' => $delivery_name, 'delivery_company' => $delivery_company, 'delivery_street_address' => $delivery_street_address, 'delivery_suburb' => $delivery_suburb, 'delivery_city' => $delivery_city, 'delivery_postcode' => $delivery_postcode, 'delivery_state' => $delivery_state, 'delivery_country' => $delivery_country, 'payment_method' => $pay_method, 'cc_type' => $cc_type, 'cc_owner' => $cc_owner, 'cc_number' => $cc_number, 'shipping_method' => $update_shipping_method, 'currency' => $update_currency, 'currency_value' => $currencies->get_value($update_currency), 'last_modified' => date('Y-m-d H:i:s', time()), 'date_purchased' => !empty($check_status['date_purchased']) ? $check_status['date_purchased'] : date('Y-m-d H:i:s', time()), 'orders_source' => $orders_source); if (!$oID) { $oID = tep_db_insert_id(); } tep_db_perform(TABLE_ORDERS, $update_orders_array, 'update', "orders_id = '" . $oID . "'"); // # Send email notifications $customer_notified = 0; if (!empty($cc_cvv2) && !empty($cc_number)) { $process = 1; } else { $process = 0; } if ($check_status['orders_status'] != $status) { $order->setStatus($status, $process); $order_updated = true; $thestatus = sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]) . "\n\n";
/** * Process a <merchant-calculation-callback>. */ function process_merchant_calculation_callback_single($google_response) { global $google_checkout, $order, $cart, $total_weight, $total_count; list($root, $gc_data) = $google_response->GetParsedXML(); $currencies = new currencies(); // Get a hash array with the description of each shipping method $shipping_methods = $google_checkout->getMethods(); require DIR_WS_CLASSES . 'order.php'; $order = new order(); $items = gc_get_arr_result($gc_data[$root]['shopping-cart']['items']['item']); // Get Coustoms OT $custom_order_totals_total = 0; $custom_order_totals = array(); $order->products = array(); foreach ($items as $item) { if (isset($item['merchant-private-item-data']['item']['VALUE'])) { $order->products[] = unserialize(base64_decode($item['merchant-private-item-data']['item']['VALUE'])); } else { if ($item['merchant-private-item-data']['order_total']['VALUE']) { $ot = unserialize(base64_decode($item['merchant-private-item-data']['order_total']['VALUE'])); $custom_order_totals[] = $ot; $order_total_value = $ot['value'] * (strrpos($ot['text'], '-') === false ? 1 : -1); $custom_order_totals_total += $currencies->get_value($gc_data[$root]['order-total']['currency']) * $order_total_value; } else { // For invoices. $order->products[] = array('qty' => $item['quantity']['VALUE'], 'name' => $item['item-name']['VALUE'], 'model' => $item['item-description']['VALUE'], 'tax' => 0, 'tax_description' => @$item['tax-table-selector']['VALUE'], 'price' => $item['unit-price']['VALUE'], 'final_price' => $item['unit-price']['VALUE'], 'onetime_charges' => 0, 'weight' => 0, 'products_priced_by_attribute' => 0, 'product_is_free' => 0, 'products_discount_type' => 0, 'products_discount_type_from' => 0, 'id' => @$item['merchant-item-id']['VALUE']); } } } $ex_cart = $cart; $cart = new shoppingCart(); $prod_attr = gc_get_prattr($order->products); foreach ($prod_attr as $product_id => $item_data) { //$products_id, $qty = '1', $attributes = ' $cart->add_cart($product_id, $item_data['qty'], $item_data['attr']); } // Register a random ID in the session to check throughout the checkout procedure // against alterations in the shopping cart contents. // TODO(eddavisson): Why is this commented out? //if (!tep_session_is_registered('cartID')) { // tep_session_register('cartID'); //} //$cartID = $cart->cartID; $total_weight = $cart->show_weight(); $total_count = $cart->count_contents(); // Create the results and send it $merchant_calc = new GoogleMerchantCalculations(DEFAULT_CURRENCY); // Loop through the list of address ids from the callback. $addresses = gc_get_arr_result($gc_data[$root]['calculate']['addresses']['anonymous-address']); // Get all the enabled shipping methods. require_once DIR_WS_CLASSES . 'shipping.php'; // Required for some shipping methods (ie. USPS). require_once 'includes/classes/http_client.php'; foreach ($addresses as $curr_address) { // Set up the order address. $curr_id = $curr_address['id']; $country = $curr_address['country-code']['VALUE']; $city = $curr_address['city']['VALUE']; $region = $curr_address['region']['VALUE']; $postal_code = $curr_address['postal-code']['VALUE']; $row = tep_db_fetch_array(tep_db_query("select * from " . TABLE_COUNTRIES . " where countries_iso_code_2 = '" . gc_make_sql_string($country) . "'")); $order->delivery['country'] = array('id' => $row['countries_id'], 'title' => $row['countries_name'], 'iso_code_2' => $country, 'iso_code_3' => $row['countries_iso_code_3']); $order->delivery['country_id'] = $row['countries_id']; $order->delivery['format_id'] = $row['address_format_id']; $row = tep_db_fetch_array(tep_db_query("select * from " . TABLE_ZONES . " where zone_code = '" . gc_make_sql_string($region) . "'")); $order->delivery['zone_id'] = $row['zone_id']; $order->delivery['state'] = $row['zone_name']; $order->delivery['city'] = $city; $order->delivery['postcode'] = $postal_code; //print_r($order); $shipping_modules = new shipping(); // Loop through each shipping method if merchant-calculated shipping // support is to be provided //print_r($gc_data[$root]['calculate']['shipping']['method']); if (isset($gc_data[$root]['calculate']['shipping'])) { $shipping = gc_get_arr_result($gc_data[$root]['calculate']['shipping']['method']); // TODO(eddavisson): If we reactivate this, need to move to new configuration system. if (MODULE_PAYMENT_GOOGLECHECKOUT_MULTISOCKET == 'True') { // Single. // Get all the enabled shipping methods. $name = $shipping[0]['name']; // Compute the price for this shipping method and address id list($a, $method_name) = explode(': ', $name); if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'international_types') { // Reset the shipping class to set the new address if (class_exists($shipping_methods[$method_name][2])) { $GLOBALS[$shipping_methods[$method_name][2]] = new $shipping_methods[$method_name][2](); } } $quotes = $shipping_modules->quote('', $shipping_methods[$method_name][2]); } else { // Standard foreach ($shipping as $curr_ship) { $name = $curr_ship['name']; // Compute the price for this shipping method and address id list($a, $method_name) = explode(': ', $name); if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'international_types') { // Reset the shipping class to set the new address. if (class_exists($shipping_methods[$method_name][2])) { $GLOBALS[$shipping_methods[$method_name][2]] = new $shipping_methods[$method_name][2](); } } } $quotes = $shipping_modules->quote(); } reset($shipping); foreach ($shipping as $curr_ship) { $name = $curr_ship['name']; // Compute the price for this shipping method and address id list($a, $method_name) = explode(': ', $name); unset($quote_provider); unset($quote_method); if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'international_types') { foreach ($quotes as $key_provider => $shipping_provider) { // privider name (class) if ($shipping_provider['id'] == $shipping_methods[$method_name][2]) { // method name $quote_provider = $key_provider; if (is_array($shipping_provider['methods'])) { foreach ($shipping_provider['methods'] as $key_method => $shipping_method) { if ($shipping_method['id'] == $shipping_methods[$method_name][0]) { $quote_method = $key_method; break; } } } break; } } } //if there is a problem with the method, i mark it as non-shippable if (isset($quotes[$quote_provider]['error']) || !isset($quotes[$quote_provider]['methods'][$quote_method]['cost'])) { $price = "9999.09"; $shippable = "false"; } else { $price = $quotes[$quote_provider]['methods'][$quote_method]['cost']; $shippable = "true"; } $merchant_result = new GoogleResult($curr_id); $merchant_result->SetShippingDetails($name, $currencies->get_value(DEFAULT_CURRENCY) * $price, $shippable); if ($gc_data[$root]['calculate']['tax']['VALUE'] == "true") { // Compute tax for this address id and shipping type $amount = 15; // Modify this to the actual tax value $merchant_result->SetTaxDetails($currencies->get_value(DEFAULT_CURRENCY) * $amount); } if (isset($gc_data[$root]['calculate']['merchant-code-strings']['merchant-code-string'])) { $codes = gc_get_arr_result($gc_data[$root]['calculate']['merchant-code-strings']['merchant-code-string']); foreach ($codes as $curr_code) { // Update this data as required to set whether the coupon is valid, the code and the amount $coupons = new GoogleCoupons("true", $curr_code['code'], $currencies->get_value(DEFAULT_CURRENCY) * 5, "test2"); $merchant_result->AddCoupons($coupons); } } $merchant_calc->AddResult($merchant_result); } } else { $merchant_result = new GoogleResult($curr_id); if ($gc_data[$root]['calculate']['tax']['VALUE'] == "true") { // Compute tax for this address id and shipping type $amount = 15; // Modify this to the actual tax value $merchant_result->SetTaxDetails($currencies->get_value(DEFAULT_CURRENCY) * $amount); } //calculate_coupons($google_response, $merchant_result); $merchant_calc->AddResult($merchant_result); } } $cart = $ex_cart; $google_response->ProcessMerchantCalculations($merchant_calc); }
$payment_modules = new payment($transaction_data[0][4]); // load the before_process function from the payment modules //$payment_modules->before_process(); $QUERY = "SELECT id, credit, lastname, firstname, address, city, state, country, zipcode, phone, email, fax, currency " . "FROM cc_agent WHERE id = '" . $transaction_data[0][1] . "'"; $resmax = $DBHandle_max->Execute($QUERY); if ($resmax) { $numrow = $resmax->RecordCount(); } else { write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "-transactionID={$transactionID}" . " ERROR NO SUCH CUSTOMER EXISTS, CUSTOMER ID = " . $transaction_data[0][1]); exit(gettext("No Such Customer exists.")); } $customer_info = $resmax->fetchRow(); $nowDate = date("Y-m-d H:i:s"); $pmodule = $transaction_data[0][4]; $orderStatus = $payment_modules->get_OrderStatus(); $Query = "INSERT INTO cc_payments_agent ( agent_id, agent_name, agent_email_address, item_name, item_id, item_quantity, payment_method, cc_type, cc_owner, cc_number, " . " cc_expires, orders_status, last_modified, date_purchased, orders_date_finished, orders_amount, currency, currency_value) values (" . " '" . $transaction_data[0][1] . "', '" . $customer_info[3] . " " . $customer_info[2] . "', '" . $customer_info["email"] . "', 'balance', '" . $customer_info[0] . "', 1, '{$pmodule}', '" . $_SESSION["p_cardtype"] . "', '" . $transaction_data[0][5] . "', '" . $transaction_data[0][6] . "', '" . $transaction_data[0][7] . "', {$orderStatus}, '" . $nowDate . "', '" . $nowDate . "', '" . $nowDate . "', " . $amount_paid . ", '" . $currCurrency . "', '" . $currencyObject->get_value($currCurrency) . "' )"; $result = $DBHandle_max->Execute($Query); //************************UPDATE THE CREDIT IN THE CARD*********************** $id = $customer_info[0]; if ($id > 0) { $addcredit = $transaction_data[0][2]; $instance_table = new Table("cc_agent", ""); $param_update .= " credit = credit + '" . $amount_without_vat . "'"; $FG_EDITION_CLAUSE = " id='{$id}'"; $instance_table->Update_table($DBHandle, $param_update, $FG_EDITION_CLAUSE, $func_table = null); write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "-transactionID={$transactionID}" . " Update_table cc_card : {$param_update} - CLAUSE : {$FG_EDITION_CLAUSE}"); $field_insert = "date, credit, agent_id, description"; $value_insert = "'{$nowDate}', '" . $amount_without_vat . "', '{$id}', '" . $transaction_data[0][4] . "'"; $instance_sub_table = new Table("cc_logrefill_agent", $field_insert); $id_logrefill = $instance_sub_table->Add_table($DBHandle, $value_insert, null, null, 'id'); write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "-transactionID={$transactionID}" . " Add_table cc_logrefill : {$field_insert} - VALUES {$value_insert}");
if (tep_not_null($author_name)) { $product_name .= ' by ' . $author_name; } $buyer_phone_number = ''; $quantity_purchased = 1; $curr = 'USD'; $item_tax = 0; $shipping_tax = 0; $shipping_price = $total_price - $item_price; $ship_phone_number = ''; } else { list($order_code, $order_item_id, $purchase_date, $payments_date, $buyer_email, $buyer_name, $buyer_phone_number, $sku, $product_name, $quantity_purchased, $curr, $item_price, $item_tax, $shipping_price, $shipping_tax, $ship_service_level, $recipient_name, $ship_address_1, $ship_address_2, $ship_address_3, $ship_city, $ship_state, $ship_postal_code, $ship_country, $ship_phone_number) = $cell; } // if ((int)$sku > 0) { echo 'order_code - ' . $order_code . '; order_item_id = ' . $order_item_id . '; purchase_date = ' . $purchase_date . '; payments_date = ' . $payments_date . '; buyer_email = ' . $buyer_email . '; buyer_name = ' . $buyer_name . '; buyer_phone_number = ' . $buyer_phone_number . '; sku = ' . $sku . '; product_name = ' . $product_name . '; quantity_purchased = ' . $quantity_purchased . '; curr = ' . $curr . '; item_price = ' . $item_price . '; item_tax = ' . $item_tax . '; shipping_price = ' . $shipping_price . '; shipping_tax = ' . $shipping_tax . '; ship_service_level = ' . $ship_service_level . '; recipient_name = ' . $recipient_name . '; ship_address_1 = ' . $ship_address_1 . '; ship_address_2 = ' . $ship_address_2 . '; ship_address_3 = ' . $ship_address_3 . '; ship_city= ' . $ship_city . '; ship_date = ' . $ship_state . '; ship_postal_code = ' . $ship_postal_code . '; ship_country = ' . $ship_country . '; ship_phone_number = ' . $ship_phone_number . '<br>'; die; } if ((int) $sku > 0 && in_array($order_code, $orders_to_upload)) { $currency_value = $currencies->get_value($curr); if ($order_code != $order_old_code) { if (tep_not_null($order_old_code)) { $global_queries = array_merge($global_queries, $sql_queries); } $ship_address = trim($ship_address_1 . ' ' . $ship_address_2 . ' ' . $ship_address_3); if (strpos($purchase_date, '+') !== false) { $purchase_date = str_replace('T', ' ', substr($purchase_date, 0, strrpos($purchase_date, '+'))); } elseif (strpos($purchase_date, 'T') !== false) { $purchase_date = str_replace('T', ' ', substr($purchase_date, 0, strrpos($purchase_date, '-'))); } $sql_data_array = array('orders_code' => $order_code, 'customers_id' => 0, 'customers_name' => $buyer_name, 'customers_street_address' => $ship_address, 'customers_suburb' => '', 'customers_city' => $ship_city, 'customers_postcode' => $ship_postal_code, 'customers_state' => $ship_state, 'customers_country' => $ship_country, 'customers_telephone' => $buyer_phone_number, 'customers_email_address' => $buyer_email, 'customers_address_format_id' => 5, 'delivery_name' => $recipient_name, 'delivery_company' => '', 'delivery_street_address' => $ship_address, 'delivery_suburb' => '', 'delivery_city' => $ship_city, 'delivery_postcode' => $ship_postal_code, 'delivery_state' => $ship_state, 'delivery_country' => $ship_country, 'delivery_telephone' => $ship_phone_number, 'delivery_address_format_id' => 5, 'billing_name' => $buyer_name, 'billing_company' => '', 'billing_street_address' => $ship_address, 'billing_suburb' => '', 'billing_city' => $ship_city, 'billing_postcode' => $ship_postal_code, 'billing_state' => $ship_state, 'billing_country' => $ship_country, 'billing_telephone' => $buyer_phone_number, 'billing_address_format_id' => 5, 'payment_method' => 'Bank card', 'date_purchased' => $purchase_date, 'orders_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $curr, 'currency_value' => $currency_value, 'delivery_transfer' => '', 'orders_ssl_enabled' => 1, 'shops_id' => $upload_to_shop); // echo '<pre>' . print_r($sql_data_array, true); die; tep_db_perform(TABLE_ORDERS, $sql_data_array); $insert_id = tep_db_insert_id(); $uploaded_orders[] = $insert_id;
write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-transactionID=$transactionID"." ERROR NO SUCH CUSTOMER EXISTS, CUSTOMER ID = ".$transaction_data[0][1]); exit(gettext("No Such Customer exists.")); } $customer_info = $resmax -> fetchRow(); $nowDate = date("Y-m-d H:i:s"); $pmodule = $transaction_data[0][4]; $orderStatus = $payment_modules->get_OrderStatus(); $Query = "Insert into cc_payments_agent ( agent_id, agent_name, agent_email_address, item_name, item_id, item_quantity, payment_method, cc_type, cc_owner, cc_number, " . " cc_expires, orders_status, last_modified, date_purchased, orders_date_finished, orders_amount, currency, currency_value) values (" . " '".$transaction_data[0][1]."', '".$customer_info[3]." ".$customer_info[2]."', '".$customer_info["email"]."', 'balance', '". $customer_info[0]."', 1, '$pmodule', '".$_SESSION["p_cardtype"]."', '".$transaction_data[0][5]."', '".$transaction_data[0][6]."', '". $transaction_data[0][7]."', $orderStatus, '".$nowDate."', '".$nowDate."', '".$nowDate."', ".$amount_paid.", '".$currCurrency."', '". $currencyObject->get_value($currCurrency)."' )"; $result = $DBHandle_max -> Execute($Query); //************************UPDATE THE CREDIT IN THE CARD*********************** $id = $customer_info[0]; if ($id > 0 ) { $addcredit = $transaction_data[0][2]; $instance_table = new Table("cc_agent", ""); $param_update .= " credit = credit+'".$amount_without_vat."'"; $FG_EDITION_CLAUSE = " id='$id'"; $instance_table -> Update_table ($DBHandle, $param_update, $FG_EDITION_CLAUSE, $func_table = null); write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-transactionID=$transactionID"." Update_table cc_card : $param_update - CLAUSE : $FG_EDITION_CLAUSE"); $field_insert = "date, credit, agent_id, description";
function process_merchant_calculation_callback_single($Gresponse) { global $googlepayment, $order, $db, $total_weight, $total_count; list($root, $data) = $Gresponse->GetParsedXML(); $currencies = new currencies(); $cart = $_SESSION['cart']; $methods_hash = $googlepayment->getMethods(); require DIR_WS_CLASSES . 'order.php'; $order = new order(); // Register a random ID in the session to check throughout the checkout procedure // against alterations in the shopping cart contents. // if (!tep_session_is_registered('cartID')) { // tep_session_register('cartID'); // } // $cartID = $cart->cartID; $items = get_arr_result($data[$root]['shopping-cart']['items']['item']); $products = array(); foreach ($items as $item) { if (isset($item['merchant-private-item-data']['item']['VALUE'])) { $products[] = unserialize(base64_decode($item['merchant-private-item-data']['item']['VALUE'])); } } $order->products = $products; $total_weight = $cart->show_weight(); $total_count = $cart->count_contents(); // Create the results and send it $merchant_calc = new GoogleMerchantCalculations(DEFAULT_CURRENCY); // Loop through the list of address ids from the callback. $addresses = get_arr_result($data[$root]['calculate']['addresses']['anonymous-address']); // Get all the enabled shipping methods. require DIR_WS_CLASSES . 'shipping.php'; // Required for some shipping methods (ie. USPS). require_once 'includes/classes/http_client.php'; foreach ($addresses as $curr_address) { // Set up the order address. $curr_id = $curr_address['id']; $country = $curr_address['country-code']['VALUE']; $city = $curr_address['city']['VALUE']; $region = $curr_address['region']['VALUE']; $postal_code = $curr_address['postal-code']['VALUE']; $countr_query = $db->Execute("select * \n from " . TABLE_COUNTRIES . " \n where countries_iso_code_2 = '" . makeSqlString($country) . "'"); $row = $countr_query->fields; $order->delivery['country'] = array('id' => $row['countries_id'], 'title' => $row['countries_name'], 'iso_code_2' => $country, 'iso_code_3' => $row['countries_iso_code_3']); $order->delivery['country_id'] = $row['countries_id']; $order->delivery['format_id'] = $row['address_format_id']; $zone_query = $db->Execute("select * \n \t\t from " . TABLE_ZONES . "\n \t\t where zone_code = '" . makeSqlString($region) . "'"); $row = $zone_query->fields; $order->delivery['zone_id'] = $row['zone_id']; $order->delivery['state'] = $row['zone_name']; $order->delivery['city'] = $city; $order->delivery['postcode'] = $postal_code; $shipping_modules = new shipping(); // Loop through each shipping method if merchant-calculated shipping // support is to be provided //print_r($data[$root]['calculate']['shipping']['method']); if (isset($data[$root]['calculate']['shipping']['method'])) { $shipping = get_arr_result($data[$root]['calculate']['shipping']['method']); // if (MODULE_PAYMENT_GOOGLECHECKOUT_MULTISOCKET == 'True') { // // Single // // i get all the enabled shipping methods // $name = $shipping[0]['name']; // // Compute the price for this shipping method and address id // list ($a, $method_name) = explode(': ', $name); // if ((($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) // && ($methods_hash[$method_name][1] == 'domestic_types')) // || (($order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY) // && ($methods_hash[$method_name][1] == 'international_types'))) { // // reset the shipping class to set the new address // if (class_exists($methods_hash[$method_name][2])) { // $GLOBALS[$methods_hash[$method_name][2]] = new $methods_hash[$method_name][2]; // } // } // $quotes = $shipping_modules->quote('', $methods_hash[$method_name][2]); // } else { // Standard foreach ($shipping as $curr_ship) { $name = $curr_ship['name']; // Compute the price for this shipping method and address id list($a, $method_name) = explode(': ', $name, 2); if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $methods_hash[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $methods_hash[$method_name][1] == 'international_types') { // reset the shipping class to set the new address if (class_exists($methods_hash[$method_name][2])) { $GLOBALS[$methods_hash[$method_name][2]] = new $methods_hash[$method_name][2](); } } } $quotes = $shipping_modules->quote(); // } reset($shipping); foreach ($shipping as $curr_ship) { $name = $curr_ship['name']; // Compute the price for this shipping method and address id list($a, $method_name) = explode(': ', $name, 2); unset($quote_povider); unset($quote_method); if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $methods_hash[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $methods_hash[$method_name][1] == 'international_types') { foreach ($quotes as $key_provider => $shipping_provider) { // privider name (class) if ($shipping_provider['id'] == $methods_hash[$method_name][2]) { // method name $quote_povider = $key_provider; if (is_array($shipping_provider['methods'])) { foreach ($shipping_provider['methods'] as $key_method => $shipping_method) { if ($shipping_method['id'] == $methods_hash[$method_name][0]) { $quote_method = $key_method; break; } } } break; } } } //if there is a problem with the method, i mark it as non-shippable if (isset($quotes[$quote_povider]['error']) || !isset($quotes[$quote_povider]['methods'][$quote_method]['cost'])) { $price = "9999.09"; $shippable = "false"; } else { $price = $quotes[$quote_povider]['methods'][$quote_method]['cost']; $shippable = "true"; } // fix for item shipping function bug if called more than once in a session. $price = $price >= 0 ? $price : 0; $merchant_result = new GoogleResult($curr_id); $merchant_result->SetShippingDetails($name, $currencies->get_value(DEFAULT_CURRENCY) * $price, $shippable); if ($data[$root]['calculate']['tax']['VALUE'] == "true") { //Compute tax for this address id and shipping type $amount = 15; // Modify this to the actual tax value $merchant_result->SetTaxDetails($currencies->get_value(DEFAULT_CURRENCY) * $amount); } //// start cupons and gift processing (working) // // only one coupon per order is valid! // $_POST['dc_redeem_code'] = 'ROPU'; // //// require(DIR_WS_CLASSES . 'order.php'); //// $order = new order; // require_once(DIR_WS_CLASSES . 'order_total.php'); // $order_total_modules = new order_total; //// $order_total_modules->collect_posts(); //// $order_total_modules->pre_confirmation_check(); // //// print_r($order_total_modules); // $order_totals = $order_total_modules->process(); //// print_r($order_totals); // calculate_coupons($Gresponse, $merchant_result, $price); // end cupons $merchant_calc->AddResult($merchant_result); } } else { $merchant_result = new GoogleResult($curr_id); if ($data[$root]['calculate']['tax']['VALUE'] == "true") { //Compute tax for this address id and shipping type $amount = 15; // Modify this to the actual tax value $merchant_result->SetTaxDetails($currencies->get_value(DEFAULT_CURRENCY) * $amount); } calculate_coupons($Gresponse, $merchant_result); $merchant_calc->AddResult($merchant_result); } } $Gresponse->ProcessMerchantCalculations($merchant_calc); }
$tansaction_ID = null; $QUERY = "SELECT username, credit, lastname, firstname, address, city, state, country, zipcode, phone, email, fax, lastuse, activated, currency FROM cc_card WHERE id = '" . $transaction_data[0][1] . "'"; $numrow = 0; $resmax = $DBHandle_max->Execute($QUERY); if ($resmax) { $numrow = $resmax->RecordCount(); } if ($numrow == 0) { write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "-transactionID={$transactionID}" . " ERROR NO SUCH CUSTOMER EXISTS, CUSTOMER ID = " . $transaction_data[0][1]); exit(gettext("No Such Customer exists.")); } $customer_info = $resmax->fetchRow(); $nowDate = date("Y-m-d H:i:s"); $pmodule = $transaction_data[0][4]; $orderStatus = $payment_modules->get_OrderStatus(); $Query = "Insert into cc_payments ( customers_id,\n customers_name,\n customers_email_address,\n item_name,\n item_id,\n item_quantity,\n payment_method,\n cc_type,\n cc_owner,\n cc_number,\n cc_expires,\n orders_status,\n last_modified,\n date_purchased,\n orders_date_finished,\n orders_amount,\n currency,\n currency_value)\n values\n (\n '" . $transaction_data[0][1] . "',\n '" . $customer_info[3] . " " . $customer_info[2] . "',\n '" . $customer_info["email"] . "',\n 'balance',\n '" . $customer_info[0] . "',\n 1,\n '{$pmodule}',\n '" . $_SESSION["p_cardtype"] . "',\n '" . $transaction_data[0][5] . "',\n '" . $transaction_data[0][6] . "',\n '" . $transaction_data[0][7] . "',\n {$orderStatus},\n '" . $nowDate . "',\n '" . $nowDate . "',\n '" . $nowDate . "',\n " . $amount_paid . ",\n '" . $currCurrency . "',\n '" . $currencyObject->get_value($currCurrency) . "'\n )"; $result = $DBHandle_max->Execute($Query); //************************UPDATE THE CREDIT IN THE CARD*********************** $id = 0; if ($customer_info[0] > 0 && $orderStatus == 2) { /* CHECK IF THE CARDNUMBER IS ON THE DATABASE */ $instance_table_card = new Table("cc_card", "username, id"); $FG_TABLE_CLAUSE_card = "username='******'"; $list_tariff_card = $instance_table_card->Get_list($DBHandle, $FG_TABLE_CLAUSE_card, null, null, null, null, null, null); //print_r($list_tariff_card); if ($customer_info[0] == $list_tariff_card[0][0]) { $id = $list_tariff_card[0][1]; } write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "-transactionID={$transactionID}" . " CARD FOUND IN DB ({$id})"); } if ($id > 0) {
$ot_shipping = $v['value']; break; default: if (substr($v['text'], 0, 1) === '-') { $discount += (double) $v['value']; } break; } $orders_totals .= '<tr> <td align="right" class="ot-subtotal-Text">' . $v['title'] . '</td> <td align="right" class="ot-subtotal-Amount">' . $currencies->format($v['value'], true, $order->info['currency']) . '</td> </tr>'; } $orders_totals .= '</tbody></table>'; $shipping_cost = $ot_shipping; $var['amount'] = number_format($order->info['total'] * $currencies->get_value($var['currency']), 2, '.', ''); // 商品价格 $var['shippingfee'] = number_format($shipping_cost * $currencies->get_value($var['currency']), 2, '.', ''); // 运费 $var['vat'] = number_format(($ot_total + $discount - $ot_subtotal - $ot_shipping) * $currencies->get_value($var['currency']), 2, '.', ''); // 附加费用 $var['discount'] = number_format($discount * $currencies->get_value($var['currency']), 2, '.', ''); // 打折 $var['total_output'] = base64_encode($orders_totals); // 商品名称、商品描述、商户数据包 foreach ($order->products as $k => $products) { $var["product_name[{$k}]"] = ' '; //$products['name']; if (is_array($products['attributes'])) { foreach ($products['attributes'] as $attribute) { $var["product_name[{$k}]"] .= "\n {$attribute['option']}:{$attribute['value']}";