techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old Jul 24, 2012, 05:12 PM   #1
Msap14
75 Posts
 
Msap14's Avatar
 
Join Date: Nov 2008
Location: US
Posts: 150 (0.09/day)
Thanks: 14
Thanked 10 Times in 6 Posts

System Specs

Authorize.net

hello,

i have never set up a website that took credit cards before, and i am self taught most of my website programming knowledge.

I am going through authorize.net, and what i need to do is take registrations for an event. I just want a simple checkout feature, that is all on the same page, no cart or anything, just type in the info, and click submit.

The only thing i know how to do, is create a table, with name forms and all that. i need help getting the information from the form, to actually charging the cards.

Can anyone help me with this? What information do you need to help me?
__________________
Heatware
Msap14 is offline  
Reply With Quote
Old Jul 24, 2012, 05:39 PM   #2
Msap14
75 Posts
 
Msap14's Avatar
 
Join Date: Nov 2008
Location: US
Posts: 150 (0.09/day)
Thanks: 14
Thanked 10 Times in 6 Posts

System Specs

Sample code from authorize.net

Code:
<?PHP

// By default, this sample code is designed to post to our test server for
// developer accounts: https://test.authorize.net/gateway/transact.dll
// for real accounts (even in test mode), please make sure that you are
// posting to: https://secure.authorize.net/gateway/transact.dll
$post_url = "https://test.authorize.net/gateway/transact.dll";

$post_values = array(
	
	// the API Login ID and Transaction Key must be replaced with valid values
	"x_login"			=> "API_LOGIN_ID",
	"x_tran_key"		=> "TRANSACTION_KEY",

	"x_version"			=> "3.1",
	"x_delim_data"		=> "TRUE",
	"x_delim_char"		=> "|",
	"x_relay_response"	=> "FALSE",

	"x_type"			=> "AUTH_CAPTURE",
	"x_method"			=> "CC",
	"x_card_num"		=> "4111111111111111",
	"x_exp_date"		=> "0115",

	"x_amount"			=> "19.99",
	"x_description"		=> "Sample Transaction",

	"x_first_name"		=> "John",
	"x_last_name"		=> "Doe",
	"x_address"			=> "1234 Street",
	"x_state"			=> "WA",
	"x_zip"				=> "98004"
	// Additional fields can be added here as outlined in the AIM integration
	// guide at: http://developer.authorize.net
);

// This section takes the input fields and converts them to the proper format
// for an http post.  For example: "x_login=username&x_tran_key=a1B2c3D4"
$post_string = "";
foreach( $post_values as $key => $value )
	{ $post_string .= "$key=" . urlencode( $value ) . "&"; }
$post_string = rtrim( $post_string, "& " );

// The following section provides an example of how to add line item details to
// the post string.  Because line items may consist of multiple values with the
// same key/name, they cannot be simply added into the above array.
//
// This section is commented out by default.
/*
$line_items = array(
	"item1<|>golf balls<|><|>2<|>18.95<|>Y",
	"item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y",
	"item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y");
	
foreach( $line_items as $value )
	{ $post_string .= "&x_line_item=" . urlencode( $value ); }
*/

// This sample code uses the CURL library for php to establish a connection,
// submit the post, and record the response.
// If you receive an error, you may want to ensure that you have the curl
// library enabled in your php configuration
$request = curl_init($post_url); // initiate curl object
	curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
	curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
	curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
	curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
	$post_response = curl_exec($request); // execute curl post and store results in $post_response
	// additional options may be required depending upon your server configuration
	// you can find documentation on curl options at http://www.php.net/curl_setopt
curl_close ($request); // close curl object

// This line takes the response and breaks it into an array using the specified delimiting character
$response_array = explode($post_values["x_delim_char"],$post_response);

// The results are output to the screen in the form of an html numbered list.
echo "<OL>\n";
foreach ($response_array as $value)
{
	echo "<LI>" . $value . "&nbsp;</LI>\n";
}
echo "</OL>\n";
// individual elements of the array could be accessed to read certain response
// fields.  For example, response_array[0] would return the Response Code,
// response_array[2] would return the Response Reason Code.
// for a list of response fields, please review the AIM Implementation Guide
?>
and this is card present that sends a transaction to the payment gateway

Code:
<?php
require_once 'anet_php_sdk/AuthorizeNet.php'; // Make sure this path is correct.
$transaction = new AuthorizeNetCP('YOUR_API_LOGIN_ID', 'YOUR_TRANSACTION_KEY');
$transaction->amount = '9.99';
$transaction->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?');
$transaction->device_type = '4';
$response = $transaction->authorizeAndCapture();

if ($response->approved) {
  echo "<h1>Success! The test credit card has been charged!</h1>";
  echo "Transaction ID: " . $response->transaction_id;
} else {
  echo $response->error_message;
}
?>
does this mean that when i make a form, for each field i choose id="x_card_num" for example? then the submit button linked to the card present somehow complete transaction?
__________________
Heatware
Msap14 is offline  
Reply With Quote
Old Jul 26, 2012, 04:17 PM   #3
Jizzler
2000 Posts
 
Jizzler's Avatar
 
Join Date: Aug 2007
Location: Geneva, FL, USA
Posts: 3,010 (1.43/day)
Thanks: 567
Thanked 606 Times in 487 Posts

System Specs

Have you found a solution to this, or do you still need help?
Jizzler is offline  
Reply With Quote
Old Jul 26, 2012, 08:46 PM   #4
Msap14
75 Posts
 
Msap14's Avatar
 
Join Date: Nov 2008
Location: US
Posts: 150 (0.09/day)
Thanks: 14
Thanked 10 Times in 6 Posts

System Specs

not quite

i haven't figured it out 100% yet, what i did so far is turned the site into a joomla site, then installed virtuemart as a checkout system, not sure how it will play out, but i will make it work somehow.
__________________
Heatware
Msap14 is offline  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
networkstream vb.net shuggans Programming & Webmastering 5 Oct 2, 2011 08:39 PM
Net Died But It's Not The Net CrAsHnBuRnXp Networking & Security 2 Oct 5, 2008 09:16 PM
Asp.net 2.0 Wastedslayer Programming & Webmastering 0 Jun 17, 2007 08:06 PM
VB.net - Help! new_rez General Software 13 Feb 28, 2007 01:26 PM


All times are GMT. The time now is 01:32 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
no new posts