About Chris Morrell

I am a Philadelphia web designer and developer who focuses on PHP development and usable design. I am also the Director of IT for the International Association of Certified Home Inspectors.

Please Note: My site fell victim to a Wordpress security flaw a few weeks ago, and I'm just getting everything back to normal. Please bear with me.

I am currently not accepting any new clients.

Other Sites/Clients

Contact Me

If you need to get in touch with me, my name is Chris and my domain name is cmorrell.com. Think about it.

Galahad Payment Layer 0.1

Posted by Chris Morrell on March 10th, 2009 in Galahad Payment Layer

During the past two years I’ve constantly been frustrated with the Authorize.net API wrappers that exist, so when I started to rebuild NACHI.TV I decided I would write the one I always hoped for. The code is just a two days old, so I’m sure there are all sorts of gaping holes in it, but I thought I’d release this first version to get some feedback from others who are as frustrated as I am.

Here’s a basic example of how you might use the wrapper:

$gateway = new Galahad_Gateway_AuthorizeNet($login, $tranKey);
$card = new Galahad_CreditCard('4222222222222', 4, 10);
$transaction = new Galahad_Gateway_Transaction(null, 2.00, $card, 'Description of $2 purchase');
$response = $gateway->capture($transaction, true);
if ($response->isApproved()) {
  echo '<h1>Approved</h1>';
} else {
  echo '<h1>Declined</h1>';
}

The code is (obviously) PHP5 only, and requires cURL and OpenSSL. Most of the code is gateway-agnostic (right now the only gateway supported is Authorize.net) so it’s written in a way that you should be able to use any gateway with a little bit of work. I plan on writing a PayPal implementation at some point in the near future.

In the future I’d like to add a GatewayResponse object and a GatewayResponseException to standardize some of the response data and error handling (so that you can check if the transaction was accepted or declined, etc, without having to know about the specific gateway), and I plan on cleaning up a lot of the code. I would HIGHLY recommend not using this in a production site yet.

Right now the Authorize.net gateway supports authorize, capture, and authorize+capture. In the future I will add support for refund and void. The plan is to standardize those 4 actions, and then let each gateway support whatever additional functionality it wants to. I might add recurring billing and data storage to that list in the future, but I don’t know how well other gateways support those functions.

Please take a look at the code and let me know if you have any suggestions. I wouldn’t be surprised if the class structure changes significantly over the next few weeks, so don’t hesitate to suggest major changes. The code is released under GPL3.

Update (3/10 6:20 PM): Major restructuring of code already started. Switching to a Zend Framework layout. Also, ditching the GatewayResponseException and returning only a Response object either way.
Update (3/11 10:00 AM): Changed the code to match the Zend Framework structure and made a bunch of updates. Sample code above now reflects basic flow.

Project Page: Galahad Payment Layer

No Comments (Respond Now) »

Leave a Reply

Additional comments powered by BackType

Comments & Trackbacks

You can leave a response, or trackback from your own site. Follow any responses to this entry through the RSS 2.0 feed.

More...

@inxilpro

  • Wet Hot American Summer at World Cafe Live. It's free and dead. 2 days ago
  • Would really like something that combines Twitter starred + Google Reader starred/liked + Delicious.com. Does such a thing exist? 6 days ago
  • Also, how can OS X be so rock solid and other Apple-developed software be so buggy? 1 week ago
  • More updates...
Copyright © Chris Morrell, Powered by WordPress, Entry RSS Feed / Comment RSS Feed