rocketgate-ruby
RocketGate's Payment Gateway, minus the painful integration.
Installation
Add this line to your application's Gemfile:
gem 'rocketgate-ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rocketgate-ruby
Usage
Configuration
Before you can jump in, you need to configure the gem with your RocketGate credentials:
RocketGate.configure do |config|
config.merchant_id = 'rocketgate_merchant_id'
config.merchant_password = 'rocketgate_merchant_password'
end
You can also supply other configuration settings:
RocketGate.configure do |config|
config.merchant_id = 'rocketgate_merchant_id'
config.merchant_password = 'rocketgate_merchant_password'
config.currency = 'USD'
config.request_host = 'special-gateway.rocketgate.com'
config.request_path = '/specialServlet'
config.request_port = 8080
config.request_timeout = 5
config.request_version = 'R2.0'
config.require_avs = false
config.require_cvv = false
config.require_scrub = false
config.require_ssl = false
end
And if you want to test something against the sandbox gateway:
RocketGate.configuration.testing!
Making an Authorization Request
In order to get an authorization, you'll need to send a request to the gateway.
- Build a
CustomerandCreditCardso we know who and how to charge:
customer = RocketGate::Customer.new('John', 'Doe', '123 Main St', 'Beverly Hills', 'CA', '90210')
credit_card = RocketGate::CreditCard.new('4111-1111-1111-1111', '08', '2042', '012')
- Build a
Transaction
transaction = RocketGate::Transaction.new(9.99, customer, credit_card)
- Set the transaction type
transaction.type = RocketGate::Transaction::TYPE[:purchase]
- Optionally, add an identifier that ties the transaction and customer to something relevant for you, like a
UserorInvoice. (A UUID will be generated if not.)
credit_card.id = User.id
transaction.id = Invoice.id
- Build a
Request
request = RocketGate::Request.new(transaction)
- Send the request to the gateway
response = RocketGate.send_request!(request)
- Check the
Response
response. # => true (authorization OK)
response.success? # => true (authorization + gateway response OK)
- Confirm receipt of the transaction response (Note: RocketGate will cancel your transaction if you don't confirm it!)
response.confirm! # => returns a Response like the original request
Authorizations
In the section above you created and sent a request, then looked at the response. The response's Authorization has lots of great information, too.
= response.
.avs_ok? # => AVS check OK or disabled
.cvv_ok? # => CVV check OK or disabled
.success? # => AVS check + CVV check + reason code OK
.declined? # => opposite of success?
.auth_code # => authorization code from gateway, may be blank
.reason_code # => descriptive(ish) reason for the response
.approved_amount # => dollar amount of authorization (should match transaction)
.approved_currency # => currency the authorization settled in (should match transaction)
.card_hash # => unique hash of the card data which can be used later
.card_expiration # => 4-digit representation of the card expiration
.card_last_four # => the last four digits of the card charged
.reference_id # => unique reference ID used to confirm, void or reverse the request
Not Yet Implemented (Future Plans)
- Rebill functionality
Compatibility
This library supports Ruby >= 1.9.3 on a variety of platforms.
Travis CI builds every commit under these environments:
- MRI 1.9.3, 2.0.0, 2.1.1 and HEAD
- JRuby 1.7.11 (1.9 mode) and HEAD
- Rubinius 2.2.1
Other interpreters and earlier versions of MRI, JRuby and RBX are not supported.
Contributing
- Fork it ( https://github.com/ccashwell/rocketgate-ruby/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
