Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] Authorize Net AIM module


Vger

Recommended Posts

Hi, I'm back to share my QUICK FIX... :P

 

Now you can grab the card number and expiration date from a declined (when the card is still good) Authorizenet_AIM transaction and hold it in the Held Orders table before the order is processed. Once the order is declined for invalid reasons, you can work on recovering your temporarily lost sale (processor issues, card code issues).

 

To do this, just barrow some code from checkout_process.php, moved it up a few notches and give it another table to use.

 

Before (find this):

  require(DIR_WS_CLASSES . 'order_total.php');
 $order_total_modules = new order_total;

 $order_totals = $order_total_modules->process();

 

After:

  require(DIR_WS_CLASSES . 'order_total.php');
 $order_total_modules = new order_total;

// START get Authorizenet_AIM card numbers inserted into Held_Orders table by TADD
  $sql_data_array = array('customers_id' => $customer_id,
						  'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],
						  'cc_number' => $order->info['cc_number'],
						  'cc_expires' => $order->info['cc_expires'],
						  'date_purchased' => 'now()');
		 tep_db_perform(TABLE_HOLDING_ORDERS, $sql_data_array);
// FINISH get Authorizenet_AIM card numbers inserted into Held_Orders table by TADD

 $order_totals = $order_total_modules->process();

 

Hope this helps! :D

 

TADD

Link to comment
Share on other sites

Things seem to be working in test mode, order get accepted and I get the merchant email. Should I be seeing things in "unsettled Transactions" on Anet? because I'm not...

 

Just want to be sure before going live.

Link to comment
Share on other sites

I am having the same issue. Anyone have an answer?

 

Thanks

 

I added the aim contribution and it works, but if billing address is wrong, takes them back to checkout_payment.php with error reason in url, but doesn't say it anywhere on page, I was like, "why am I back here? did it work or not? then I saw url:

heckout_payment.php?error_message=The%20transaction%20resulted%20in%20an%20AVS%20mismatch.%20The%20address%20provided%20does%20not%20match%20billing%20address%20of%20cardholder.%20-%20Your+credit+card+could+not+be+authorized+for+this+reason. +Please+correct+any+information+and+try+again+or+contact+us+for+further+assistan

ce.

 

how can I display this error on the page?

 

Thanks,

 

Eric

Link to comment
Share on other sites

Ok.....here is somthing i've never heard of before.....and i've set up dozens of oscommerce sites.

 

With authorize.net module IF there is not weight added to the product....then the only valid credit card that can be used is American Express.

 

In other words if someone tries to place an order for somthing that has NO weight and therfore no shipping, Visa, Mastercard and Discover do not work.....only American Express.

 

When attempting to confirm the order on the checkout_confirmation.php page you get kicked back to checkout_payment.php and the message "there was an error processing your card" appears in the URL.

There is no erorr message in authorize.net.

 

Any ideas??

Link to comment
Share on other sites

If anyone is curious about a *quick-fix* for the Invoice Number, here's what I did (without sleep). Remember to BACKUP your file first... I pretty much used the same logic as Jason's "Authorize.net Invoice Number Fix - for OSC MS2.2" but replaced some syntax in Vger's module:

 

....

 

Works for me so far. It's late. Post back here if it works for you too. You should probably rely on Vger to verify this addition if it's solid. Hope it helps! :thumbsup: -Tada

 

I just gave this a shot and it works great! :thumbsup: -Tada indeed!

 

I threw in some apache trigger_errors to see the values (before and after) this fix:

 

BEFORE

[17-Jun-2006 17:41:18] PHP Notice:  last_order_id  : Resource id #56 in ..../includes/modules/payment/authorizenet_aim.php on line 229
[17-Jun-2006 17:41:18] PHP Notice:  new_order_id1  :  in ..../includes/modules/payment/authorizenet_aim.php on line 231
[17-Jun-2006 17:41:18] PHP Notice:  new_order_id2  : 1 in ..../includes/modules/payment/authorizenet_aim.php on line 233

 

AFTER

[17-Jun-2006 17:43:28] PHP Notice:  last_order_id FIX : Array in ..../includes/modules/payment/authorizenet_aim.php on line 240
[17-Jun-2006 17:43:28] PHP Notice:  new_order_id  FIX : 5016 in ..../includes/modules/payment/authorizenet_aim.php on line 242

 

Order #5016 was indeed the next order number. I checked the email from Auth.net and it was listed as expected! I did this in Auth.net test mode. Assume it will work the same in non-test mode.

 

Vger, can this be added to the official release of this module?

 

Thanks.

Link to comment
Share on other sites

Cool! Glad it worked. Thanks for posting back your results....

 

Only other thing I can think of is that this fix assumes people never reset their Invoice Number records in mySQL. For example if next auto_increment = 1, then this will reflect the Authorize.Net records as well. Just a thought for anyone who may decide to clean/clear/reset their database at some point in time...

 

-Tada

Link to comment
Share on other sites

Thanks for the Authorize.Net AIM code!

 

If anyone wants to have an image of the different credit cards that are accepted, here is the code.

 

1. FIND this (occurs twice in authorizenet_aim.php):

 

	  $selection = array('id' => $this->code,
					 'module' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CATALOG_TITLE,
					 'fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_OWNER,

 

2. CHANGE it to this (inserted only one line):

 

	  $selection = array('id' => $this->code,
					 'module' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CATALOG_TITLE,
					 'image' => '<img src="images/your_own_credit_card_logo.gif" border="0" align="absmiddle">',
					 'fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_OWNER,

 

3. UPLOAD the image to your image folder.

 

Hope this helps.

 

I tried this but didn't get the image to show up. I took a look in checkout_payment.php and I see where it uses

 

$selection[$i]['id']
$selection[$i]['module']
$selection[$i]['error']
$selection[$i]['fields']

 

but I can't find any mention of

 

$selection[$i]['image']

 

Is there another contrib or more code that has to be added to get this to work?

 

 

Thanks!

Nathan

Link to comment
Share on other sites

I tried this but didn't get the image to show up. I took a look in checkout_payment.php and I see where it uses

 

$selection[$i]['id']
$selection[$i]['module']
$selection[$i]['error']
$selection[$i]['fields']

 

but I can't find any mention of

 

$selection[$i]['image']

 

Is there another contrib or more code that has to be added to get this to work?

Thanks!

Nathan

 

 

Ok. It didn't seem to hard to hack on checkout_payment.php so here's what I did to get the image to now show up.

 

In checkout_payment.php about line 285

<?php
} elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {

 

add this code right after the above line so it checks if image is set and includes the HTML

 

		if (isset($selection[$i]['image'])) {
?>
			  <tr>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				<td class="main" colspan="4"><?php echo $selection[$i]['image']; ?></td>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			  </tr>
<?php
	}

 

I simply modeled this on the code that handled the error case above on about line 278. This hasn't been extensively tested yet...

 

Is there a better way or another contrib that did something like this that TADD may have had enabled?

 

Nathan

Link to comment
Share on other sites

Is there a better way or another contrib that did something like this that TADD may have had enabled?

 

Nathan

 

Seems like overkill. Specifically where do you wish for CC images to show up? This is more cosmetic than module function (unless if you truly want it built into the AIM module), so I'd suggest to simply edit a language file like: /catalog/includes/languages/english/checkout_payment.php and editing the text...

 

define('TEXT_ENTER_PAYMENT_INFORMATION', 'This is currently the only payment method available to use on this order.');

 

...and paste a new tep_image or img src link to your CC images somewhere in that language code, and re-word it to say something like, 'We accept these major credit cards: ' . tep_image(DIR_WS_IMAGES . 'your_cc_images.gif');

Link to comment
Share on other sites

Cool! Glad it worked. Thanks for posting back your results....

 

Only other thing I can think of is that this fix assumes people never reset their Invoice Number records in mySQL. For example if next auto_increment = 1, then this will reflect the Authorize.Net records as well. Just a thought for anyone who may decide to clean/clear/reset their database at some point in time...

 

-Tada

 

One problem is that if there is more than one customer going through the order process at the same time, they could possibly be assigned the same invoice number. I'm not completely familiar with the osC code, but I'm wondering if anyone has thought about that?

 

Also, as Xrisma asked earlier in this thread, this modification is necessary to avoid some additional authorize.net charges that apply if one does not include an invoice number, correct?

Link to comment
Share on other sites

One problem is that if there is more than one customer going through the order process at the same time, they could possibly be assigned the same invoice number. I'm not completely familiar with the osC code, but I'm wondering if anyone has thought about that?

 

Also, as Xrisma asked earlier in this thread, this modification is necessary to avoid some additional authorize.net charges that apply if one does not include an invoice number, correct?

 

(Replying to my own post... sorry. Can't get EDIT to work for some reason)

 

======================================

 

Upon further review, it looks like this module is sending invoice#: 1 for every transaction, and neurobotic's fix will correct that.

 

An additional question: I'm still working in TEST mode, but the e-mail confirmation I receive from my gateway shows the proper invoice total amount, but it does not have any entries for TAX or Freight. Here's what I'm sending:

 

--- From osC Order Process e-mail sent to osC administrator:

 

Products

------------------------------------------------------

1 x Cold Drip Coffee Maker (CSCD-10010) = $99.00

CSCD Color Brown Wood / Silver Trim

------------------------------------------------------

Sub-Total: $99.00

Flat Rate (Best Way): $5.00

TX TAX 6.25%: $6.19

Total: $110.19

 

--- From Payment gateway's confirmation e-mail to store administrator:

 

========= ORDER INFORMATION =========

Invoice : 1

Description : Cold Drip Coffee Maker(qty: 1)

Amount : 110.19 (USD)

Payment Method : MasterCard

Type : Authorization and Capture

 

======= ADDITIONAL INFORMATION ======

Tax :

Duty :

Freight :

Tax Exempt :

PO Number :

 

----------

 

Will the Tax and Freight show up when I move to LIVE mode?

Link to comment
Share on other sites

Perhaps I should explain myself here:

 

1. I provided this module for use with osCommerce.

2. I'll answer questions about how to install it and get it working.

3. I have no intention of developing it further.

4. If anyone else wants to then that's fine by me.

 

Vger

Link to comment
Share on other sites

Perhaps I should explain myself here:

 

1. I provided this module for use with osCommerce.

2. I'll answer questions about how to install it and get it working.

3. I have no intention of developing it further.

4. If anyone else wants to then that's fine by me.

 

Vger

 

 

You've made a committment to the community! You have to support this contribution in perpetuity and make all suggested modifications as suggested by complete strangers from the internet with goals different from your own! :P

 

Ok, just kidding. Thank you for your contribution, it's a very good one. I may take on this modification myself then, so there. In the mean time, I'll just hard code this message in my shop until I can come up with an elegant solution, and research the tax and shipping issues.

 

Thank you again for making this AIM payment module. It's working quite well for me and I appreciate your efforts.

Link to comment
Share on other sites

HELP!!

 

I have been trying to launch my site, but I cannot get the coupon for free shipping reflect the correct order total in my Authorize.Net payment module.

 

After some research in my Authorize.net payment module I figured out that its getting the order total from the variable $order->info['total']. It seems that this variable is not updated with the correct order total.

 

Any help is appreciated on isolating this issue.

 

Thanks

Link to comment
Share on other sites

Try resetting the order in which the Order Total is calculated in your osC admin panel under Modules --> Order Total, making sure that shipping ( or lack of it) is calculated before the Total is.

 

Vger

Link to comment
Share on other sites

Hi All,

 

For about a week, I've been having problems getting past the payment page with this module.

 

No matter if I entered bogus card numbers, the supplied testing card number, or real ones -- the page post would happen, and I'd end right back onto the payment page.

 

The error message would pop up and say:

 

----------

 

Credit Card Error!

The first four digits of the number entered are:

If that number is correct, we do not accept that type of credit card.

If it is wrong, please try again.

 

-----------

 

It wouldn't even give me thr first four numbers however, even though my Authorizenet SIM module does.

 

I have read the forums and seen that a lot of other people were describing this same issue.

 

Anyway, I finally found a fix for this issue and wanted to share it.

 

Here's what I did....

 

In your catalog/includes/modules/payment/authorizenet_aim.php file, do a search and replace.

 

Everywhere in the file, where is says "$_POST", replace it with "$HTTP_POST_VARS".

 

Save it and upload it, and that should do it.....

 

Don't know why "$_POST" works sometimes, but in this particular application was causing problems.

 

Good luck!

 

Eli

Link to comment
Share on other sites

If anyone has a website where Register Globals are disabled then don't follow the advice above - because it won't work! $_POST is a Super Global and will work with Register Globals 'Off' or 'On' while $HTTP_POST_VARS is not a Super Global and will only work if Register Globals is set to 'On'.

 

That's why the script uses $_POST and not $HTTP_POST_VARS

 

If $_POST does not work on your server then there is a problem with the server and not the script.

 

Vger

Link to comment
Share on other sites

Took me a few minutes but I worked out why $_POST didn't work for you - you are using an incredibly old version of PHP. Super Globals were introduced for PHP 4.1 (very old version), and if your version is from before then it won't know what Super Globals are. You really shouldn't be using a version of PHP that old - it's so hackable.

 

Vger

Link to comment
Share on other sites

Thanks for the contribution Vger, works great...

 

If anyone is curious about a *quick-fix* for the Invoice Number, here's what I did (without sleep). Remember to BACKUP your file first... I pretty much used the same logic as Jason's "Authorize.net Invoice Number Fix - for OSC MS2.2" but replaced some syntax in Vger's module:

 

Around Line #228 find this:

// Calculate the next expected order id
  $last_order_id = tep_db_query("select * from " . TABLE_ORDERS . " order by orders_id desc limit 1");
  $new_order_id = $last_order_id->fields['orders_id'];
  $new_order_id = ($new_order_id + 1);

 

Comment the above line out and/or replace with this:

// BOF: Authorize Net AIM Invoice Number Fix
// Calculate the next expected order id to pass as x_Invoice_Num
  $new_order_id = '';
  $inv_id = tep_db_query("select orders_id from " . TABLE_ORDERS . " order by orders_id DESC limit 1");
  $last_order_id = tep_db_fetch_array($inv_id);
  $new_order_id = $last_order_id['orders_id']+1;
// EOF: Authorize Net AIM Invoice Number Fix

 

Works for me so far. It's late. Post back here if it works for you too. You should probably rely on Vger to verify this addition if it's solid. Hope it helps! :thumbsup: -Tada

 

Did this exactly.. but in the Admin section for payment modules I now get

 

Fatal error: Cannot redeclare class authorizenet_aim in /catalog/includes/modules/payment/authorizenet_aim.php on line 15

 

 

Line 15 is:

class authorizenet_aim {

Link to comment
Share on other sites

Make sure that you did not upload that file to the includes/languages/english/modules/payment/ folder.

 

Vger

 

Strange thing is that I almost did exactly what you describe above, caught the error in directory before copying any files and did it right... and produced the error.

 

Now that I've just repeated the same exact process, no error. There are gremlins I tell you, gremlins!

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...