Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kenmazaika/884267 to your computer and use it in GitHub Desktop.
Save kenmazaika/884267 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'activemerchant'
LOGIN_ID = '************'
TRANSACTION_KEY = '**********'
ActiveMerchant::Billing::Base.mode = :test
ActiveMerchant::Billing::CreditCard.require_verification_value = false
gateway = ActiveMerchant::Billing::AuthorizeNetCimGateway.new(:login => LOGIN_ID, :password => TRANSACTION_KEY)
response = gateway.create_customer_profile({:profile => {:merchant_customer_id => rand(10000), :email => "[email protected]", :description => "Testman Testington"} })
cpi = response.params['customer_profile_id']
response = gateway.get_customer_profile({:customer_profile_id => cpi})
creditcard = ActiveMerchant::Billing::CreditCard.new(
:number => '4222222222222',
:month => 3,
:year => 2011,
:first_name => 'Mark',
:last_name => 'McBride',
:type => 'visa'
)
response = gateway.create_customer_payment_profile( {:customer_profile_id => cpi, :payment_profile => { :payment => { :credit_card => creditcard } } } )
cppi = response.params['customer_payment_profile_id']
response = gateway.create_customer_profile_transaction({:transaction =>{:type => :auth_only, :amount => (1 * rand(100).to_f/100).to_s, :customer_profile_id => cpi, :customer_payment_profile_id => cppi}})
trans_id = response.params['direct_response']['transaction_id']
puts "waiting"
gets
puts "going"
response = gateway.create_customer_profile_transaction({:transaction =>{:type => :prior_auth_capture, :amount => (1 * rand(100).to_f/100).to_s, :customer_profile_id => cpi, :customer_payment_profile_id => cppi, :trans_id => trans_id}})
puts response.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment