Jump to content

Using Authorize.net gateway with 2CO


Guest lcools

Recommended Posts

Guest lcools

To follow up on the idea of using the Authorize.net gateway for processing through 2CO....

If you use 2CO, you can use the Authorize.net gateway module instead of the 2CO gateway module. With the 2CO module, customers can change item amounts after leaving your shopping cart (while paying 2CO), which can lead to some confusion /overshipped and undershipped orders etc.

To use Authorize.net, set up the Authorize.net gateway (accessible from your admin) by putting in your 2CO member number. You do not need to add anything else or transaction key as far as I know.

You do need to edit the bottom of you transfer.php file (in the authorize.net gateway folder)

Change the bit at the bottom of the file to:

///////////////////////////

// Other Vars

////////

if($module['testMode']==1){

$formAction = "https://www.2checkout.com/2co/buyer/purchase";

} else {

$formAction = "https://www.2checkout.com/2co/buyer/purchase";

}

$formMethod = "post";

$formTarget = "_self";

$transfer = "auto";

$stateUpdate = FALSE;

?>

Make a copy of the confirmed.php (also in the authorize gateway folder) and put it in your shop's root folder.

And on the 2CO website, put the return url in both boxes (in the admin Look and Feel section) if you have not already done this:

http://www.yoursite.com/confirmed.php

or

https://www.yoursite.com/confirmed.php

-whichever applies.

I hope that helps. I hope I typed that all right.

I got these instructions from a generous fellow Cubecart user.

Link to comment
Share on other sites

  • 2 weeks later...

Guest hennaboy

To follow up on the idea of using the Authorize.net gateway for processing through 2CO....

If you use 2CO, you can use the Authorize.net gateway module instead of the 2CO gateway module. With the 2CO module, customers can change item amounts after leaving your shopping cart (while paying 2CO), which can lead to some confusion /overshipped and undershipped orders etc.

To use Authorize.net, set up the Authorize.net gateway (accessible from your admin) by putting in your 2CO member number. You do not need to add anything else or transaction key as far as I know.

You do need to edit the bottom of you transfer.php file (in the authorize.net gateway folder)

Change the bit at the bottom of the file to:

///////////////////////////

// Other Vars

////////

if($module['testMode']==1){

$formAction = "https://www.2checkout.com/2co/buyer/purchase";

} else {

$formAction = "https://www.2checkout.com/2co/buyer/purchase";

}

$formMethod = "post";

$formTarget = "_self";

$transfer = "auto";

$stateUpdate = FALSE;

?>

Make a copy of the confirmed.php (also in the authorize gateway folder) and put it in your shop's root folder.

And on the 2CO website, put the return url in both boxes (in the admin Look and Feel section) if you have not already done this:

http://www.yoursite.com/confirmed.php

or

https://www.yoursite.com/confirmed.php

-whichever applies.

I hope that helps. I hope I typed that all right.

I got these instructions from a generous fellow Cubecart user.

Having a problem with this..... followed your instructions and when you order and complete the transaction in 2co tries loads a page with a single url on it

http://www.henna-boy.co.uk/upload/confirme...pg=QXV0aG9yaXpl

I assume that the variables after the php is the order number

The problem is that the page just continously refreshes itself and nothing actually happens.

So....

here is my settings....

Cubecart Admin Authorize enabled. ID setup correctly....

Relay response url in cubecart admin is set to http://www.henna-boy.co.uk/upload/confirmed.php

2CO settings

return url on both settings is set to http://www.henna-boy.co.uk/upload/confirmed.php

After i followed your instructions and changed the authorize transfer file and then uploaded it into the root directory uploaded the confirmed file taken from the Authorize gatweay module. Then errors occured due to the include files not being specified correctly....so this is my changed confirmed.php file

<?php

/*

+--------------------------------------------------------------------------

|   CubeCart v3.0.10

|   ========================================

|   by Alistair Brookbanks

|	CubeCart is a Trade Mark of Devellion Limited

|   Copyright Devellion Limited 2005 - 2006. All rights reserved.

|   Devellion Limited,

|   22 Thomas Heskin Court,

|   Station Road,

|   Bishops Stortford,

|   HERTFORDSHIRE.

|   CM23 3EE

|   UNITED KINGDOM

|   http://www.devellion.com

|	UK Private Limited Company No. 5323904

|   ========================================

|   Web: http://www.cubecart.com

|   Date: Tuesday, 14th March 2006

|   Email: info (at) cubecart (dot) com

|	License Type: CubeCart is NOT Open Source Software and Limitations Apply 

|   Licence Info: http://www.cubecart.com/site/faq/license.php

+--------------------------------------------------------------------------

|	confirmed.php

|   ========================================

|	Order Confirmation

+--------------------------------------------------------------------------

*/

if(!isset($_POST['x_invoice_num']) && !isset($_POST['x_amount'])){

	echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";

	exit;

}



	include_once("includes/ini.inc.php");

	

	// INCLUDE CORE VARIABLES & FUNCTIONS

	include_once("includes/global.inc.php");

	$enableSSl = 1;

	

	// initiate db class

	include_once("classes/db.inc.php");

	$db = new db();

	

	include_once("includes/functions.inc.php");

	$config = fetchDbConfig("config");

	

	include_once("includes/sslSwitch.inc.php");

	

	include_once("includes/session.inc.php");

	// get exchange rates etc

	include_once("includes/currencyVars.inc.php");

	

	include_once("language/".$config['defaultLang']."/lang.inc.php");



// WORK OUT IS THE ORDER WAS SUCCESSFULL OR NOT;)



// 1. Include gateway file



include("transfer.inc.php");



// 2. Include function which returns ture or false



$success = successFirst();

	

	if($success == TRUE){

		

		$cart_order_id = $_POST['x_invoice_num'];

		include_once("includes/orderSuccess.inc.php");

		$result = "?pg=".base64_encode("Authorize");

		

	} else {

		

		$result = "?f=1&pg=".base64_encode("Authorize");

		

	}

	

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charsetIso;?>" />

<title>Redirecting...</title>

<meta http-equiv="refresh" content="0;URL=<?php echo $GLOBALS['storeURL']."/confirmed.php".$result; ?>" />

</head>

<body>

<p align="center"><a href="<?php echo $GLOBALS['storeURL']."/confirmed.php".$result; ?>"><?php echo $GLOBALS['storeURL']; ?></a></p>

<?php 



if($success == TRUE){

		

	// add affilate tracking code/module

	$affiliateModule = $db->select("SELECT folder, `default` FROM ".$glob['dbprefix']."CubeCart_Modules WHERE module='affiliate' AND status = 1");



	if($affiliateModule == TRUE) {

	

		for($i=0; $i<count($affiliateModule); $i++){

			

			include("modules/affiliate/".$affiliateModule[$i]['folder']."/tracker.inc.php");

			// VARS AVAILABLE

			// Order Id Number $basket['cart_order_id']

			// Order Total $order[0]['prod_total']

			$basket['cart_order_id'] = $_POST['x_invoice_num'];

			$order[0]['prod_total'] = $_POST['x_amount'];

			echo $affCode;

		

		}

	

	}

		

}



?>

</body>

</html>




The next error i got was that a transfer inc file could not be found.... i checked over the code and yes on line 60 it asks for the transfer inc file. So i uploaded that into the root directory also.



But there is a problem in that the page just continously refreshes itself...something to do with this section of the confirmed.php file?




<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charsetIso;?>" />

<title>Redirecting...</title>

<meta http-equiv="refresh" content="0;URL=<?php echo $GLOBALS['storeURL']."/confirmed.php".$result; ?>" />

</head>

<body>

<p align="center"><a href="<?php echo $GLOBALS['storeURL']."/confirmed.php".$result; ?>"><?php echo $GLOBALS['storeURL']; ?></a></p>




Perhaps?



I also have my transfer inc file which is like so....




<?php

/*

+--------------------------------------------------------------------------

|   CubeCart v3.0.10

|   ========================================

|   by Alistair Brookbanks

|	CubeCart is a Trade Mark of Devellion Limited

|   Copyright Devellion Limited 2005 - 2006. All rights reserved.

|   Devellion Limited,

|   22 Thomas Heskin Court,

|   Station Road,

|   Bishops Stortford,

|   HERTFORDSHIRE.

|   CM23 3EE

|   UNITED KINGDOM

|   http://www.devellion.com

|	UK Private Limited Company No. 5323904

|   ========================================

|   Web: http://www.cubecart.com

|   Date: Friday, 15 July 2005

|   Email: info (at) cubecart (dot) com

|	License Type: CubeCart is NOT Open Source Software and Limitations Apply 

|   Licence Info: http://www.cubecart.com/site/faq/license.php

+--------------------------------------------------------------------------

|	transfer.php

|   ========================================

|	Core functions for the Authorize.Net Gateway	

+--------------------------------------------------------------------------

*/

/*

//////////////////////////

// AUTHORIZE.NET GATEWAY

//////////////////////////

// L@@K AT ALL THE LOVELY 

// VARIABLES WE HAVE TO

// PLAY WITH!!

//////



//////////////////////////

// IN THE REPEATED REGION

//////

$orderInv['productId']						- product id as an integer

$orderInv['name']							- product name as a varchar

$orderInv['price']							- price of each product (inc options)

$orderInv['quantity']						- quantity of products as an integer

$orderInv['product_options']				- products attributes as test

$orderInv['productCode']					- product code as a varchar

$i											- This is the current incremented integer starting at 0



/////////////////////////

// FIXED VARS

///////

$cart_order_id							- cart order id as a varchar

$ccUserData[0]['email']						- Customers email address

$ccUserData[0]['title']						- Customers title (Mr Miss etc...)

$ccUserData[0]['firstName']					- Customers first name

$ccUserData[0]['lastName']					- Customers last name 

$ccUserData[0]['add_1']						- Invoice Address line 1

$ccUserData[0]['add_2']						- Invoice Address line 1

$ccUserData[0]['town']						- Invoice Town or city

$ccUserData[0]['county']					- Invoice County or state

$ccUserData[0]['postcode']					- Invoice Post/Zip Code

$ccUserData[0]['country']					- Invoice country Id we can look up the country name like this

										countryName($ccUserData[0]['country']);

$ccUserData[0]['phone']						- Contact phone no

$ccUserData[0]['mobile']					- Mobile/Cell phone number



$basket['delInf']['title']				- Delivery title (Mr Miss etc...)

$basket['delInf']['firstName']			- Delivery customers first name

$basket['delInf']['lastName']			- Delivery customers last name 

$basket['delInf']['add_1']				- Delivery Address line 1

$basket['delInf']['add_2']				- Delivery Address line 1

$basket['delInf']['town']				- Delivery Town or city

$basket['delInf']['county']				- Delivery County or state

$basket['delInf']['postcode']			- Delivery Post/Zip Code

$basket['delInf']['country']			- Delivery  country Id we can look up the country name like this	

									countryName($basket['delInf']['country']);





$basket['subTotal'] 					- Order Subtotal (exTax and Shipping)

$basket['grandTotal']					- Basket total which has to be paid (inc Tax and Shipping).

$basket['tax']							- Total tax to pay

$basket['shipCost']						- Shipping price

////////////////////////////////////////////////////////

*/



$module = fetchDbConfig("Authorize");



function repeatVars(){



		return FALSE;

	

}



function fixedVars(){

	

	global $module, $basket, $ccUserData, $cart_order_id, $config, $GLOBALS; 

	

	$amount = $basket['grandTotal'];



	// Trim $ sign if it exists

	if (substr($amount, 0,1) == "$") {

		$amount = substr($amount,1);

	}

	$loginid = $module['acNo'];

	$txnkey = $module['txnkey'];

	

	if(!empty($ccUserData[0]['add_2'])){



		$add = $ccUserData[0]['add_1'].", ".$ccUserData[0]['add_2'];

					

	} else {

						

		$add = $ccUserData[0]['add_1'];

					

	}

	

	// function InsertFP ($loginid, $txnkey, $amount, $sequence) - Insert HTML form elements required for SIM

	// function CalculateFP ($loginid, $txnkey, $amount, $sequence, $tstamp) - Returns Fingerprint.

	

	// compute HMAC-MD5

	// Uses PHP mhash extension. Pl sure to enable the extension

	function hmac ($key, $data)

	{

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

	}

	

	// Calculate and return fingerprint

	// Use when you need control on the HTML output

	function CalculateFP ($loginid, $txnkey, $amount, $sequence, $tstamp, $currency = "")

	{

	return (hmac ($txnkey, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency));

	}

	

	

	// Inserts the hidden variables in the HTML FORM required for SIM

	// Invokes hmac function to calculate fingerprint.

	

	function InsertFP ($loginid, $txnkey, $amount, $sequence, $currency = "")

	{

	

	$tstamp = time();

	

	$fingerprint = hmac ($txnkey, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency);

	

	$hiddenVars = "<input type='hidden' name='x_fp_sequence' value='" . $sequence . "' />

					<input type='hidden' name='x_fp_timestamp' value='" . $tstamp . "' />

					<input type='hidden' name='x_fp_hash' value='" . $fingerprint . "'/>";

	

	return $hiddenVars;

	

	}

	

	// Seed random number for security and better randomness.



	srand(time());

	$sequence = rand(1, 1000);

	// Insert the form elements required for SIM by calling InsertFP		

	

	$hiddenVars = InsertFP ($loginid, $txnkey, $amount, $sequence, $config['defaultCurrency'])."

					<input type='hidden' name='x_login' value='".$loginid."' />

					<input type='hidden' name='x_currency_code' value='" . $config['defaultCurrency'] . "' />

					<input type='hidden' name='x_show_form' value='PAYMENT_FORM' />

					<input type='hidden' name='x_amount' value='".$amount."' />

					<input type='hidden' name='x_cust_id' value='".substr(strtoupper($ccUserData[0]['lastName']),0,4).$ccUserData[0]['customer_id']."' />

					<input type='hidden' name='x_description' value='Cart - ".$cart_order_id."' />

					<input type='hidden' name='x_invoice_num' value='".$cart_order_id."' />

					<input type='hidden' name='x_first_name' value='".$ccUserData[0]['firstName']."' />

					<input type='hidden' name='x_last_name' value='".$ccUserData[0]['lastName']."' />

					<input type='hidden' name='x_relay_response' value='TRUE' />

					<input type='hidden' name='x_relay_url' value='".$GLOBALS['storeURL']."/modules/gateway/Authorize/confirmed.php' />

					<input type='hidden' name='x_address' value='".$add."' />

					<input type='hidden' name='x_city' value='".$ccUserData[0]['town']."' />

					<input type='hidden' name='x_state' value='".$ccUserData[0]['county']."' />

					<input type='hidden' name='x_zip' value='".$ccUserData[0]['postcode']."' />

					<input type='hidden' name='x_country' value='".countryIso($ccUserData[0]['country'])."' />

					<input type='hidden' name='x_phone' value='".$ccUserData[0]['phone']."' />

					<input type='hidden' name='x_email' value='".$ccUserData[0]['email']."' />

					<input type='hidden' name='x_ship_to_first_name' value='".$basket['delInf']['firstName']."' />

					<input type='hidden' name='x_ship_to_last_name' value='".$basket['delInf']['lastName']."' />

					<input type='hidden' name='x_ship_to_address' value='".$basket['delInf']['add_1']." ".$basket['delInf']['add_2']."' />

					<input type='hidden' name='x_ship_to_city' value='".$basket['delInf']['town']."' />

					<input type='hidden' name='x_ship_to_state' value='".$basket['delInf']['county']."' />

					<input type='hidden' name='x_ship_to_zip' value='".$basket['delInf']['postcode']."' />

					<input type='hidden' name='x_ship_to_country' value='".countryIso($basket['delInf']['country'])."' />

					<input type='hidden' name='x_Customer_IP' value='".$_SERVER['REMOTE_ADDR']."' />\r\n					";



				

				if($module['testMode']==1){	

					$hiddenVars .= "<input type='hidden' name='x_test_request' value='TRUE' />";

				}

				

			return $hiddenVars;

	

}



function successFirst(){

	

	if($_POST['x_response_code']==1 && isset($_POST['x_invoice_num'])){

	

		return TRUE;

	

	} else {

	

		return FALSE;

	

	}



}



function success(){

		

		if($_GET['f']==1){

		

			return FALSE;

			

		} else {

		

			return TRUE;

			

		}	



}



///////////////////////////

// Other Vars

////////

if($module['testMode']==1){

$formAction = "https://www.2checkout.com/2co/buyer/purchase";

} else {

$formAction = "https://www.2checkout.com/2co/buyer/purchase";

}



$formMethod = "post";

$formTarget = "_self";

$transfer = "auto";

$stateUpdate = FALSE;

?>




Does anyone know if the line 




<input type='hidden' name='x_relay_url' value='".$GLOBALS['storeURL']."/modules/gateway/Authorize/confirmed.php' />

Is correct or should that be modified ?

Link to comment
Share on other sites

Guest lcools

After i followed your instructions and changed the authorize transfer file and then uploaded it into the root directory uploaded the confirmed file taken from the Authorize gatweay module.

Just to confirm..you were to edit the transfer file and leave it where it was...copy the confirmed file and put it in your root folder-then use the root address. (Perhaps also try the url with out the /uploads/)

Link to comment
Share on other sites

Guest hennaboy

Ok but what about the call to the transfer.inc.php in the confirmed.php that i have placed in the root directory (upload/ is my store root)

the authorize version of the confirmed.php has on line 60

include("transfer.inc.php");

change that to

include("modules/gateway/Authorize/transfer.inc.php");

?

Link to comment
Share on other sites

Guest STEVE33304

Hi, you should only need to to the confirmed.php, and put that in your root directory, with the aforementoined changes, everying should be then ok, always make a backup of your orig confirmed.php, when you done this you can set the return url in 2co.

alternatively, i have never done this, set the return rul direct to the authorize dir.

You will sstill need to make te fixes.

Cheers

Steve

Ok but what about the call to the transfer.inc.php in the confirmed.php that i have placed in the root directory (upload/ is my store root)

the authorize version of the confirmed.php has on line 60

include("transfer.inc.php");

change that to

include("modules/gateway/Authorize/transfer.inc.php");

?

Link to comment
Share on other sites

Guest STEVE33304

if you really get really stuk after trying and testing them then pm, but please test first. better you learn this, as if you need to do more work with cube better that you understand. And you can always put 2co in test mode

I will ask questions ;-)

Steve

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