Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

making code changes after successful placement of order


upuaut

Recommended Posts

I have posted this question some 5 times in hopes of getting simple pointers, but no one responded. Can some kind soul help?

 

I need to know where in osc's code is it that i have to look to make changes. I need to execute an external command AFTER an order has been successfully created (i.e. CC authorization was successful)

 

Where in the code should I look? I tried to figure it out on my own.. could not.

 

which php file(s) should look into?

 

thanking anyone who can help in advance.

Link to comment
Share on other sites

The only two files that would directly effect the outcome of an order as you describe are:

 

catalog/checkout_process.php (for orders_id finalization)

 

and

 

catalog/includes/modules/payment/cc.php (for local credit card verification)

 

 

IN checkout_process.php the code directly effecting the orders_id outcome is something like:

 

// load the before_process function from the payment modules

$payment_modules->before_process();

 

require(DIR_WS_CLASSES . 'order_total.php');

$order_total_modules = new order_total;

 

$order_totals = $order_total_modules->process();

 

$sql_data_array = array('customers_id' => $customer_id,

'customers_title' => $order->customer['title'],

'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],

'customers_acct' => $order->customer['acct'],

'customers_company' => $order->customer['company'],

'customers_street_address' => $order->customer['street_address'],

'customers_street_address2' => $order->customer['street_address2'], // rmh addr-enhancer

'customers_suburb' => $order->customer['suburb'],

'customers_city' => $order->customer['city'],

'customers_postcode' => $order->customer['postcode'],

'customers_state' => $order->customer['state'],

'customers_country' => $order->customer['country']['title'],

'customers_telephone' => $order->customer['telephone'],

'customers_email_address' => $order->customer['email_address'],

'customers_address_format_id' => $order->customer['format_id'],

'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],

'delivery_company' => $order->delivery['company'],

'delivery_street_address' => $order->delivery['street_address'],

'delivery_street_address2' => $order->delivery['street_address2'], // rmh addr-enhancer

'delivery_suburb' => $order->delivery['suburb'],

'delivery_city' => $order->delivery['city'],

'delivery_postcode' => $order->delivery['postcode'],

'delivery_state' => $order->delivery['state'],

'delivery_country' => $order->delivery['country']['title'],

'delivery_residence_id' => $order->delivery['residence_id'], // res/comm contrib

'delivery_telephone' => $order->delivery['telephone'], // rmh addr-enhancer

'delivery_address_format_id' => $order->delivery['format_id'],

'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],

'billing_acct' => $order->billing['acct'],

'billing_company' => $order->billing['company'],

'billing_street_address' => $order->billing['street_address'],

'billing_street_address2' => $order->billing['street_address2'], // rmh addr-enhancer

'billing_suburb' => $order->billing['suburb'],

'billing_city' => $order->billing['city'],

'billing_postcode' => $order->billing['postcode'],

'billing_state' => $order->billing['state'],

'billing_country' => $order->billing['country']['title'],

'billing_telephone' => $order->billing['telephone'], // rmh addr-enhancer

'billing_address_format_id' => $order->billing['format_id'],

'payment_method' => $order->info['payment_method'],

'payment_info' => $GLOBALS['payment_info'],

'cc_type' => $order->info['cc_type'],

'cc_owner' => $order->info['cc_owner'],

'cc_number' => $order->info['cc_number'],

'cc_expires' => $order->info['cc_expires'],

'cc_start' => $order->info['cc_start'],

'cc_cvv' => $order->info['cc_cvv'],

'cc_issue' => $order->info['cc_issue'],

'card_type_id' => $order->info['card_type_id'],

'surcharge' => $order->info['surcharge'],

'date_purchased' => 'now()',

'orders_status' => $order->info['order_status'],

// purchaseorders_1_5 start

'purchase_order_number' => $order->info['purchase_order_number'],

'po_requested_by' => $order->info['po_requested_by'],

'po_contact_person' => $order->info['po_contact_person'],

// purchaseorders_1_5 end

'currency' => $order->info['currency'],

'currency_value' => $order->info['currency_value'],

'ip' => $ip,

'ipisp' => $isp);

 

 

tep_db_perform(TABLE_ORDERS, $sql_data_array);

 

$insert_id = tep_db_insert_id();

 

THE LINE ABOVE IS THE BIGGY ... it inserts the order into the database

 

 

AS FOR MODULES LIKE cc.php:

 

function pre_confirmation_check() {

global $_POST;

 

include(DIR_WS_CLASSES . 'cc_validation.php');

 

$cc_validation = new cc_validation();

$result = $cc_validation->validate($_POST['cc_number'], $_POST['cc_expires_month'], $_POST['cc_expires_year'], $_POST['cc_start_month'], $_POST['cc_start_year'], $_POST['cc_cvv'], $_POST['cc_issue']);

 

$error = '';

switch ($result) {

case -1:

$error = sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4));

break;

case -2:

case -3:

case -4:

$error = TEXT_CCVAL_ERROR_INVALID_DATE;

break;

//case -5:

//$error = sprintf(TEXT_CCVAL_ERROR_NOT_ACCEPTED, substr($cc_validation->cc_type, 0, 10));

//break;

// I had to hard code case -5 . For some reason it would not work using the language define as above

case -5:

$error = 'The Credit Card number you have entered appears to be ' . $cc_validation->cc_type . '. Unfortunately at this time we do not accept ' . $cc_validation->cc_type . ' as payment. Please try another.';

break;

case -6:

$error = TEXT_CCVAL_ERROR_SHORT;

break;

case -7:

$error = TEXT_CCVAL_ERROR_BLACKLIST;

break;

case -10:

$error = TEXT_CCVAL_ERROR_INVALID_START_DATE;

break;

case -11:

$error = TEXT_CCVAL_ERROR_CC_ISSUE;

break;

case -12:

$error = TEXT_CCVAL_ERROR_CVV;

break;

case false:

$error = TEXT_CCVAL_ERROR_INVALID_NUMBER;

break;

}

 

if (($result == false) || ($result < 1)) {

$payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&cc_owner=' . urlencode($_POST['cc_owner']) . '&cc_expires_month=' . $_POST['cc_expires_month'] . '&cc_expires_year=' . $_POST['cc_expires_year'] . '&cc_start_month=' . $_POST['cc_start_month'] . '&cc_start_year=' . $_POST['cc_start_year'];

 

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false));

}

 

THIS EXAMPLE DOES THE LOCAL VERIFICATION. As you can see it calls cc_validation.php and checks for any errors before allowing the number to register to the database. If anything is wrong it redirects back to Checkout Payment.

 

NOTE: This cc card processing has nothing to do with a payment processor. This code is all local. Your example you stated (i.e. CC authorization was successful) does not necessarily mean that the card number is ok.

 

Once whatever Payment Module your using POSTS the ie. cc card data ... it will be the Payment Processor (ie. Verisign or whoever) who actually does does the credit check and authorizes the card is valid and passes the debit transaction to ... You Guessed It !!! ... another Whoever (ie. Visa or MasterCard etc.) who hold the rights to the customers data and once again verifies and does the actual ...... Well you get the idea ! LOL

 

Anyway if the External Command you speak of has to do in anyway with accepting payment or otherwise ... Be Wary! Don't use any commands that are going to set for example an orders status to Delivered or Complete .. because you may end up shipping merchandise etc that you may not have been rightfully paid for.

 

There are so many possibilities I could go on forever .. but I think I have explained some of the possibilities.

 

Well Good Luck with your project. and remember it is only those two areas that actually do any local database finalization. A Payment Module for specific payment types .. and checkout_process for the final $insert_id

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...