Braintree Ruby Docs

We decided to build an app for the Node.js Knockout that will give us a head start on developing one of our most requested features: push notifications of gateway activity. Check out PushRelay and vote for us in the Node Knockout!

Ruby Client Library

Installation

gem install braintree

Updates

Current version: 2.5.0. Released August 19, 2010.

For details on changes see the change log. If we deprecate any functionality we’ll add updating instructions to the deprecations page.

Fill out this form to receive emails when we release updates to the Ruby gem.



Source Code

github | tgz | zip

Integration Examples

github | tgz | zip

Bugs

If you run into a bug, email us at support@getbraintree.com or create an issue on the github issue tracker.

Quick Start Example

require "rubygems"
require "braintree"

Braintree::Configuration.environment = :sandbox
Braintree::Configuration.merchant_id = "your_merchant_id"
Braintree::Configuration.public_key = "your_public_key"
Braintree::Configuration.private_key = "your_private_key"

result = Braintree::Transaction.sale(
  :amount => "1000.00",
  :credit_card => {
    :number => "5105105105105100",
    :expiration_date => "05/12"
  }
)

if result.success?
  puts "Transaction ID: #{result.transaction.id}"
  # status will be authorized or submitted_for_settlement
  puts "Transaction Status: #{result.transaction.status}"
else
  puts "Message: #{result.message}"
  if result.transaction.nil?
    # validation errors prevented transaction from being created
    p result.errors
  else
    puts "Transaction ID: #{result.transaction.id}"
    # status will be processor_declined, gateway_rejected, or failed
    puts "Transaction Status: #{result.transaction.status}"
  end
end