Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
Created October 11, 2012 13:01
Show Gist options
  • Save chris-ramon/3872118 to your computer and use it in GitHub Desktop.
Save chris-ramon/3872118 to your computer and use it in GitHub Desktop.
activemerchant-error
require 'rubygems'
gem 'active_merchant', '~> 1.3.1'
# Send requests to the gateway's test servers
ActiveMerchant::Billing::Base.mode = :test
Create a new credit card object
credit_card = ActiveMerchant::Billing::CreditCard.new(
:number => '4111111111111111',
:month => '8',
:year => '2009',
:first_name => 'Tobias',
:last_name => 'Luetke',
:verification_value => '123'
)
if credit_card.valid?
# Create a gateway object to the TrustCommerce service
gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
:login => 'TestMerchant',
:password => 'password'
)
# Authorize for $10 dollars (1000 cents)
response = gateway.authorize(1000, credit_card)
if response.success?
# Capture the money
gateway.capture(1000, response.authorization)
else
raise StandardError, response.message
end
end
# Error : /Users/chris/Desktop/am.rb:5:in `<main>': uninitialized constant
# Object::ActiveMerchant (NameError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment