Jeushy
unread,May 7, 2008, 2:22:44 AM5/7/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Active Merchant
I'm also having a little trouble implementing ARB with Authorize.Net.
I keep getting a "uninitialized constant
Subscription::AuthorizeNetGateway" error, but I must be missing
something or chalk it up to my noobness on ActiveMerchant, but if
anyone can point out where my bug is I would really appreciate the
help:
Below is code from my app/models/subscription.rb
def process_recurring
ActiveMerchant::Billing::Base.mode = :production
amount = (self.total_to_charge)
# read api key and transaction # from config file
c = YAML::load(File.open("#{RAILS_ROOT}/config/config.yml"))
user = c[RAILS_ENV]['auth_net_user']
pass = c[RAILS_ENV]['auth_net_pass']
creditcard = ActiveMerchant::Billing::CreditCard.new(
:first_name => self.bill_to_fname,
:last_name => self.bill_to_lname,
:number=> self.card_number,
:verification_value => self.card_verification_value,
:type => self.card_type,
:month => self.card_expiration_month,
:year => self.card_expiration_year
)
if creditcard.valid?
options = {
:interval => {
:length => 1,
:unit => "months"
},
:duration => {
:startDate => "2008-06-08",
:totalOccurences => 9999,
},
:billing_address => {
:firstName => self.bill_to_fname,
:lastName => self.bill_to_lname,
}
}
# Create a gateway object to the Authorize.net service
gateway = AuthorizeNetGateway.new( { :login => user, :password
=> pass} )
# Authorize and Capture payment for the total amount (in cents)
response = gateway.recurring(amount, creditcard, options)
if response.success?
self.total_amount = amount
self.subscription_id = response.subscriptionId
self.status = 'processed'
else
self.status = 'failed'
self.error_message = response.message
end
else
self.status = 'failed'
self.error_message = 'Invalid credit card'
end
end
Thanks for the help.