Page 1 of 1

Retrieve Credit Card Processing Results

Posted: Wed Feb 14, 2018 7:28 am
by MarcPinnell
I have a need for a client to send a custom email that includes among other things the results of the credit card authorization from authorize.net. I located where OC 3.02 is putting the info: oc_order_history table, "comment" field. However, when I try to pull that info in real time, I get a blank field back (order_cc_info). If I manually run the same query it returns the expected value. Any ideas?

From line 119 of order.php:

Code: Select all

$order_query = $this->db->query("SELECT *, (SELECT oh.comment FROM `oc_order_history` oh WHERE oh.order_id = '" . (int)$order_id . "' LIMIT 1) AS order_cc_info, (SELECT os.name FROM `" . DB_PREFIX . "order_status` os WHERE os.order_status_id = o.order_status_id AND os.language_id = o.language_id) AS order_status FROM `" . DB_PREFIX . "order` o WHERE o.order_id = '" . (int)$order_id . "'");
If I do the obvious substituions and run it in phpmyadmin it works as expected:

Code: Select all

SELECT *, (SELECT oh.comment FROM `oc_order_history` oh WHERE oh.order_id = '109' LIMIT 1) AS order_cc_info, (SELECT os.name FROM `oc_order_status` os WHERE os.order_status_id = o.order_status_id AND os.language_id = o.language_id) AS order_status FROM `oc_order` o WHERE o.order_id = '109'

Re: Retrieve Credit Card Processing Results

Posted: Wed Feb 14, 2018 7:55 am
by straightlight
order_cc_info does not exist as part of the core. You are trying to refer to an extension.

Re: Retrieve Credit Card Processing Results

Posted: Wed Feb 14, 2018 9:01 am
by MarcPinnell
You lost me. I am adding a field to the query result with order_cc_info in the SQL.
straightlight wrote:
Wed Feb 14, 2018 7:55 am
order_cc_info does not exist as part of the core. You are trying to refer to an extension.

Re: Retrieve Credit Card Processing Results

Posted: Wed Feb 14, 2018 11:33 pm
by MarcPinnell
In an effort to simplify, I added the below code to the controller/mail/order.php file:

Code: Select all

$sql = "SELECT * FROM `oc_order_history` WHERE order_id = '" . (int)$order_info['order_id'] . "' LIMIT 1";
//$sql = "SELECT * FROM `oc_order_history` WHERE order_id = '99' LIMIT 1";

$history_query = $this->db->query($sql);
if ($history_query->num_rows) {
	$order_transinfo = $history_query->row['comment'];
} else {
	$order_transinfo = 'x';
}
With this code $order_transinfo ALWAYS outputs "x". If I uncomment (swap) the $sql statements, then $order_transinfo is properly populated with the credit card transaction info (although it is from the wrong order - 99 - obviously). Is it possible the data isn't there yet? Do the credit card verifications happen asynchronously or something and therefore the data isn't there yet? Is there something wrong with my initial SQL? I've tried outputting the $sql var and cutting and pasting the output to phpmyadmin and it runs as expected and without error.