Ruby integration with CyberSource

Posted on April 07, 2006

I have received a number of emails asking about how we did the integration with CyberSource credit card processing system. I have decided to post our extension here so that google can index it. We switched to CyberSource about a year and a half ago and this extension has been proved to be very stable for all this time. It uses CyberSource SCMP API SDK for C language which you can download here.

Note that this API is now considered to be a legacy one, but it still works perfectly. I'm not sure about the future though.

Follow this steps:

  1. Download SDK from the CyberSource and install it. By default it will be placed at /opt/CyberSource/SDK and this is where ruby extension assumes it resides. Otherwise you have to modify extconf.rb file.
  2. You need to generate merchant keys and certificate as explained here.
  3. Download ruby extension and use standard steps to install it:

    $ ruby extconf.rb 
    $ make 
    $ make install.
    
  4. Test it! SCMP API is a name-value pairs API. Basically, you submit some set of name-value pairs and the server responds with another set of name-value pairs. For details consult documentation which comes with SDK. Below is a simple test program:

    #!/usr/bin/env ruby
    require 'rics'
    
    
    req = ICSMessage.new
    req['ics_applications'] = 'ics_auth'
    req['server_host'] = 'ics2test.ic3.com'
    req['server_port'] = '80'
    req['merchant_id'] = 'v1111111'
    
    
    req['grand_total_amount'] = '100.55'
    req['merchant_ref_number'] = '1'
    
    
    req['bill_address1'] = 'Miami Beach'
    req['bill_city'] = 'Miami'
    req['bill_country'] = 'US'
    req['bill_state'] = 'FL'
    req['bill_zip'] = '33160'
    
    
    req['currency'] = 'USD'
    
    
    req['customer_cc_expmo'] = '12'
    req['customer_cc_expyr'] = '2005'
    req['customer_cc_number'] = '4111111111111111'
    req['customer_firstname'] = 'John'
    req['customer_lastname'] = 'Doe'
    req['customer_email'] = 'john@example.com'
    
    
    resp = req.send
    
    
    resp.each do |k,v|
      puts "#{k} = #{v}"
    end
    

Enjoy.

Comments
  1. FredrikFebruary 16, 2007 @ 04:49 PM

    What kind of system do you install this on. I'm on a 2.6.12 gentoo system and the required libraries does not match up. I'm trying to run the ecert binary.

  2. KentFebruary 16, 2007 @ 07:21 PM

    I'm on a debian sarge 2.6.11.

    Make sure that you are using the latest ecert which comes separately from the SDK.

  3. FredrikFebruary 19, 2007 @ 11:54 AM

    I did get the new ecert app, but still ran into trouble.

    Here is what I did on gentoo, to get the ecert application to run if someone else attempts to do it.

    libcom_err libraries are located in /usr/lib and /lib. This one symlink will take care of it. ln -s /lib/libcomerr.so /lib/libcomerr.so.3

    For ssl: ln -s /usr/lib/libssl.so.0.9.7 /usr/lib/libssl.so.4 ln -s /usr/lib/libcrypto.so.0.9.7 /usr/lib/libcrypto.so.4

    I have libssl.so.0.9.8 too on the system, but did not try to link against these.

    ./ecert <merchant_id>

    Fredrik

  4. JaredMarch 01, 2007 @ 03:56 PM

    I'm on debian etch 4.0 and also had to do some symlinking, but got the following error when running make:

    gcc -shared -rdynamic -Wl,-export-dynamic -L"/opt/CyberSource/SDK/lib" -L"/usr/lib" -o rics.so rics.o -lruby1.8 -lics2 -lpthread -ldl -lcrypt -lm -lc rics.o: file not recognized: File format not recognized collect2: ld returned 1 exit status make: * [rics.so] Error 1

    any ideas?

  5. JaredMarch 07, 2007 @ 02:21 PM

    I ran make clean and make again and it compiled fine. Thanks for posting the extension.

  6. jeffJuly 02, 2007 @ 02:50 PM

    i'm trying to install this on mac osx (intel)... make runs with no errors, but when i require 'rics', i get : dyld: NSLinkModule() error dyld: Symbol not found: icsfget Referenced from: /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/rics.bundle Expected in: flat namespace

    any suggestions?

    thanks, jeff

Post a comment
Comment





You may use Markdown in your comments, so please give your code snippets a four-space indent.