the bofe blog

a twenty something IT professional with a few things to say

Archive for December 2006

links for 2006-12-30

with 3 comments

Written by bofe

December 30, 2006 at 14:20

Posted in Uncategorized

Tagged with

links for 2006-12-30

without comments

Written by bofe

December 30, 2006 at 05:23

Posted in Uncategorized

Tagged with

links for 2006-12-29

without comments

Written by bofe

December 29, 2006 at 14:21

Posted in Uncategorized

Tagged with

Phasing out the Linkrolls

with 3 comments

Instead of having the linkrolls take up the huge chunk of real-estate on each page, I’m experimenting with delicious’ XML-RPC posting interface.

I’ll let you know how it goes =)

Written by bofe

December 29, 2006 at 11:26

Posted in Personal

Tagged with , , ,

Let’s go Skydiving (clap clap-clapclapclap)

without comments

I came across the Kentucky Skydiving Center on Google today. When I was in KC I really wanted to try some Skydiving. I’ll give it a try now that I’m back in KY.

I’d really like to wait until later in the year – maybe coordinate some other readers/friends to go along, too. None of that tandem business, though. I want to solo jump. Prices:

  • $129
  • $Gas to Drive to Frankfort
  • $66 for a video (which would obviously be posted to YouTube!)

Anyone want to go?

Written by bofe

December 29, 2006 at 11:03

Posted in Personal

Tagged with

Authorizing and Capturing Credit Card Transactions with Authorize.net and PHP/MySQL

with one comment

This is a quick guide intended for anyone who wants to make some money online. I will be covering the Authorize.net Advanced Integration Method (AIM) which is fully documented elsewhere. Their documentation is excellent, but it does little for PHP/MySQL.

Things you will need:

  • A server with PHP/MySQL and cURL
  • An Authorize.net merchant account. Not a Merchant? Contact Authorize.
  • An SSL certificate on the server you’re using
  • A basic understanding of PHP and cURL

Step 0: Terminology

  • Validate – before we go out and hit Authorize.net we need to make every effort to ensure the data we sent them is valid. This involves basic input validation and taking the credit card number through what is called the Luhn algorithm (wikipedia link contains a sample PHP function)
  • Authorize – verify that the card could be charged for an amount.
  • Capture – actually charge the card a specified amount.
  • Transaction – completion of at least the authorization step
  • PCI Compliance – PCI stands for Payment Cardholder Institute. It’s basically a consortium of American Express, JCB, MasterCard, and VISA International who have set forth security guidelines that developers must be privvy to in order to legally store customer payment data.

Step 1: Preparing the Data

The required fields for a successful Authorize.net Credit Card transaction are:

  • x_login (constant, authorize.net will provide this)
  • x_tran_key (constant, authorize.net will provide this)
  • x_delim_data (x_delim_char, x_encap_char) – you can specify how Authorize.NET returns data to you. The delimiting character I used was ”|” and the encapsulating characters I used were “”. So my data would look like: “1”|”The transaction was approved.”
  • x_amount – an amount. No dollar sign. 00.00
  • x_method – set this to “CC”.
  • x_type – Defaults to AUTH_CAPTURE. Depending on your business needs you may/may not want to Authorize and Capture on the spot. Check the documentation for other settings.
  • x_card_num – the Luhn validated credit card number.
  • x_exp_date – card’s expiration date. A variety of formats will work. I’m partial to MM-YYYY. PHP date(“m-Y”, $exp_date).
  • x_card_code – CVV code

You’ll want to gather all of this data into a POST string, like this one:

x_login=abc&x_tran_key=123…&x_card_code=234

This can be done a variety of ways in PHP. From an example gotten at Authorize.net:

$authnet_values= array
(
“x_login”=> $auth_net_login_id,
“x_version”=> “3.1″,
“x_delim_char”=> “|”,
“x_delim_data”=> “TRUE”,
“x_url”=> “FALSE”,
“x_type”=> “AUTH_CAPTURE”,
“x_method”=> “CC”,

“x_tran_key”=> $auth_net_tran_key,
“x_relay_response”=> “FALSE”,
“x_card_num”=> “4242424242424242″,
“x_exp_date”=> “1203″,
“x_description”=> “Recycled Toner Cartridges”,
“x_amount”=> “12.23″,
“x_first_name”=> “Charles D.”,
“x_last_name”=> “Gaulle”,
“x_address”=> “342 N. Main Street #150″,
“x_city”=> “Ft. Worth”,
“x_state”=> “TX”,
“x_zip”=> “12345″,
);

$fields = “”;
foreach( $authnet_values as $key => $value ) $fields .= “$key=” . urlencode( $value ) . “&”;

Step 2: Sending to Authorize.net

There are two URLs you can use to send to Authorize.net:

  1. https://certification.authorize.net/gateway/transact.dll – testing only
  2. https://secure.authorize.net/gateway/transact.dll – production only

The PHP:

$ch = curl_init(“https://certification.authorize.net/gateway/transact.dll”);
curl_setopt($ch, CURLOPT_HEADER, 0); // removes HTTP headers from response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, “& ” )); // use HTTP POST to send form data
$authorize_response = curl_exec($ch); //execute post and get results
curl_close ($ch);

Testing the transactions can be a pain.

Here are some numbers to test your transactions with:

  • Visa: 4111-1111-1111-1111
  • MasterCard: 5431-1111-1111-1111
  • Amex: 341-1111-1111-1111
  • Discover: 6011-6011-6011-6611

Step 3: Parsing Authorize’s Response

Authorize.net will send back a response to you, stored in $authorize_response. It will vary depending on the delimiters you set up in your cURL request. It should look something like this:

“X”|”XXX”|”XX”|”XX”|”X”|”X”|”X”|”X”|”X”|”X”|”X”

Again, this string depends on what you sent to Authorize.NET via cURL. You’ll now want to make heavy use of PHP’s explode function and deal with what happens in your application when there is success, failure, or other errors.

The big one is the first field you receive back. It’s referred to as “ResponseCode”. There are three different ResponseCodes—1 = Approved, 2 = Declined, 3 = Error. After you receive a ResponseCode of 1—and only after that can you consider the transaction complete and start fulfilling the order.

Read up in the Authorize.net AIM documentation for more about response codes. – It’s under “Gateway Response API”.

Authorize.net also provides sample PHP code if you’re still having trouble.

See also…

Written by bofe

December 26, 2006 at 11:12

Posted in Personal

Tagged with ,

Higher Level

with 2 comments

Since moving back to my old Kentucky home, I’ve realized what I was missing when I was in KS – the time to do “higher level” activities.

Basically in KC here’s a summary of my activities:

  1. Work & Commute (35%) – 60 hours a week (very conservative estimate – especially when external projects were going on)
  2. Sleep (29%) – 7 hours a night (again, conservative estimate)
  3. Eat (8%) – 2 hours a day, including lunch break at work (an hour for lunch at work stretches it a little)
  4. Free Time (18%) – 4 hours a day – Includes watching LOST, driving to and from DMac’s, awesome times on the Malibu, TOOL/O.A.R./Thursday & Billy Talent concerts, bars, and Guitar Hero. 4 hours a day seems excessive, but remember I’m talking about a 7 day week. Weekends skew this number

Here’s a summary of my activities in KY so far:

  1. Work & Commute (23%) – 40.5 hours a week.
  2. Sleep (29%) – still about 7 hours a night.
  3. Eat (8%) – 2 hours a day. Mandatory one hour lunch, though.
  4. Free Time (39%) – 9 hours a day. This includes seeing friends, bars, cooking meals, watching TV, doing things around the apartment, reading

We’ve got a 11% increase in “Free Time” and an 11% decrease in “Work & Commute”.

Maybe some pies will help illustrate [click for full views]:

Kansas City:

kc-chart.jpg

Kentucky:

owb-chart.jpg

As the charts reveal, I clearly have more free time. Which means I can spend it doing “higher level” activities besides work/sleep/eat. What am I going to be doing?

  • Reading
  • Catching up with friends
  • Making new friends
  • Exercise
  • Cooking/Learning to Cook more things
  • The ever important, writing and making pie charts about my time to post on my blog =)

Written by bofe

December 21, 2006 at 09:25

Posted in Personal

Tagged with

New Subscriptions

with 2 comments

My new RSS subscriptions this week, using Google Reader:

Great sites with great advice. Any other suggestions?

Written by bofe

December 19, 2006 at 15:02

Posted in Personal

Tagged with ,

New Music Suggestions

with 2 comments

I’m in dire need of some good, new (to me) music.

Check my last.fm to see what I’ve been listening to if you don’t know what kind of music I’m into. I wouldn’t say my last.fm is too indicative of all of my musical tastes, but it’s a start.

Craiggers? Chris R? Bittel?

Comment me up some awesome new music, please!

Written by bofe

December 18, 2006 at 08:23

Posted in Personal

Tagged with ,

The Other Regimen

with 4 comments

Since I’ve moved life has slowed down dramatically. There are a few good things about this:

  • I’m reading again
  • I’m cooking again, thus I’m not eating out nearly as much
  • I’m sleeping again
  • I’m seeing family/friends again

The not so good things:

  • (sometimes) I’m bored again
  • I’m not going to Chipotle or QuikTrip
  • I’m poor again
  • I’m out of those “I’m too busy” excuses

The one thing that I want to get back into (more than anything in the world, Ron!) is an exercise regimen. My sister’s going to be my accountability partner with working out at the OMHS Health Park.

There’s more incentives than the whole “better feeling, better looking” that always goes with a healthier lifestyle. In an effort to reduce claims, my employer offers reductions in Health Insurance Premiums if you meet certain wellness requirements. Very cool.

Anyone out there have suggested recipes? Shaina & Rick Petersen, I’m talking to you particularly. =)

Written by bofe

December 15, 2006 at 15:00

Posted in Personal

Tagged with