Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

online payment

Status
Not open for further replies.

acbflores

Programmer
Nov 7, 2002
5
US
I need to create a form to do online live cc transactions with authorize.net. They use php for the integration. I'm a ColdFusion developer and know little about php... does anybody here have done a form an process with authorize.net from scratch using php code? any help or code will be appreciated... don't have much time... found some files on their site but information is all over...

Thank you very much.
 
My solution uses CURL. You must have OpenSSL support compiled into CURL to connect via HTTPS.

Code:
$postfields  = 'x_Version=3.0&x_Login=<your merchant login here>&x_ADC_Delim_Data=true&x_ADC_URL=false&';
$postfields .= 'x_Amount='.$purchase_amount.'&';
$postfields .= 'x_Card_Num='.$cc_number.'&';
$postfields .= 'x_Exp_Date='.$cc_expiration.'&';
$postfields .= 'x_Address='.$purchaser_address.'&';
$postfields .= 'X_Zip='.$purchaser_zip.'&';
$postfields .= 'x_Type=AUTH_CAPTURE';
	
$curl_handle = curl_init (&quot;[URL unfurl="true"]https://secure.authorize.net/gateway/transact.dll&quot;);[/URL]

curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $postfields);
		
$result = curl_exec ($curl_handle) or die (&quot;There has been an error contacting the transaction system&quot;);
	
curl_close ($curl_handle);
	
$result_fields = split (&quot;:&quot;, $result);

Some notes:
The return from curl_exec(), normally a boolean, is instead the return response from the foreign server when CURLOPT_RETURNTRANSFER is set to 1.

The actual format if the return is set in Authorize.net's Advanced Integration Method Implementation Guide ( on page 20. The actual character used to separate the fields defaults to a comma, but can be set to any character in your merchant account page at Authorize.net. We're using a colon.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
I still can't make it work... I'm hard-coding the variables but don't get any output:
<?
$postfields = 'x_Version=3.0&x_Login=MYACCOUNT&x_ADC_Delim_Data=true&x_ADC_URL=false&';
$postfields .= 'x_Amount='.$27.'&';
$postfields .= 'x_Card_Num='.$4222222222222.'&';
$postfields .= 'x_Exp_Date='.$04/04.'&';
$postfields .= 'x_Address='.$444 w test.'&';
$postfields .= 'X_Zip='.$90210.'&';
$postfields .= 'x_Type=AUTH_CAPTURE';

$curl_handle = curl_init (&quot;
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $postfields);

$result = curl_exec ($curl_handle) or die (&quot;There has been an error contacting the transaction system&quot;);



curl_close ($curl_handle);

$result_fields = split (&quot;:&quot;, $result);


print(&quot;Thank you&quot; . &quot; &quot; . $_POST['result_fields'] . &quot;<BR>&quot;);
?>

There are no debug messages on php....
could you please tell me what I'm doing wrong...


Thank you very much for your prompt responce on this matter.....
 
Have you set up the colon as a return field separator in your merchant account settings? If not, split() may not be working as you expect because colon is not the default separator. I don't remember what the default separator is -- the AIM documentation will tell you.

What's in $result?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top