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.

Ruby Hacking Guide is being translated.

Posted on April 06, 2006

I would like to praise Vincent ISAMBART and Clifford Escobar CAOILE for translating this book to english written by Ruby wizard Minero AOKI. I've been reading several chapters that are already translated and it is a wonderful source of information about the internal structure of Ruby interpreter.