class ActiveMerchant::Billing::HeartlandPorticoGateway
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 23 def initialize(options = {}) @options = options requires!(@options, :user_name, :password) requires!(@options, :developer_i_d, :device_id, :license_id, :site_id, :version_nbr) super end
Public Instance Methods
capture(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 59 def capture(money, authorization, options = {}) post = initial_post(options) add_authorization(post, authorization) commit('credit_add_to_batch', money, post) end
purchase(money, creditcard, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 49 def purchase(money, creditcard, options = {}) post = initial_post(options) add_invoice(post, options) add_creditcard(post, creditcard) add_address(post, creditcard, options) add_customer_data(post, options) commit('credit_sale', money, post) end
return(money, creditcard, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 66 def return(money, creditcard, options = {}) post = initial_post(options) add_creditcard(post, creditcard) commit('credit_return', money, post) end
Also aliased as: refund
reverse(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 74 def reverse(money, authorization, options = {}) post = initial_post(options) add_authorization(post, authorization) commit('credit_reversal', money, post) end
verify(creditcard, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 30 def verify(creditcard, options = {}) post = {} add_creditcard(post, creditcard) add_address(post, creditcard, options) add_customer_data(post, options) commit('credit_account_verify', nil, post) end
void(authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 81 def void(authorization, options = {}) post = initial_post(options) add_authorization(post, authorization) commit('credit_void', nil, post) end
Private Instance Methods
add_address(post, creditcard, options)
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 94 def add_address(post, creditcard, options) address = options[:billing_address] || {} post[:card_holder_data] = { :card_holder_first_name => creditcard.first_name, :card_holder_last_name => creditcard.last_name, :card_holder_addr => [address[:address1], address[:address2]].compact.join(" "), :card_holder_city => address[:city], :card_holder_state => address[:state], :card_holder_zip => address[:zip].to_s.gsub(/[^0-9A-Za-z]/, ''), :card_holder_phone => address[:phone].to_s.gsub(/[^0-9]/, ''), #:card_holder_email => "", } end
add_creditcard(post, creditcard)
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 112 def add_creditcard(post, creditcard) post[:card_data] = { :manual_entry => { :card_nbr => creditcard.number, :exp_month => creditcard.month, :exp_year => creditcard.year, :c_v_v_2 => creditcard.verification_value, :card_present => 'N', :reader_present => 'N', } } end
add_customer_data(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 90 def add_customer_data(post, options) # TODO? end
add_invoice(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 131 def add_invoice(post, options) # avoid empty hash return unless options[:invoice] || options[:invoice_ship_month] || options[:invoice_ship_day] post[:direct_mkt_data] = { :direct_mkt_invoice_nbr => options[:invoice], :direct_mkt_ship_month => options[:invoice_ship_month], :direct_mkt_ship_day => options[:invoice_ship_day], } end
client()
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 141 def client @client ||= HeartlandPortico.new(@options, test?) end
commit(action, money, parameters)
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 145 def commit(action, money, parameters) parameters[:amt] = amount(money) translate_response(client.send(action, parameters)) end
initial_post(options)
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 125 def initial_post(options) # Not usually expected to be true, mostly just here for # testing purposes { :allow_dup => options[:allow_dup] } end
translate_response(heartland_response)
click to toggle source
# File lib/active_merchant/billing/gateways/heartland_portico.rb, line 150 def translate_response(heartland_response) Response.new( heartland_response.success?, heartland_response.message, heartland_response.body, { :fraud_review => false, :authorization => heartland_response.authorization, :test => test?, :avs_result => { :code => heartland_response.avs_code }, :cvv_result => heartland_response.cvv_code } ) end