Garbanzo
Ruby library for interacting with Authorize.net's Automated Recurring Billing.
Installation
Add this line to your application's Gemfile:
gem 'garbanzo'
And then execute:
$ bundle
Or install it yourself as:
$ gem install garbanzo
Usage
Alpha API, subject to change.
Connection
Configuration for the connection to Authorize.net is handled through Garbanzo.configure
.
Garbanzo.configure do |c|
c.login = 'your_login'
c.password = 'your_key'
c.test_mode = true # defaults to false
end
You can also assign a connection object directly.
test_mode = true
connection = Garbanzo::Connection.new('your_login', 'your_key', test_mode)
Garbanzo.connection = connection
Subscriptions
Subscription objects are ActiveAttr::Model
s; they can be treated as such with
the exception of the initializer, which doesn't take a hash as normal
ActiveAttr::Model
s do.
subscription = Garbanzo::Subscription.new
# Regular assignment
subscription.amount = amount
# Mass assignment
subscription.attributes = { address: address, duration: duration, interval: interval }
# Without ID present, create new subscription
subscription.save
# With ID present, update existing subscription
subscription.id = 12345
subscription.amount = amount + 100
subscription.save
# Returns active, expired, suspended, canceled, or terminated
subscription.status
# Cancels subscription
subscription.cancel
Parameters
Required parameters for interacting with ARB subscriptions are wrapped in helper classes.
They include validation via a #valid?
method, where appropriate.
# Only first and last name are required.
address = Garbanzo::Address.new(
first_name: 'Test',
last_name: 'Dude',
address1: '123 Main St',
city: 'New York',
state: 'NY',
zip: '12345',
country: 'USA'
)
card_number = '4111111111111111'
exp_month = '10'
exp_year = '2021'
card = Garbanzo::CreditCard.new(card_number, exp_month, exp_year)
# Amount is in dollars
amount = 10.0
# Defaults: start today, run indefinitely
# Example: start today, run for 12 intervals
duration = Garbanzo::Duration.new(Date.today, 12)
# Defaults: run every month
# Example: run every 14 days
interval = Garbanzo::Interval.new(14, :days)
TODO
- Public method return value documentation
- Errors
Contributing
- Fork it ( https://github.com/dubdromic/garbanzo/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request