forked from braintree/braintree_ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Braintree
committed
Dec 19, 2009
0 parents
commit 15748ee
Showing
82 changed files
with
8,537 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bt_rdoc | ||
rdoc | ||
*.gem | ||
tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2009 Braintree Payment Solutions | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
= Braintree Ruby Client Library | ||
|
||
The Braintree gem provides integration access to the Braintree Gateway. | ||
|
||
== Dependencies | ||
|
||
* builder | ||
* libxml-ruby | ||
|
||
== Quick Start Example | ||
|
||
require "rubygems" | ||
require "braintree" | ||
|
||
Braintree::Configuration.environment = :sandbox | ||
Braintree::Configuration.merchant_id = "the_merchant_id" | ||
Braintree::Configuration.public_key = "a_public_key" | ||
Braintree::Configuration.private_key = "a_private_key" | ||
|
||
transaction = Braintree::Transaction.sale!( | ||
:amount => "100.00", | ||
:credit_card => { | ||
:number => "5105105105105100", | ||
:expiration_date => "05/12" | ||
} | ||
) | ||
puts "Transaction ID: #{transaction.id}" | ||
puts "Status: #{transaction.status}" | ||
|
||
== Bang Methods | ||
|
||
Most methods have a bang and a non-bang version (e.g. <tt>Braintree::Customer.create</tt> and <tt>Braintree::Customer.create!</tt>). | ||
The non-bang version will either return a +SuccessfulResult+ or an +ErrorResult+. The bang version will either return | ||
the created or updated resource, or it will raise a ValidationsFailed exception. | ||
|
||
Example of using non-bang method: | ||
|
||
result = Braintree::Customer.create!(:first_name => "Josh") | ||
if result.success? | ||
puts "Created customer #{result.customer.id} | ||
else | ||
puts "Validations failed" | ||
result.errors.for(:customer).each do |error| | ||
puts error.message | ||
end | ||
end | ||
|
||
Example of using bang method: | ||
|
||
begin | ||
customer = Braintree::Customer.create!(:first_name => "Josh") | ||
puts "Created customer #{customer.id} | ||
rescue Braintree::ValidationsFailed | ||
puts "Validations failed" | ||
end | ||
|
||
We recommend using the bang methods when you assume that the data is valid and do not expect validations to fail. | ||
Otherwise, we recommend using the non-bang methods. | ||
|
||
== License | ||
|
||
See the LICENSE file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require "rubygems" | ||
require "spec/rake/spectask" | ||
require "rake/rdoctask" | ||
|
||
task :default => %w[spec:unit spec:integration] | ||
|
||
task :dev_console do | ||
sh "irb -I lib -rubygems -r braintree -r env/development" | ||
end | ||
|
||
task :qa_console do | ||
sh "irb -I lib -rubygems -r braintree -r env/qa" | ||
end | ||
|
||
desc "Run units" | ||
Spec::Rake::SpecTask.new("spec:unit") do |t| | ||
t.spec_files = FileList["spec/unit/**/*_spec.rb"] | ||
end | ||
|
||
desc "Run integration" | ||
Spec::Rake::SpecTask.new("spec:integration") do |t| | ||
t.spec_files = FileList["spec/integration/**/*_spec.rb"] | ||
end | ||
|
||
def configure_rdoc_task(t) | ||
t.main = "README.rdoc" | ||
t.rdoc_files.include("README.rdoc", "LICENSE", "lib/**/*.rb") | ||
t.title = "Braintree Ruby Documentation" | ||
end | ||
|
||
Rake::RDocTask.new do |t| | ||
configure_rdoc_task(t) | ||
t.rdoc_dir = "rdoc" | ||
end | ||
|
||
Rake::RDocTask.new(:bt_rdoc) do |t| | ||
configure_rdoc_task(t) | ||
t.rdoc_dir = "bt_rdoc" | ||
t.template = "bt_rdoc_template/braintree" | ||
end | ||
|
||
task :bt_rdoc_postprocessing do | ||
FileUtils.cp "bt_rdoc_template/braintree.gif", "bt_rdoc" | ||
FileUtils.cp "bt_rdoc_template/ruby.png", "bt_rdoc" | ||
Dir.glob("bt_rdoc/**/*.html") do |html_file| | ||
original = File.read(html_file) | ||
next unless original =~ /STYLE_URL/ | ||
base_url = original[/STYLE_URL = (.*)\/.*/, 1] | ||
updated = original.gsub("BASE_URL", base_url) | ||
File.open(html_file, "w") { |f| f.write updated } | ||
end | ||
end | ||
task(:bt_rdoc) { Rake::Task["bt_rdoc_postprocessing"].invoke } | ||
|
||
require File.dirname(__FILE__) + "/lib/braintree/version.rb" | ||
gem_spec = Gem::Specification.new do |s| | ||
s.name = "braintree" | ||
s.summary = "Braintree Gateway Ruby Client Library" | ||
s.description = "Ruby library for integrating with the Braintree Gateway" | ||
s.version = Braintree::Version::String | ||
s.author = "Braintree Payment Solutions" | ||
s.email = "devs@getbraintree.com" | ||
s.homepage = "http://www.braintreepaymentsolutions.com/gateway" | ||
s.rubyforge_project = "braintree" | ||
s.has_rdoc = false | ||
s.files = FileList["README.rdoc", "LICENSE", "{lib,spec}/**/*.rb", "lib/**/*.crt"] | ||
end | ||
|
||
task :gem do | ||
Gem::Builder.new(gem_spec).build | ||
end | ||
|
Oops, something went wrong.