

Hi All,
Here the code of Automated Recurring Billing (ARB) in ruby.
First install the active_merchant plugins in your application.
// ruby code
require 'rubygems'
require 'active_merchant'
def payment
ActiveMerchant::Billing::Base.mode = :test
amount = 10
credit_card = ActiveMerchant::Billing::CreditCard.new(
:first_name => 'dinesh',
:last_name => 'singh',
:number => '4242424242424242',
:month => '12',
:year => '2020',
:verification_value => '123'
)
if credit_card.valid?
gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(
:login => 'username',
:password => 'password'
)
# Authorize for the amount
response = gateway.recurring( amount, credit_card,
{ :interval =>{:length=>1, :unit =>:months},
:duration => {:start_date=>'2010-01-01', :occurrences=>1},
:billing_address=>{:first_name=>'dinesh', :last_name=>'singh'}
}
)
#response = gateway.purchase(amount, credit_card)
if response.success?
puts response.params.inspect
puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}. The Account number is #{response.params['rbAccountId']}"
else
puts response.message
end
end
end
hope this will be helpful for all
