Ruby Client for OpenTransact
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


OpenTransact Ruby Client

This library provides an easy to use client for interacting with OpenTransact financial service providers.

This is currently a work in progress and we need to add better error checking, exceptions etc.

Quick start

An OpenTransact asset is a server that accepts either a http POST or GET request containing a to and an amount field.

There are 2 major ways of performing a transfer/payment with OpenTransact.

  • Simple Web Payments - Simplest to get started

  • Pre authorized payments - Uses OAuth

See []

Simple Web Payments

In your controller create a Asset object and redirect to url:

@asset = ""
redirect_to @asset.transfer_url 12, "", "For implementing shopping cart"

TODO. Work out web callback method, based on

Pre authorized Payments

OpenTransact delegates all of this to OAuth. This library only supports OAuth 1.0a at the moment. OAuth 2.0 is easy to implement so it will be added shortly.

OAuth Authorization

You need to register your application eg.

This whole section can be handled transparently by the OAuth Plugin

Now request authorization:

def request_authorization
  @consumer = "my key", "my secret", :site=>""
  #callback_url is a url on your site
  @request_token =  @consumer.get_request_token(:oauth_callback=>callback_url) 
  redirect_to @request_token.authorize_url

The user will authorize your app and get redirected back to your callback url

def callback
  @consumer = "my key", "my secret", :site=>""

  # build up request_token
  @request_token = @consumer, params[:oauth_token], session[params[:oauth_token]]

  # exchange request_token for permanent access_token
  @access_token = @request_token.get_access_token
  # associate this with your user in your database

Performing payments. This could be subscription payments etc.

@client = "", 
        :token=>@access_token.token, :secret=>@access_token.secret,
        :consumer_key=>"my key", :consumer_secret=>"my secret"

@asset = "", :client => @client

@asset.transfer 12, "", "For implementing shopping cart"

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.


Copyright © 2010 Pelle Braendgaard. See LICENSE for details.