Welcome, Guest. Please login or register.
Login with username, password and session length


VirtueMart 1.1.8 - [SECURITY RELEASE] is available! Read more....

  Advanced search

247038 Posts in 67506 Topics- by 258314 Members - Latest Member: aniketana
Pages: [1]   Go Down
Print
Author Topic: Email notification fields  (Read 9029 times)
sapplega
Newbie
*
Posts: 2


« on: November 05, 2007, 12:51:32 PM »

When I get an email notification from Authorize.net it lists a 20 character PO Number that was appearantly created by VirtueMart.  When I try to match this email notification to a specific order in VirtueMart, the PO Number is completely different.  Its an 8 character number something like "00000012".

Is there any way to modify the PO Number that gets sent to Authorize.net so that it's the same one that gets recorded in VirtueMart?  I'm most interested in having the same PO Number show up in the Authorize.net email notification and the VirtueMart email notifications  This way the person who is entering purchases into our accounting software knows which VirtueMart purchases were authorized by Authorize.net.  Without the same PO Number being recorded in both places, I can't figure out a way to tie the authorization to the items purchased.  Thanks!
« Last Edit: November 06, 2007, 07:30:02 AM by sapplega » Logged
Joe Sauve
Newbie
*
Posts: 16


« Reply #1 on: November 08, 2007, 19:22:24 PM »

Is this invoice number like 20 characters long, consisting of apparently random numbers and lower-case letters?  Is so, this is more than likely the Authorize.net invoice number.  I would be willing to bet that the email you're getting the number from has the subject line "Merchant Email Receipt".  Am I correct?

If you're nodding your head, then the 20 character number is indeed FROM Authorize.net.  This number is not sent to Authorize.net by Virtuemart, it is generated as a unique transaction identifier BY Authorize.net.  At least, thats my understanding.  Someone please correct me if I'm wrong.

If you enter any transactions by hand using the Authorize.net virtual terminal, you don't see these 20 character numbers.  This is the only evidence that MAYBE Virtuemart generates the numbers, but I don't think so.
Logged
sapplega
Newbie
*
Posts: 2


« Reply #2 on: November 09, 2007, 09:16:31 AM »

Joe, thank you very much for responding to my question.  The 20 digit number that shows up on my "Merchant Email Receipt" is indeed mixed numbers and lower case letters.  It is referred to twice in this email.  Once as "PO Number" and once as "Invoice".  According to Authorize.net tech support, they do not generate this number.  They say it was sent to them by VirtueMart.  The Authorize.net number is 10 digits long and is referred to in the email as "Transaction ID".  I've included Authorize.net's response to this problem below:

"Greetings from Authorize.Net!
The invoice numbers are not generated by Authorize.net. Authorize.net does create a Transaction ID number which is a 10 digit number. The Transaction ID number should be visible in the e-mail receipt you are receiving from us.
If the Invoice number you're seeing within VirtueMart is different than the Invoice number visible within your Authorize.net account and e-mail receipts, that means that VirtueMart is creating a separate invoice which they are submitting to us."

Logged
Joe Sauve
Newbie
*
Posts: 16


« Reply #3 on: November 09, 2007, 09:57:06 AM »

Weird!  Well, in that case it would indeed be handy to have VM send the VM invoice number instead of the random one.

To implement this, the code would need to retrieve the last order number from the VM database, increment it by one, then pass it to Authorize.net in the card transaction.  If successful, then VM would generate a new sales order/invoice and the numbers would match. Otherwise, it would discard the incremented number until the next transaction attempt.

In the ps_authorize.php file, there's a function for submitting the transaction:

Code:
function process_payment($order_number, $order_total, &$d) {...}

Notice the $order_number parameter.  Now we have to figure out how it is generated.

Also in the body of the afore-mentioned function is this:

Code:
// Invoice Information
'x_invoice_num' => substr([b]$order_number[/b], 0, 20),
'x_description' => $VM_LANG->_PHPSHOP_ORDER_PRINT_PO_LBL,

and this...


Code:
// Level 2 data
'x_po_num' => substr($order_number, 0, 20),
'x_tax' => substr($d['order_tax'], 0, 15),
'x_tax_exempt' => "FALSE",
'x_freight' => $d['order_shipping'],
'x_duty' => 0

So, you can see why this number is being used for the invoice and po numbers in Authorize.net: it is being sub-stringed from the same variable, $order_number.

Since the first time $order_number appears in this file is as a parameter for the afore-mentioned process_payment() function, it must originate from some other file.

I personally don't have time to dedicate to this right now, but this should point you in the right direction.  If you don't write code, you may want to hire a PHP programmer, of perhaps there's someone else on the forum that has time to tackle it. Good Luck!
Logged
purestudio
Newbie
*
Posts: 5


« Reply #4 on: July 09, 2008, 13:48:04 PM »

OK, I think I've made progress on this for anyone who's still struggling with this.  It seems that VM is indeed creating a random order number based on session variable.  From ps_authorize.php (mentioned above) you can see that VM is sending a substring of a variable called $order_number.  By globally searching for this variable, I see it's created in classes/ps_checkout.php (line 696 for me) by calling a function get_order_number():

Code:
/* Set the order number */
$order_number = $this->get_order_number();

By searching for that function name in the same file, I find it (on line 1081 for me):

Code:
function get_order_number() {
global $sess;

/* Generated a unique order number */

$str = session_id();
$str .= session_name();
$str .= (string)time();

$order_number = md5($str);

return($order_number);
}

It seems that the only necessary change should be changing
Code:
$order_number = $this->get_order_number();
to something like this:
Code:
$order_number = mosgetparam( $_REQUEST, 'order_id', 0);

This always returns a value of 0 in Authorize.net.  So I'm getting somewhere with it, but am not enough of a programmer to figure out why this database call is not functioning correctly on this page (I grabbed the mosgetparam( $_REQUEST, 'order_id', 0); code from another page.)

Anyone want to take it from here?
Logged
brickford5
Newbie
*
Posts: 28


« Reply #5 on: October 24, 2008, 14:25:28 PM »

This is the exact same spot I am stuck on. Has anyone had any success with this?
Logged
brickford5
Newbie
*
Posts: 28


« Reply #6 on: October 27, 2008, 21:07:19 PM »

Anyone?
Logged
ranbou
Newbie
*
Posts: 4


« Reply #7 on: March 04, 2009, 21:17:05 PM »

I don't have time to look into this but I thought I would post and at least help a little from what I can see here in your post.

Code:
$order_number = mosgetparam( $_REQUEST, 'order_id', 0);

This is not a database call. I am not sure what the function mosgetparam does, but the $_REQUEST object is the HTTP Request header. This is sent from the browser to the server and holds information. Cookies, for example, are appended to the Request header. It is looking for the variable 'order_id' in the Request header and is not finding it. It is returning 0 because that is what the third parameter is for. It is used as a default for when the variable is not found in the Request object.

I know this is pretty late and you probably have already solved the problem, but I thought I would post to possibly help others who were stuck in the same spot.

Looking at the code Joe Suave posted I would find out where the $d array is coming from. That looks like it has order details and probably has the value you are looking for.

Good luck!
Logged
ranbou
Newbie
*
Posts: 4


« Reply #8 on: March 05, 2009, 11:32:18 AM »

I had a chance to look at it this morning and here is an easy solution:

Open ps_authorize.php and look for this code block:

Code:
// Invoice Information
'x_invoice_num' => substr($d['order_number'], 0, 20),
'x_description' => '',

// Transaction Data
'x_amount' => $db->f("order_total"),
'x_currency_code' => $vendor_currency,
'x_method' => 'CC',
'x_type' => 'PRIOR_AUTH_CAPTURE',
'x_recurring_billing' => AN_RECURRING,

'x_card_num' => $dbaccount->f("account_number"),
'x_card_code' => $db->f('order_payment_code'),
'x_exp_date' => $expire_date,
'x_trans_id' => $db->f("order_payment_trans_id"),

// Level 2 data
'x_po_num' => substr($d['order_number'], 0, 20),
'x_tax' => substr($db->f('order_tax'), 0, 15),
'x_tax_exempt' => "FALSE",
'x_freight' => $db->f('order_shipping'),
'x_duty' => 0

I think this block contains both of the pieces of information you are looking for; x_invoice_num and x_po_num. Simply change those two lines like this:

Code:
'x_invoice_num' => $db->f("order_id"),

Code:
'x_po_num' => substr($d['order_number'], 0, 20),

That will send the Order ID to Authorize.net instead of the Order Number. It is an easy fix, now that you know how. Smiley

I hope this helps!
« Last Edit: March 05, 2009, 11:37:43 AM by ranbou » Logged
Pages: [1]   Go Up
Print
Jump to: