gateway = ActiveMerchant::Billing::ElavonGateway.new( :login => "my_virtual_merchant_id", :password => "my_virtual_merchant_pin", :user => "my_virtual_merchant_user_id" # optional ) # set up credit card obj as in main ActiveMerchant example creditcard = ActiveMerchant::Billing::CreditCard.new( :type => 'visa', :number => '41111111111111111', :month => 10, :year => 2011, :first_name => 'Bob', :last_name => 'Bobsen' ) # run request response = gateway.purchase(1000, creditcard) # authorize and capture 10 USD puts response.success? # Check whether the transaction was successful puts response.message # Retrieve the message returned by Elavon puts response.authorization # Retrieve the unique transaction ID returned by Elavon
Capture authorized funds from a credit card.
money - The amount to be captured as an Integer value in cents.
authorization - The approval code returned from the initial authorization.
options
:credit_card - The CreditCard details from the initial transaction (required).
# File lib/active_merchant/billing/gateways/elavon.rb, line 72 72: def capture(money, authorization, options = {}) 73: requires!(options, :credit_card) 74: 75: form = {} 76: add_reference(form, authorization) 77: add_invoice(form, options) 78: add_creditcard(form, options[:credit_card]) 79: add_customer_data(form, options) 80: commit(:capture, money, form) 81: end
# File lib/active_merchant/billing/gateways/elavon.rb, line 97 97: def add_address(form,options) 98: billing_address = options[:billing_address] || options[:address] 99: 100: if billing_address 101: form[:avs_address] = billing_address[:address1].to_s.slice(0, 30) 102: form[:address2] = billing_address[:address2].to_s.slice(0, 30) 103: form[:avs_zip] = billing_address[:zip].to_s.slice(0, 10) 104: form[:city] = billing_address[:city].to_s.slice(0, 30) 105: form[:state] = billing_address[:state].to_s.slice(0, 10) 106: form[:company] = billing_address[:company].to_s.slice(0, 50) 107: form[:phone] = billing_address[:phone].to_s.slice(0, 20) 108: form[:country] = billing_address[:country].to_s.slice(0, 50) 109: end 110: 111: if shipping_address = options[:shipping_address] 112: first_name, last_name = parse_first_and_last_name(shipping_address[:name]) 113: form[:ship_to_first_name] = first_name.to_s.slice(0, 20) 114: form[:ship_to_last_name] = last_name.to_s.slice(0, 30) 115: form[:ship_to_address1] = shipping_address[:address1].to_s.slice(0, 30) 116: form[:ship_to_address2] = shipping_address[:address2].to_s.slice(0, 30) 117: form[:ship_to_city] = shipping_address[:city].to_s.slice(0, 30) 118: form[:ship_to_state] = shipping_address[:state].to_s.slice(0, 10) 119: form[:ship_to_company] = shipping_address[:company].to_s.slice(0, 50) 120: form[:ship_to_country] = shipping_address[:country].to_s.slice(0, 50) 121: form[:ship_to_zip] = shipping_address[:zip].to_s.slice(0, 10) 122: end 123: end
# File lib/active_merchant/billing/gateways/elavon.rb, line 84 84: def add_reference(form, authorization) 85: form[:approval_code] = authorization 86: end
# File lib/active_merchant/billing/gateways/elavon.rb, line 92 92: def add_verification_value(form, creditcard) 93: form[:cvv2cvc2] = creditcard.verification_value 94: form[:cvv2cvc2_indicator] = '1' 95: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.