Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Authorize.net post string example for cURL

Posted on 2009-04-02
1
Medium Priority
?
942 Views
Last Modified: 2013-11-18
Long story short, we have to use cURL command line to send a AUTH request to Authorize.net to pre-auth credit card transactions.  Does anyone have an example of what the post string should look like?  Are there existing scripts already written?

Thanks, Jay
0
Comment
Question by:jaygraves
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 51

Accepted Solution

by:
Steve Bink earned 1500 total points
ID: 24066306
You mean something like this?  This code was written in PHP.

You'll likely want to use this manual along with the example code:

http://www.authorize.net/support/AIM_guide.pdf
http://www.authorize.net/support/CNP/helpfiles/
<?
// ... more code up here to set up order processing, etc.
 
// set a test mode?
$x_Test = "FALSE";
if (usr_GLOBALS_TESTMODE) { $x_Test='TRUE'; }
 
$hashval = "Authorize.NET Customer HASH";
$x_Login="Authorize.NET Customer Login#";
$x_Delim_Data="TRUE";
$x_Delim_Char="|";
$x_Encap_Char="";
$x_Type="AUTH_ONLY";
// customer fields
$x_Method="CC";
$x_Tran_Key = "Authorize.NET Transaction Key";
$x_Amount = sprintf("%1.2f","Amount to charge");
$x_FName = "Customer First Name";
$x_LName = "Customer Last Name";
$x_Company = "Customer Company Name";
$x_Address = "Customer Address";
$x_City = "Customer City";
$x_State = "Customer State";
$x_Zip = "Customer Zip";
$x_Phone = "Customer Phone Number";
$x_Card_Num = "Customer Card Number";
// Customer's Card Expiration Date...specific format!
$x_Exp_Date = date("m/y", mktime(0, 0, 1, $expmonth, 1, $expyear));
$x_CVV = "Customer CVV Code";
 
 
/*
Unused fields:
x_tax:#:sales tax, 0.00 formatted
x_customer_ip:15:????????????????
x_description:255:description field...hrrmmm.....
*/
 
// standard fields
$fields = "x_version=3.1&x_delim_data=$x_Delim_Data&x_delim_char=$x_Delim_Char&" .
		"x_encap_char=$x_Encap_Char&x_type=$x_Type&x_method=$x_Method&x_duplicate_window=300&" .
		"x_country=US&x_email_customer=FALSE&";
 
// customized fields
$fields .= "x_login=$x_Login&x_tran_key=$x_Tran_Key&x_test_request=$x_Test&" .
					"x_first_name=$x_FName&x_last_name=$x_LName&x_address=$x_Address&" .
					"x_city=$x_City&x_state=$x_State&x_zip=$x_Zip&x_company=$x_Company&" .
					"x_phone=$x_Phone&x_cust_id=$custid&x_invoice_num=$orderid&" .
					"x_amount=$x_Amount&x_card_num=$x_Card_Num&x_exp_date=$x_Exp_Date&" .
					"x_card_code=$x_CVV";
 
// execute CURL session to authorize.net, return in $details
$ch = curl_init("https://secure.authorize.net/gateway/transact.dll");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($ch);
curl_close($ch);
// get the returned array, and set up for the hash check.
$details = explode($x_Delim_Char,$buffer);
 
// details is now an array of the return
?>

Open in new window

0

Featured Post

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The online market is growing at an unprecedented rate and retail eCommerce sales are expected to reach $4 trillion by 2020. Yet, the profit is not just there for the taking because you have to set yourself apart from the competition.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question