REQUEST A DEMO

Credit Card Authorization via Clearbasic

I was recently asked if we could tie into a credit card authorization service from the Clarify Classic Client.

 

The particular service in question was Authorize.net, which allows merchants to accept credit card payments.

 

What’s nice about Authorize is that they expose web APIs that can be called via HTTP. Their developer site is pretty good – with lots of different options, and sample code in a variety of languages.

 

I’ve blogged in the past about making web requests and consuming result sets, so the approach here is similar – although in this instance it’s even easier. The results from Authorize are just a delimited string, which is much easier to parse in ClearBasic than JSON.

Giddy Up

 

signed up for a test account, grabbed some sample code from their site, and ported it to ClearBasic.

 

The API is pretty much what you expect – supply your merchant information, the credit card number, expiration data, amount, customer name, etc. The result is an approval/denial, along with a nice text message, and an approval code.

 

I called the ClearBasic code using cbbatch, as opposed to the Clarify Client, as the dev/test cycle is much faster there, and I didn’t need any UI to prove this would work.

 

The general task flow is:

  • Setup a collection of post data, such as credit card number, amount, merchant info, etc.
  • Make the HTTP POST request, passing in the collection of data
  • Get the response, and parse it based on the string delimiter.
  • Display the relevant data out of the response (approved/denied, reason, authorization code, etc.)

 

Pretty straightforward.

Code

 

The code is freely available on github:  https://gist.github.com/994126

 

You just need to put in your own API_KEY and TRANSACTION_KEY for it to be able to work (which you get when you sign up for a free test account).

Lets see it in action

 

Here’s what the output shows when executed:

credit_card

 

Approved! Sweet!

Postlude

 

The overall strategy here is the same that I’ve blogged about in the past. herehere, and here.

 

Ultimately, this post is less about credit card authorization, and more about calling web services from ClearBasic.

 

Hopefully it’s clear that if you have a web api (web service) available to you – it’s pretty straightforward to call it and get the result data – even if you’re using an older language like ClearBasic.

 

Rock on.