Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

One Page Checkout Support


Guest

Recommended Posts

Hi i dont use paypal express is there no setting in admin>modules>payment>paypal express to set return link ?, see if its hard coded in either includes/modules/payment/paypal_express.php? or ext/modules/payment/paypal/express.php? or should return link be ext/modules/payment/paypal/express.php play around a bit

 

Steve

 

Thanks so much for your help, but I found out the problem! There wasn't anything wrong with my paypal express module... it was the checkout_process.php that was the problem. So I just swapped the contribution's checkout_process.php for my original one and wala! It works!

Link to comment
Share on other sites

Hello Steve,

 

Sorry, reading your last post again I realise that isn't it. Could it be this though?...

 

//customer_exclusions
       $check_user_query = tep_db_query( $sql = 'SELECT dc2u.customers_id
                                                 FROM '.TABLE_DISCOUNT_COUPONS_TO_CUSTOMERS.' dc2u
                                                 WHERE customers_id='.$customer_id.'
                                                   AND coupons_id="'.tep_db_input( $code ).'"' );
       if( tep_db_num_rows( $check_user_query ) > 0 ) {
         $this->message( ENTRY_DISCOUNT_COUPON_ERROR ); //display the error message
         //use this to debug exclusions:
         //$this->message( 'Customer exclusion check failed' );
       }
       //shipping zone exclusions
       $check_user_query = tep_db_query($sql = 'SELECT dc2z.geo_zone_id
                                                 FROM '.TABLE_DISCOUNT_COUPONS_TO_ZONES.' dc2z
                                                 LEFT JOIN '.TABLE_ZONES_TO_GEO_ZONES.' z2g
                                                   USING( geo_zone_id )
                                                 WHERE ( z2g.zone_id='.$delivery['zone_id'].' or z2g.zone_id = 0 or z2g.zone_id IS NULL )
                                                   AND ( z2g.zone_country_id='.$delivery['country_id'].' or z2g.zone_country_id = 0 )
                                                   AND dc2z.coupons_id="'.tep_db_input( $code ).'"' );

         if (tep_db_num_rows( $check_user_query ) > 0 ) {
           $this->message( ENTRY_DISCOUNT_COUPON_ERROR ); //display the error message
         //use this to debug exclusions:
           //$this->message( 'Shipping Zones exclusion check failed' );
         }
         //end shipping zone exclusions


AND THIS SECTION

function check_coupons_max_use() {
     global $customer_id;
     $check_use_query = tep_db_query($sql = "SELECT COUNT(*) AS cnt
                                             FROM ".TABLE_ORDERS." AS o
                                             INNER JOIN ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o
                                               ON dc2o.orders_id=o.orders_id
                                               AND o.customers_id = '".(int)$customer_id."'
                                               AND dc2o.coupons_id='".tep_db_input( $this->coupon['coupons_id'] )."'");
     $use = tep_db_fetch_array( $check_use_query );
     //show error message if coupons_max_use is equal to the number of times this customer has used the code
     if( $this->coupon['coupons_max_use'] <= $use['cnt'] ) {
       $this->message( sprintf( ENTRY_DISCOUNT_COUPON_USE_ERROR, $use['cnt'], $this->coupon['coupons_max_use'] ) ); //display the error message for number of times used
       return false;
     }
     return true;
   }

 

This is what i have deleted from my includes/classes/discount_coupon.php

Maybe it is some more, but try with this first.

 

Remember to backup!

Edited by sportstolen
Link to comment
Share on other sites

//customer_exclusions
       $check_user_query = tep_db_query( $sql = 'SELECT dc2u.customers_id
                                                 FROM '.TABLE_DISCOUNT_COUPONS_TO_CUSTOMERS.' dc2u
                                                 WHERE customers_id='.$customer_id.'
                                                   AND coupons_id="'.tep_db_input( $code ).'"' );
       if( tep_db_num_rows( $check_user_query ) > 0 ) {
         $this->message( ENTRY_DISCOUNT_COUPON_ERROR ); //display the error message
         //use this to debug exclusions:
         //$this->message( 'Customer exclusion check failed' );
       }
       //shipping zone exclusions
       $check_user_query = tep_db_query($sql = 'SELECT dc2z.geo_zone_id
                                                 FROM '.TABLE_DISCOUNT_COUPONS_TO_ZONES.' dc2z
                                                 LEFT JOIN '.TABLE_ZONES_TO_GEO_ZONES.' z2g
                                                   USING( geo_zone_id )
                                                 WHERE ( z2g.zone_id='.$delivery['zone_id'].' or z2g.zone_id = 0 or z2g.zone_id IS NULL )
                                                   AND ( z2g.zone_country_id='.$delivery['country_id'].' or z2g.zone_country_id = 0 )
                                                   AND dc2z.coupons_id="'.tep_db_input( $code ).'"' );

         if (tep_db_num_rows( $check_user_query ) > 0 ) {
           $this->message( ENTRY_DISCOUNT_COUPON_ERROR ); //display the error message
         //use this to debug exclusions:
           //$this->message( 'Shipping Zones exclusion check failed' );
         }
         //end shipping zone exclusions


AND THIS SECTION

function check_coupons_max_use() {
     global $customer_id;
     $check_use_query = tep_db_query($sql = "SELECT COUNT(*) AS cnt
                                             FROM ".TABLE_ORDERS." AS o
                                             INNER JOIN ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o
                                               ON dc2o.orders_id=o.orders_id
                                               AND o.customers_id = '".(int)$customer_id."'
                                               AND dc2o.coupons_id='".tep_db_input( $this->coupon['coupons_id'] )."'");
     $use = tep_db_fetch_array( $check_use_query );
     //show error message if coupons_max_use is equal to the number of times this customer has used the code
     if( $this->coupon['coupons_max_use'] <= $use['cnt'] ) {
       $this->message( sprintf( ENTRY_DISCOUNT_COUPON_USE_ERROR, $use['cnt'], $this->coupon['coupons_max_use'] ) ); //display the error message for number of times used
       return false;
     }
     return true;
   }

 

This is what i have deleted from my includes/classes/discount_coupon.php

Maybe it is some more, but try with this first.

 

Remember to backup!

 

YES!!!! GET IN!!!! Johann you're a star! Thankyou so much. Big thankyou to Steve aswell! Can I just ask a couple more questions?

 

1. Is it possible to move the voucher section on the checkout page to below the address fields?

 

2. I am using the Paypal_ipn module. During the checkout process for some reason the order is generated ie. coming into "Pending" in the Orders section of admin and the "Order Process" email sent BEFORE the customer actually pays through Paypal. If for some reason the customer changes their mind or there is a problem with Paypal they still receive the "Order Process" email and the unpaid order sits on their account as pending. Is there any way of changing this?

 

Thanks again for all the help so far!

 

Cheers,

Mark.

Link to comment
Share on other sites

YES!!!! GET IN!!!! Johann you're a star! Thankyou so much. Big thankyou to Steve aswell! Can I just ask a couple more questions?

 

1. Is it possible to move the voucher section on the checkout page to below the address fields?

 

2. I am using the Paypal_ipn module. During the checkout process for some reason the order is generated ie. coming into "Pending" in the Orders section of admin and the "Order Process" email sent BEFORE the customer actually pays through Paypal. If for some reason the customer changes their mind or there is a problem with Paypal they still receive the "Order Process" email and the unpaid order sits on their account as pending. Is there any way of changing this?

 

Thanks again for all the help so far!

 

Cheers,

Mark.

 

Glad i could help!

 

It should be this section in checkout.php i havent tested it myself.

 

I dont use any of paypal so i couldnt answer, but i am almost for sure that this topic have been up in this thread or somewhere else in the forums that there is a fix for it. i dont know if it was call held orders or something.

 

<tr>

 <td class="main" style="padding-top:5px;"><table cellpadding="10" cellspacing="0" border="0" width="100%">
  <tr>
   <td class="main" width="50%" align="left"><?php
   	  if (!tep_session_is_registered('customer_id')){
	//BOF KGT
	if (MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true'){
		echo '<table cellpadding="2" cellspacing="0" border="0">
		 <tr>
		  <td class="main"><b>' . TEXT_HAVE_COUPON_CCGV . '</b></td>
		 </tr>
		 <tr>
		  <td class="main">' . tep_draw_input_field('coupon', '') . '</td>
		  <td class="main">' . tep_image_submit('button_redeem.gif', IMAGE_REDEEM_VOUCHER, 'id="voucherRedeemCoupon"') . '</td>
		 </tr>
		</table>';
	}
	//EOF KGT
	  		} else {
	if (MODULE_ORDER_TOTAL_COUPON_STATUS == 'true'){
		echo '<table cellpadding="2" cellspacing="0" border="0">
		 <tr>
		  <td class="main"><b>' . TEXT_HAVE_COUPON_CCGV . '</b></td>
		 </tr>
		 <tr>
		  <td class="main">' . tep_draw_input_field('gv_redeem_code', '') . '</td>
		  <td class="main">' . tep_image_submit('button_redeem.gif', IMAGE_REDEEM_VOUCHER, 'id="voucherRedeem"') . '</td>
		 </tr>
		</table>';
	}
	//BOF KGT
	if (MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true'){
		echo '<table cellpadding="2" cellspacing="0" border="0">
		 <tr>
		  <td class="main"><b>' . TEXT_HAVE_COUPON_CCGV . '</b></td>
		 </tr>
		 <tr>
		  <td class="main">' . tep_draw_input_field('coupon', '') . '</td>
		  <td class="main">' . tep_image_submit('button_redeem.gif', IMAGE_REDEEM_VOUCHER, 'id="voucherRedeemCoupon"') . '</td>
		 </tr>
		</table>';
	}
	//EOF KGT

	}
   ?></td>
   <td class="main" width="50%" align="right"></td>
  </tr>
 </table></td>
</tr>

Link to comment
Share on other sites

Shipping Address Bug

 

I've recently found something that I think is a bug within OPC1.4 that I hope someone can help me to confirm and fix?

 

Bug: Shipping Address Does Not Get Recorded, If Password Is Added AFTER Shipping Address Is Added.

 

Steps to recreate:

 

1. Fill in Billing Address

2. Click Different From Bill Address Checkbox.

3. Shipping Address Fields Reveal

4. Enter Shipping Address (different from billing)

5. Enter new password (in two password boxes)

6. Complete order

 

 

Then go to the Admin section and I am seeing that the shipping and billing addresses are the same.

 

Does anyone else see this bug?

 

 

 

Thanks!

Link to comment
Share on other sites

Thanks again Johan! That sorted the voucher section. Much appreciated!

 

I'm still struggling with the orders being generated before the actual payment. I think the "held orders" contribution is for orders that are getting lost during the checkout process.

 

My problem is that I think for some reason the orders are being generated when the "Continue" button is clicked on the checkout page (before being directed to Paypal) rather than on returning to the confirmation page after the Paypal payment has been completed.

 

Any ideas?

 

Cheers,

Mark.

Link to comment
Share on other sites

Thanks again Johan! That sorted the voucher section. Much appreciated!

 

I'm still struggling with the orders being generated before the actual payment. I think the "held orders" contribution is for orders that are getting lost during the checkout process.

 

My problem is that I think for some reason the orders are being generated when the "Continue" button is clicked on the checkout page (before being directed to Paypal) rather than on returning to the confirmation page after the Paypal payment has been completed.

 

Any ideas?

 

Cheers,

Mark.

 

I have an payment module that is called payson (swedish version of paypal) the customer transports to the payson site and make their payment with their creditcard and if they process with payment then they are redirected back to my site and the order is made. if they dont pay there will be no order.

 

shouldnt paypal do the same thing on a standard shop?

Link to comment
Share on other sites

Hello Johan,

 

Yes that is exactly what I need. But like I say for some reason the order is generated (order comes into admin and "order process" email sent) when the "continue" button is clicked on the checkout page ie. before Paypal. I'm guessing there must be some code somewhere that needs changing so that the order is generated only once the customer has paid.

 

Cheers,

Mark.

Link to comment
Share on other sites

Hello. I have a problem with charset in the billing and the shipping address. My website and DB are using windows-1250 charset. I adjusted the checkout.php according to http://www.oscommerce.com/forums/topic/333292-one-page-checkout-support/page__st__1840__p__1532342#entry1532342. I made a little change. I replaced UTF-8 by "windows-1250" and "cp1250" in the checkout.php. It seems that works for most of the text, but not for the billing and the shipping address.

 

You can see that in the picture.

 

hs1586.jpg

 

Please, does anybody know where and how to make more changes to show the characters correctly even if I'm using windows-1250 charset?

Link to comment
Share on other sites

Hi !

 

for several days I break my head to understand why the total amount after adding the shipping costs do not appear in the confirmation email, or in "My Account - info commands" and in the Admin area "order"

 

you can see in the screenshot :

 

in the frontend "My Account - Order Info ":

info_commande.gif

 

in the "Admin""orders":

info_pedido_admin.gif

 

when we finalize the order, the amount is correct,

and when we pay by credit card, the amount is also correct:

finaliser.gif

 

 

 

all this is rather annoying...

 

 

someone faced that problem before me?

///

Link to comment
Share on other sites

Installed and works, sort of.

I can actually check out, but I have absolutely no administration. The only way I can change any of the settings is to do it from the MySQL command line?.?.? I read in the forum several threads discussing various aspect of the administrations tools for this contribution, and how to change settings, but I have downloaded all version of the contribution and cannot find any admin files anywhere. I can see clearly that one of the sql queries added a sort order entry that would put the One Page Checkoutright between Session Options and Dynamic MoPics In the admin panel however there is nothing between these menu entries. Presumably because the package included nothing for me to install in the admin panel, but then how is it that many of you have administration tools for this contribution?.?.? :blink:

I presume once I have this worked out I will be able to change the payment modules that are loaded. As it is the modules appear to work, but One Page Checkout ignores entirely the payment modules I set up with the usual payment modules tool in the admin panel.

Any hints would be appreciated of course, but perhaps somebody can point out a duh! moment for me?.?.?

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

Hi,

 

I'm using several flat rates modules for the shipping. Each one is for different zone - for example one for US, one for Canada, one for europe. There is no shipping module installed for all zones/countries. This way "Shipping Method" section is missing on checkout.php page. Is there a solution for this ? If I enable one of the flat rate modules for all the countries then everything is fine. But It's stupid to have for example international shipping option available in case the selected shipp to country is US.

Link to comment
Share on other sites

Installed and works, sort of.

I can actually check out, but I have absolutely no administration. The only way I can change any of the settings is to do it from the MySQL command line?.?.? I read in the forum several threads discussing various aspect of the administrations tools for this contribution, and how to change settings, but I have downloaded all version of the contribution and cannot find any admin files anywhere. I can see clearly that one of the sql queries added a sort order entry that would put the One Page Checkoutright between Session Options and Dynamic MoPics In the admin panel however there is nothing between these menu entries. Presumably because the package included nothing for me to install in the admin panel, but then how is it that many of you have administration tools for this contribution?.?.? :blink:

I presume once I have this worked out I will be able to change the payment modules that are loaded. As it is the modules appear to work, but One Page Checkout ignores entirely the payment modules I set up with the usual payment modules tool in the admin panel.

Any hints would be appreciated of course, but perhaps somebody can point out a duh! moment for me?.?.?

 

have you run the sql in phpmyadmin?

 

In the install file at the bottom you will find the sql you shuld add to you DB

Link to comment
Share on other sites

Hi,

 

I'm using several flat rates modules for the shipping. Each one is for different zone - for example one for US, one for Canada, one for europe. There is no shipping module installed for all zones/countries. This way "Shipping Method" section is missing on checkout.php page. Is there a solution for this ? If I enable one of the flat rate modules for all the countries then everything is fine. But It's stupid to have for example international shipping option available in case the selected shipp to country is US.

 

 

im using zones for shipping, there i can setup how many countries i want to send to, and in checkout when the customer change country the shipping cost will change aswell.

Edited by sportstolen
Link to comment
Share on other sites

im using KGT discount coupon codes and it works almost as i want.

 

But! If i sell a gift card at the value $100 and then the customer wants to buy items for it some other day, the order_total will be zero and when press confirm order it goes to the "proccessing order, please wait" it go back to checkout.phph with error " you must select a paymentmethod for your order even though i did that.

 

So i think something in classes/onepage_checkout.php will have to change, someone with more knowledge maybe can point me in the right direction.

 

Thanks.

Link to comment
Share on other sites

I have installed OPC1.4 and it works just great :) Thanks for this contrubution.

 

Earlier i could choose to say that when a customer choos COD payment the can only choose flat rate shipping.

But now i cant do this, does anyone has sucess with something like that when using the OPC1.4 contribution?

 

Regards,

thbor83

Link to comment
Share on other sites

Hello. I have a problem with charset in the billing and the shipping address. My website and DB are using windows-1250 charset. I adjusted the checkout.php according to http://www.oscommerce.com/forums/topic/333292-one-page-checkout-support/page__st__1840__p__1532342#entry1532342. I made a little change. I replaced UTF-8 by "windows-1250" and "cp1250" in the checkout.php. It seems that works for most of the text, but not for the billing and the shipping address.

 

You can see that in the picture.

 

hs1586.jpg

 

Please, does anybody know where and how to make more changes to show the characters correctly even if I'm using windows-1250 charset?

replace them special chars with utf8 code for them

http://www.atm.ox.ac.uk/user/iwi/charmap.html

 

Steve

Link to comment
Share on other sites

Installed and works, sort of.

I can actually check out, but I have absolutely no administration. The only way I can change any of the settings is to do it from the MySQL command line?.?.? I read in the forum several threads discussing various aspect of the administrations tools for this contribution, and how to change settings, but I have downloaded all version of the contribution and cannot find any admin files anywhere. I can see clearly that one of the sql queries added a sort order entry that would put the One Page Checkoutright between Session Options and Dynamic MoPics In the admin panel however there is nothing between these menu entries. Presumably because the package included nothing for me to install in the admin panel, but then how is it that many of you have administration tools for this contribution?.?.? :blink:

I presume once I have this worked out I will be able to change the payment modules that are loaded. As it is the modules appear to work, but One Page Checkout ignores entirely the payment modules I set up with the usual payment modules tool in the admin panel.

Any hints would be appreciated of course, but perhaps somebody can point out a duh! moment for me?.?.?

it should be i admin>configuration>one page checkout

 

Steve

Link to comment
Share on other sites

it should be i admin>configuration>one page checkout

 

Steve

Steve,

Exactly! I looked at my configuration table after running all of the queries included with the contribution and that is exactly where I would expect it to be based on the records created. Admin>Configuration right in between Session Options (sort order 15) and Dynamic Mopics (sort order 17) , however; it is not there. I gathered from the two responses to my initial question that there is not a separate admin panel page for this contribution, but rather that the configuration is made using the configuration.php page with the appropriate gID specified in the url. When I check the configuration_group table I see that One Page Checkout is assigned configuration_group_id 7575. Despite the fact that there is no menu entry for One Page Checkout in my Configuration menu I tried this url catalog/admin/configuration.php?gID=7575 Which resulted in the following screen shot. As you can see not only is the Configuration menu entry missing the configuration.php page does nothing with the gID 7575. Strangely enough no error is generated either, just this blank configuration page. The next screenshot is of the relevant section of the configuration and configuraiton_group tables, perhaps one of the queries included with the contribution failed in some way without error and I am missing a record that somebody can point out.

-Jason

opc.jpg

opcConfigGroups.jpg

opcConfiguration.jpg

Edited by jsalis

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

How embarrassing, after plowing through the queries included with the contribution I verified that every query was successful. Then I looked at catalog/admin/includes/configure.php file and discovered that the change the db assigned there was the production db instead of the sandbox db that I ran the queries against. Anyway the admin panel does work fine and I no longer need to change the configuration from the MySQL db directly.

 

My initial testing was with the cc payment module which works well enough.The Authorize.net AIM module (or Credit Card via Authorize.net module)on the other hand suffers the same fate as others have reported here in the forum. Basically if I select the Authorize.net module's radio button I get the "There was an error setting payment method, please inform [Company Name] about this error." message, then if I click continue I get the same message again in addition to the error that the first 4 digits of the card number indicates an unsupported card type message, only now the module is in fact actually loaded and can be used. I have tried making Authorize.net available with and without the cc module makes no difference nor does it make any difference which Authorize.net module I use.

Edited by jsalis

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

How embarrassing, after plowing through the queries included with the contribution I verified that every query was successful. Then I looked at catalog/admin/includes/configure.php file and discovered that the change the db assigned there was the production db instead of the sandbox db that I ran the queries against. Anyway the admin panel does work fine and I no longer need to change the configuration from the MySQL db directly.

 

My initial testing was with the cc payment module which works well enough.The Authorize.net AIM module (or Credit Card via Authorize.net module)on the other hand suffers the same fate as others have reported here in the forum. Basically if I select the Authorize.net module's radio button I get the "There was an error setting payment method, please inform [Company Name] about this error." message, then if I click continue I get the same message again in addition to the error that the first 4 digits of the card number indicates an unsupported card type message, only now the module is in fact actually loaded and can be used. I have tried making Authorize.net available with and without the cc module makes no difference nor does it make any difference which Authorize.net module I use.

Hi use authorizenet_cc_aim.php

 

and replace code in that file with this code

<?php

/*

 $Id: authorizenet_cc_aim.php 1803 2008-01-11 18:16:37Z hpdl $



 Digistore v4.0,  Open Source E-Commerce Solutions

 http://www.digistore.co.nz



 Copyright (c) 2008 osCommerce



 Released under the GNU General Public License

*/



 class authorizenet_cc_aim {

   var $code, $title, $description, $enabled;



// class constructor

   function authorizenet_cc_aim() {

     global $order;



     $this->signature = 'authorizenet|authorizenet_cc_aim|1.0|2.2';



     $this->code = 'authorizenet_cc_aim';

     $this->title = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_TITLE;

     $this->public_title = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_PUBLIC_TITLE;

     $this->description = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_DESCRIPTION;

     $this->sort_order = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER;

     $this->enabled = ((MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS == 'True') ? true : false);



     if ((int)MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID > 0) {

       $this->order_status = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID;

     }



     if (is_object($order)) $this->update_status();

   }



// class methods

   function update_status() {

     global $order;



// disable the module if  free downloads

     if ($this->enabled == true) {

       global $cart;

       if ($cart->show_total() == 0.00) {

         $this->enabled = false;

       }

     }







     if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE > 0) ) {

       $check_flag = false;

       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");

       while ($check = tep_db_fetch_array($check_query)) {

         if ($check['zone_id'] < 1) {

           $check_flag = true;

           break;

         } elseif ($check['zone_id'] == $order->billing['zone_id']) {

           $check_flag = true;

           break;

         }

       }



       if ($check_flag == false) {

         $this->enabled = false;

       }

     }

   }



   function javascript_validation() {

     return false;

   }



   function selection() {

     return array('id' => $this->code,

                  'module' => $this->public_title);

   }



   function pre_confirmation_check() {

     return false;

   }



   function confirmation() {

     global $order, $_POST;



     for ($i=1; $i<13; $i++) {

       $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));

     }



     $today = getdate(); 

     for ($i=$today['year']; $i < $today['year']+10; $i++) {

       $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));

     }



     $confirmation = array('fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_OWNER,

                                                   'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),

                                             array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_NUMBER,

                                                   'field' => tep_draw_input_field('cc_number_nh-dns')),

                                             array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_EXPIRES,

                                                   'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year)),

                                             array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_CVC,

                                                   'field' => tep_draw_input_field('cc_cvc_nh-dns', '', 'size="5" maxlength="4"'))));



     return $confirmation;

   }



   function process_button() {

     return false;

   }



   function before_process() {

     global $_POST, $customer_id, $order, $sendto, $currency;



     $params = array('x_login' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID, 0, 20),

                     'x_tran_key' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY, 0, 16),

                     'x_version' => '3.1',

                     'x_delim_data' => 'TRUE',

                     'x_delim_char' => ',',

                     'x_encap_char' => '"',

                     'x_relay_response' => 'FALSE',

                     'x_first_name' => substr($order->billing['firstname'], 0, 50),

                     'x_last_name' => substr($order->billing['lastname'], 0, 50),

                     'x_company' => substr($order->billing['company'], 0, 50),

                     'x_address' => substr($order->billing['street_address'], 0, 60),

                     'x_city' => substr($order->billing['city'], 0, 40),

                     'x_state' => substr($order->billing['state'], 0, 40),

                     'x_zip' => substr($order->billing['postcode'], 0, 20),

                     'x_country' => substr($order->billing['country']['title'], 0, 60),

                     'x_phone' => substr($order->customer['telephone'], 0, 25),

                     'x_cust_id' => substr($customer_id, 0, 20),

                     'x_customer_ip' => tep_get_ip_address(),

                     'x_email' => substr($order->customer['email_address'], 0, 255),

                     'x_description' => substr(STORE_NAME, 0, 255),

                     'x_amount' => substr($this->format_raw($order->info['total']), 0, 15),

                     'x_currency_code' => substr($currency, 0, 3),

                     'x_method' => 'CC',

                     'x_type' => ((MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD == 'Capture') ? 'AUTH_CAPTURE' : 'AUTH_ONLY'),

                     'x_card_num' => substr($_POST['cc_number_nh-dns'], 0, 22),

                     'x_exp_date' => $_POST['cc_expires_month'] . $_POST['cc_expires_year'],

                     'x_card_code' => substr($_POST['cc_cvc_nh-dns'], 0, 4));



     if (is_numeric($sendto) && ($sendto > 0)) {

       $params['x_ship_to_first_name'] = substr($order->delivery['firstname'], 0, 50);

       $params['x_ship_to_last_name'] = substr($order->delivery['lastname'], 0, 50);

       $params['x_ship_to_company'] = substr($order->delivery['company'], 0, 50);

       $params['x_ship_to_address'] = substr($order->delivery['street_address'], 0, 60);

       $params['x_ship_to_city'] = substr($order->delivery['city'], 0, 40);

       $params['x_ship_to_state'] = substr($order->delivery['state'], 0, 40);

       $params['x_ship_to_zip'] = substr($order->delivery['postcode'], 0, 20);

       $params['x_ship_to_country'] = substr($order->delivery['country']['title'], 0, 60);

     }



     if (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE == 'Test') {

       $params['x_test_request'] = 'TRUE';

     }



     $tax_value = 0;



     foreach ($order->info['tax_groups'] as $key => $value) {

       if ($value > 0) {

         $tax_value += $this->format_raw($value);

       }

     }



     if ($tax_value > 0) {

       $params['x_tax'] = $this->format_raw($tax_value);

     }



     $params['x_freight'] = $this->format_raw($order->info['shipping_cost']);



     $post_string = '';



     foreach ($params as $key => $value) {

       $post_string .= $key . '=' . urlencode(trim($value)) . '&';

     }



     $post_string = substr($post_string, 0, -1);



     for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

       $post_string .= '&x_line_item=' . urlencode($i+1) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 31)) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 255)) . '<|>' . urlencode($order->products[$i]['qty']) . '<|>' . urlencode($this->format_raw($order->products[$i]['final_price'])) . '<|>' . urlencode($order->products[$i]['tax'] > 0 ? 'YES' : 'NO');

     }



     switch (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER) {

       case 'Live':

         $gateway_url = 'https://secure.authorize.net/gateway/transact.dll';

         break;



       default:

         $gateway_url = 'https://test.authorize.net/gateway/transact.dll';

         break;

     }



     $transaction_response = $this->sendTransactionToGateway($gateway_url, $post_string);



     if (!empty($transaction_response)) {

       $regs = preg_split("/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/", $transaction_response);



       foreach ($regs as $key => $value) {

         $regs[$key] = substr($value, 1, -1); // remove double quotes

       }

     } else {

       $regs = array('-1', '-1', '-1');

     }



     $error = false;



     if ($regs[0] == '1') {

       if (tep_not_null(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH)) {

         if (strtoupper($regs[37]) != strtoupper(md5(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH . MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID . $regs[6] . $this->format_raw($order->info['total'])))) {

           $error = 'general';

         }

       }

     } else {

       switch ($regs[2]) {

         case '7':

           $error = 'invalid_expiration_date';

           break;



         case '8':

           $error = 'expired';

           break;



         case '6':

         case '17':

         case '28':

           $error = 'declined';

           break;



         case '78':

           $error = 'cvc';

           break;



         default:

           $error = 'general';

           break;

       }

     }



     if ($error != false) {

       tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . $error, 'SSL'));

     }

   }



   function after_process() {

     return false;

   }



   function get_error() {

     global $_GET;



     $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_GENERAL;



     switch ($_GET['error']) {

       case 'invalid_expiration_date':

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_INVALID_EXP_DATE;

         break;



       case 'expired':

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_EXPIRED;

         break;



       case 'declined':

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_DECLINED;

         break;



       case 'cvc':

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_CVC;

         break;



       default:

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_GENERAL;

         break;

     }



     $error = array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_TITLE,

                    'error' => $error_message);



     return $error;

   }



   function check() {

     if (!isset($this->_check)) {

       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS'");

       $this->_check = tep_db_num_rows($check_query);

     }

     return $this->_check;

   }



   function install() {

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Authorize.net Credit Card AIM', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS', 'False', 'Do you want to accept Authorize.net Credit Card AIM payments?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Login ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID', '', 'The login ID used for the Authorize.net service', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Transaction Key', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY', '', 'Transaction key used for encrypting data', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('MD5 Hash', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH', '', 'The MD5 hash value to verify transactions with', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Server', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER', 'Live', 'Perform transactions on the live or test server. The test server should only be used by developers with Authorize.net test accounts.', '6', '0', 'tep_cfg_select_option(array(\'Live\', \'Test\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Mode', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE', 'Live', 'Transaction mode used for processing orders', '6', '0', 'tep_cfg_select_option(array(\'Live\', \'Test\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Method', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD', 'Authorization', 'The processing method to use for each transaction.', '6', '0', 'tep_cfg_select_option(array(\'Authorization\', \'Capture\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('cURL Program Location', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL', '/usr/bin/curl', 'The location to the cURL program application.', '6', '0' , now())");

   }



   function remove() {

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

   }



   function keys() {

     return array('MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL');

   }



   function _hmac($key, $data) {

     if (function_exists('mhash') && defined('MHASH_MD5')) {

       return bin2hex(mhash(MHASH_MD5, $data, $key));

     }



// RFC 2104 HMAC implementation for php.

// Creates an md5 HMAC.

// Eliminates the need to install mhash to compute a HMAC

// Hacked by Lance Rushing



     $b = 64; // byte length for md5

     if (strlen($key) > $B) {

       $key = pack("H*",md5($key));

     }



     $key = str_pad($key, $b, chr(0x00));

     $ipad = str_pad('', $b, chr(0x36));

     $opad = str_pad('', $b, chr(0x5c));

     $k_ipad = $key ^ $ipad ;

     $k_opad = $key ^ $opad;



     return md5($k_opad . pack("H*",md5($k_ipad . $data)));

   }



   function sendTransactionToGateway($url, $parameters) {

     $server = parse_url($url);



     if (isset($server['port']) === false) {

       $server['port'] = ($server['scheme'] == 'https') ? 443 : 80;

     }



     if (isset($server['path']) === false) {

       $server['path'] = '/';

     }



     if (isset($server['user']) && isset($server['pass'])) {

       $header[] = 'Authorization: Basic ' . base64_encode($server['user'] . ':' . $server['pass']);

     }



     if (function_exists('curl_init')) {

       $curl = curl_init($server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : ''));

       curl_setopt($curl, CURLOPT_PORT, $server['port']);

       curl_setopt($curl, CURLOPT_HEADER, 0);

       curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

       curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

       curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);

       curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);

       curl_setopt($curl, CURLOPT_POST, 1);

       curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters);



       $result = curl_exec($curl);



       curl_close($curl);

     } else {

       exec(escapeshellarg(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL) . ' -d ' . escapeshellarg($parameters) . ' "' . $server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : '') . '" -P ' . $server['port'] . ' -k', $result);

       $result = implode("\n", $result);

     }



     return $result;

   }



// format prices without currency formatting

   function format_raw($number, $currency_code = '', $currency_value = '') {

     global $currencies, $currency;



     if (empty($currency_code) || !$this->is_set($currency_code)) {

       $currency_code = $currency;

     }



     if (empty($currency_value) || !is_numeric($currency_value)) {

       $currency_value = $currencies->currencies[$currency_code]['value'];

     }



     return number_format(tep_round($number * $currency_value, $currencies->currencies[$currency_code]['decimal_places']), $currencies->currencies[$currency_code]['decimal_places'], '.', '');
   }
 }
?>

 

Steve

Edited by steve_s
Link to comment
Share on other sites

Hi use authorizenet_cc_aim.php

 

and replace code in that file with this code

<?php

/*

 $Id: authorizenet_cc_aim.php 1803 2008-01-11 18:16:37Z hpdl $



 Digistore v4.0,  Open Source E-Commerce Solutions

 http://www.digistore.co.nz



 Copyright (c) 2008 osCommerce



 Released under the GNU General Public License

*/



 class authorizenet_cc_aim {

   var $code, $title, $description, $enabled;



// class constructor

   function authorizenet_cc_aim() {

     global $order;



     $this->signature = 'authorizenet|authorizenet_cc_aim|1.0|2.2';



     $this->code = 'authorizenet_cc_aim';

     $this->title = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_TITLE;

     $this->public_title = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_PUBLIC_TITLE;

     $this->description = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_DESCRIPTION;

     $this->sort_order = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER;

     $this->enabled = ((MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS == 'True') ? true : false);



     if ((int)MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID > 0) {

       $this->order_status = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID;

     }



     if (is_object($order)) $this->update_status();

   }



// class methods

   function update_status() {

     global $order;



// disable the module if  free downloads

     if ($this->enabled == true) {

       global $cart;

       if ($cart->show_total() == 0.00) {

         $this->enabled = false;

       }

     }







     if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE > 0) ) {

       $check_flag = false;

       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");

       while ($check = tep_db_fetch_array($check_query)) {

         if ($check['zone_id'] < 1) {

           $check_flag = true;

           break;

         } elseif ($check['zone_id'] == $order->billing['zone_id']) {

           $check_flag = true;

           break;

         }

       }



       if ($check_flag == false) {

         $this->enabled = false;

       }

     }

   }



   function javascript_validation() {

     return false;

   }



   function selection() {

     return array('id' => $this->code,

                  'module' => $this->public_title);

   }



   function pre_confirmation_check() {

     return false;

   }



   function confirmation() {

     global $order, $_POST;



     for ($i=1; $i<13; $i++) {

       $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));

     }



     $today = getdate(); 

     for ($i=$today['year']; $i < $today['year']+10; $i++) {

       $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));

     }



     $confirmation = array('fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_OWNER,

                                                   'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),

                                             array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_NUMBER,

                                                   'field' => tep_draw_input_field('cc_number_nh-dns')),

                                             array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_EXPIRES,

                                                   'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year)),

                                             array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_CVC,

                                                   'field' => tep_draw_input_field('cc_cvc_nh-dns', '', 'size="5" maxlength="4"'))));



     return $confirmation;

   }



   function process_button() {

     return false;

   }



   function before_process() {

     global $_POST, $customer_id, $order, $sendto, $currency;



     $params = array('x_login' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID, 0, 20),

                     'x_tran_key' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY, 0, 16),

                     'x_version' => '3.1',

                     'x_delim_data' => 'TRUE',

                     'x_delim_char' => ',',

                     'x_encap_char' => '"',

                     'x_relay_response' => 'FALSE',

                     'x_first_name' => substr($order->billing['firstname'], 0, 50),

                     'x_last_name' => substr($order->billing['lastname'], 0, 50),

                     'x_company' => substr($order->billing['company'], 0, 50),

                     'x_address' => substr($order->billing['street_address'], 0, 60),

                     'x_city' => substr($order->billing['city'], 0, 40),

                     'x_state' => substr($order->billing['state'], 0, 40),

                     'x_zip' => substr($order->billing['postcode'], 0, 20),

                     'x_country' => substr($order->billing['country']['title'], 0, 60),

                     'x_phone' => substr($order->customer['telephone'], 0, 25),

                     'x_cust_id' => substr($customer_id, 0, 20),

                     'x_customer_ip' => tep_get_ip_address(),

                     'x_email' => substr($order->customer['email_address'], 0, 255),

                     'x_description' => substr(STORE_NAME, 0, 255),

                     'x_amount' => substr($this->format_raw($order->info['total']), 0, 15),

                     'x_currency_code' => substr($currency, 0, 3),

                     'x_method' => 'CC',

                     'x_type' => ((MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD == 'Capture') ? 'AUTH_CAPTURE' : 'AUTH_ONLY'),

                     'x_card_num' => substr($_POST['cc_number_nh-dns'], 0, 22),

                     'x_exp_date' => $_POST['cc_expires_month'] . $_POST['cc_expires_year'],

                     'x_card_code' => substr($_POST['cc_cvc_nh-dns'], 0, 4));



     if (is_numeric($sendto) && ($sendto > 0)) {

       $params['x_ship_to_first_name'] = substr($order->delivery['firstname'], 0, 50);

       $params['x_ship_to_last_name'] = substr($order->delivery['lastname'], 0, 50);

       $params['x_ship_to_company'] = substr($order->delivery['company'], 0, 50);

       $params['x_ship_to_address'] = substr($order->delivery['street_address'], 0, 60);

       $params['x_ship_to_city'] = substr($order->delivery['city'], 0, 40);

       $params['x_ship_to_state'] = substr($order->delivery['state'], 0, 40);

       $params['x_ship_to_zip'] = substr($order->delivery['postcode'], 0, 20);

       $params['x_ship_to_country'] = substr($order->delivery['country']['title'], 0, 60);

     }



     if (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE == 'Test') {

       $params['x_test_request'] = 'TRUE';

     }



     $tax_value = 0;



     foreach ($order->info['tax_groups'] as $key => $value) {

       if ($value > 0) {

         $tax_value += $this->format_raw($value);

       }

     }



     if ($tax_value > 0) {

       $params['x_tax'] = $this->format_raw($tax_value);

     }



     $params['x_freight'] = $this->format_raw($order->info['shipping_cost']);



     $post_string = '';



     foreach ($params as $key => $value) {

       $post_string .= $key . '=' . urlencode(trim($value)) . '&';

     }



     $post_string = substr($post_string, 0, -1);



     for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

       $post_string .= '&x_line_item=' . urlencode($i+1) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 31)) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 255)) . '<|>' . urlencode($order->products[$i]['qty']) . '<|>' . urlencode($this->format_raw($order->products[$i]['final_price'])) . '<|>' . urlencode($order->products[$i]['tax'] > 0 ? 'YES' : 'NO');

     }



     switch (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER) {

       case 'Live':

         $gateway_url = 'https://secure.authorize.net/gateway/transact.dll';

         break;



       default:

         $gateway_url = 'https://test.authorize.net/gateway/transact.dll';

         break;

     }



     $transaction_response = $this->sendTransactionToGateway($gateway_url, $post_string);



     if (!empty($transaction_response)) {

       $regs = preg_split("/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/", $transaction_response);



       foreach ($regs as $key => $value) {

         $regs[$key] = substr($value, 1, -1); // remove double quotes

       }

     } else {

       $regs = array('-1', '-1', '-1');

     }



     $error = false;



     if ($regs[0] == '1') {

       if (tep_not_null(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH)) {

         if (strtoupper($regs[37]) != strtoupper(md5(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH . MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID . $regs[6] . $this->format_raw($order->info['total'])))) {

           $error = 'general';

         }

       }

     } else {

       switch ($regs[2]) {

         case '7':

           $error = 'invalid_expiration_date';

           break;



         case '8':

           $error = 'expired';

           break;



         case '6':

         case '17':

         case '28':

           $error = 'declined';

           break;



         case '78':

           $error = 'cvc';

           break;



         default:

           $error = 'general';

           break;

       }

     }



     if ($error != false) {

       tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . $error, 'SSL'));

     }

   }



   function after_process() {

     return false;

   }



   function get_error() {

     global $_GET;



     $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_GENERAL;



     switch ($_GET['error']) {

       case 'invalid_expiration_date':

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_INVALID_EXP_DATE;

         break;



       case 'expired':

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_EXPIRED;

         break;



       case 'declined':

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_DECLINED;

         break;



       case 'cvc':

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_CVC;

         break;



       default:

         $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_GENERAL;

         break;

     }



     $error = array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_TITLE,

                    'error' => $error_message);



     return $error;

   }



   function check() {

     if (!isset($this->_check)) {

       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS'");

       $this->_check = tep_db_num_rows($check_query);

     }

     return $this->_check;

   }



   function install() {

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Authorize.net Credit Card AIM', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS', 'False', 'Do you want to accept Authorize.net Credit Card AIM payments?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Login ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID', '', 'The login ID used for the Authorize.net service', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Transaction Key', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY', '', 'Transaction key used for encrypting data', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('MD5 Hash', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH', '', 'The MD5 hash value to verify transactions with', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Server', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER', 'Live', 'Perform transactions on the live or test server. The test server should only be used by developers with Authorize.net test accounts.', '6', '0', 'tep_cfg_select_option(array(\'Live\', \'Test\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Mode', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE', 'Live', 'Transaction mode used for processing orders', '6', '0', 'tep_cfg_select_option(array(\'Live\', \'Test\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Method', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD', 'Authorization', 'The processing method to use for each transaction.', '6', '0', 'tep_cfg_select_option(array(\'Authorization\', \'Capture\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('cURL Program Location', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL', '/usr/bin/curl', 'The location to the cURL program application.', '6', '0' , now())");

   }



   function remove() {

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

   }



   function keys() {

     return array('MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL');

   }



   function _hmac($key, $data) {

     if (function_exists('mhash') && defined('MHASH_MD5')) {

       return bin2hex(mhash(MHASH_MD5, $data, $key));

     }



// RFC 2104 HMAC implementation for php.

// Creates an md5 HMAC.

// Eliminates the need to install mhash to compute a HMAC

// Hacked by Lance Rushing



     $b = 64; // byte length for md5

     if (strlen($key) > $B) {

       $key = pack("H*",md5($key));

     }



     $key = str_pad($key, $b, chr(0x00));

     $ipad = str_pad('', $b, chr(0x36));

     $opad = str_pad('', $b, chr(0x5c));

     $k_ipad = $key ^ $ipad ;

     $k_opad = $key ^ $opad;



     return md5($k_opad . pack("H*",md5($k_ipad . $data)));

   }



   function sendTransactionToGateway($url, $parameters) {

     $server = parse_url($url);



     if (isset($server['port']) === false) {

       $server['port'] = ($server['scheme'] == 'https') ? 443 : 80;

     }



     if (isset($server['path']) === false) {

       $server['path'] = '/';

     }



     if (isset($server['user']) && isset($server['pass'])) {

       $header[] = 'Authorization: Basic ' . base64_encode($server['user'] . ':' . $server['pass']);

     }



     if (function_exists('curl_init')) {

       $curl = curl_init($server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : ''));

       curl_setopt($curl, CURLOPT_PORT, $server['port']);

       curl_setopt($curl, CURLOPT_HEADER, 0);

       curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

       curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

       curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);

       curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);

       curl_setopt($curl, CURLOPT_POST, 1);

       curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters);



       $result = curl_exec($curl);



       curl_close($curl);

     } else {

       exec(escapeshellarg(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL) . ' -d ' . escapeshellarg($parameters) . ' "' . $server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : '') . '" -P ' . $server['port'] . ' -k', $result);

       $result = implode("\n", $result);

     }



     return $result;

   }



// format prices without currency formatting

   function format_raw($number, $currency_code = '', $currency_value = '') {

     global $currencies, $currency;



     if (empty($currency_code) || !$this->is_set($currency_code)) {

       $currency_code = $currency;

     }



     if (empty($currency_value) || !is_numeric($currency_value)) {

       $currency_value = $currencies->currencies[$currency_code]['value'];

     }



     return number_format(tep_round($number * $currency_value, $currencies->currencies[$currency_code]['decimal_places']), $currencies->currencies[$currency_code]['decimal_places'], '.', '');
   }
 }
?>

 

Steve

Hmmm, I don't have that one. I will have to see if I can scrounge up a English language file to go with it.

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

Hmmm, I don't have that one. I will have to see if I can scrounge up a English language file to go with it.

I found the payment module specified here http://addons.oscommerce.com/info/5662 and installed substituting the file as you suggested and the payment method now sets correctly. I will test with some transactions, if all is well I will not need to post again, so I would like to thank you now.

Merry Christmas Steve and Thanks a mint, this was much quicker than figuring out why the other Authorize.net module didn't work.

-Jason

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

Hi use authorizenet_cc_aim.php

 

and replace code in that file with this code

 

Steve

 

Steve,

Thanks for the tip I am finished testing and at least in test mode everything appears to work as designed. I did remember however, why I wasn't using this particular Authorize.net payment module; this module has no way to turn off customer notifications from Authorize.net (we send HTML equivalents from osC directly) and this module stores the entire credit card number in the osC db. To make this arrangement PCI compliant I would have to change my server environment.

Does anybody know if the Authorize.net notifications can be turned off from the merchant control panel at the Authorize.net website or a simple way to make this module request that no e-mail notification be sent to the customer directly from Authorize.net for each transaction the way that the authorizenet_aim.php module does? I am sure I can modify this module to x out the middle digits of the cc number, but I sure wish the other Authorize.net modules worked with OPC. The authoriznet.php module even has the ability to select which credit card types you want to accept and does echeck.net. Though I understand that particular module has some licensing issue that restricts how it can be distributed.

Thanks,

Jason

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

I'm no Java pro, but this seems to do the trick:

 

In checkout.php, find:

	if (updateTotals == true){
		       onePage.updateOrderTotals();
		  }

This is around line 453.

 

Add right after:

 

javascript:location.reload(true);

 

I wanted to add my experience with this issue. I've been integrating onepage checkout with my county tax mod. I had everything working correctly without using SSL even the login popup. When I started testing using SSL I noticed the problem with the login popup. As soon as I logged in my cart was dumped. The above code does work but breaks Google Chrome. You get a popup about the billing address. I've seen other posts about this issue. I don't think this is a javascript problem. The reason the cart is dumped is because there is no customer_id. I've verified that the login code in the onepage checkout class does work. My server has php 5.3. I've had to recode many things to make my site php 5.3 compatibile. My suspicion is that this behavior may be related to how php 5.3 handles session data when going from non-ssl to ssl, but this is just a guess. What I would like to know is how many of you having this problem have a server using php 5.3.

 

In the mean time, I have a slightly better solution then the above that works with Google Chrome.

 

In checkout.php around line 418:

 

Replace this:

 

success: function (data){

if (data.success == true){

$('#loginStatus', $dialog).html(data.msg);

$('#logInRow').hide();

 

$('#changeBillingAddressTable').show();

$('#changeShippingAddressTable').show();

$('#newAccountEmail').remove();

$('#diffShipping').parent().parent().parent().remove();

 

onePage.updateAddressHTML('billing');

onePage.updateAddressHTML('shipping');

 

$('#shippingAddress').show();

 

var updateTotals = true;

onePage.updateCartView();

onePage.updateFinalProductListing();

onePage.updatePaymentMethods();

if ($(':radio[name=payment]:checked').size() > 0){

onePage.setPaymentMethod($(':radio[name=payment]:checked'));

updateTotals = false;

}

onePage.updateShippingMethods();

if ($(':radio[name=shipping]:checked').size() > 0){

//onePage.setShippingMethod($(':radio[name=shipping]:checked').val());

onePage.setShippingMethod($(':radio[name=shipping]:checked'));

updateTotals = false;

}

 

if (updateTotals == true){

onePage.updateOrderTotals();

}

 

With this:

success: function (data){

if (data.success == true){

$('#loginStatus', $dialog).html(data.msg);

$('#logInRow').hide();

 

$('#changeBillingAddressTable').show();

$('#changeShippingAddressTable').show();

$('#newAccountEmail').remove();

$('#diffShipping').parent().parent().parent().remove();

 

//onePage.updateAddressHTML('billing');

//onePage.updateAddressHTML('shipping');

 

$('#shippingAddress').show();

 

var updateTotals = true;

//onePage.updateCartView();

//onePage.updateFinalProductListing();

//onePage.updatePaymentMethods();

//if ($(':radio[name=payment]:checked').size() > 0){

// onePage.setPaymentMethod($(':radio[name=payment]:checked'));

// updateTotals = false;

//}

//onePage.updateShippingMethods();

//if ($(':radio[name=shipping]:checked').size() > 0){

//onePage.setShippingMethod($(':radio[name=shipping]:checked').val());

// onePage.setShippingMethod($(':radio[name=shipping]:checked'));

// updateTotals = false;

//}

 

//if (updateTotals == true){

// onePage.updateOrderTotals();

//}

location.reload(); // login problem kludge reload will do above

 

 

This works fine on my site. When it reloads, it does everything that was commented. I consider this a kludge and would like to get to the root of this problem. This behavior only occurs on my site if I use ssl. When I did my initial testing I was not using ssl and the login worked perfectly which is why I don't think it is the javascript. I hope this info is helpful.

 

Gary

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