Class Index [+]

Quicksearch

ActiveMerchant::Billing::MerchantESolutionsGateway

Constants

TEST_URL
LIVE_URL

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 20
20:                         def initialize(options = {})
21:                                 requires!(options, :login, :password)
22:                                 @options = options
23:                                 super
24:                         end

Public Instance Methods

authorize(money, creditcard_or_card_id, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 26
26:                         def authorize(money, creditcard_or_card_id, options = {})
27:                                 post = {}
28:                                 add_invoice(post, options)
29:                                 add_payment_source(post, creditcard_or_card_id, options)        
30:                                 add_address(post, options)        
31:                                 commit('P', money, post)
32:                         end
capture(money, transaction_id, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 42
42:                         def capture(money, transaction_id, options = {})
43:                                 post ={}
44:                                 post[:transaction_id] = transaction_id
45:                                 commit('S', money, post)
46:                         end
credit(money, creditcard_or_card_id, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 64
64:                         def credit(money, creditcard_or_card_id, options = {})
65:                                 post = {}
66:                                 add_payment_source(post, creditcard_or_card_id, options)
67:                                 commit('C', money, post)
68:                         end
purchase(money, creditcard_or_card_id, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 34
34:                         def purchase(money, creditcard_or_card_id, options = {})
35:                                 post = {}
36:                                 add_invoice(post, options)
37:                                 add_payment_source(post, creditcard_or_card_id, options)        
38:                                 add_address(post, options)   
39:                                 commit('D', money, post)
40:                         end
refund(money, identification, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 60
60:                         def refund(money, identification, options = {})
61:                                 commit('U', money, options.merge(:transaction_id => identification))
62:                         end
store(creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 48
48:                         def store(creditcard, options = {})
49:                                 post = {}
50:                                 add_creditcard(post, creditcard, options) 
51:                                 commit('T', nil, post)
52:                         end
unstore(card_id) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 54
54:                         def unstore(card_id)
55:                                 post = {}
56:                                 post[:card_id] = card_id
57:                                 commit('X', nil, post)
58:                         end
void(transaction_id, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 70
70:                         def void(transaction_id, options = {})
71:                                 commit('V', nil, options.merge(:transaction_id => transaction_id))
72:                         end

Private Instance Methods

add_address(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 76
76:                         def add_address(post, options)
77:                                 if address = options[:billing_address] || options[:address]
78:                                         post[:cardholder_street_address] = address[:address1].to_s.gsub(/[^\w.]/, '+')
79:                                         post[:cardholder_zip] = address[:zip].to_s       
80:                                 end
81:                         end
add_creditcard(post, creditcard, options) click to toggle source
     # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 99
 99:                         def add_creditcard(post, creditcard, options)  
100:                                 post[:card_number]  = creditcard.number
101:                                 post[:cvv2] = creditcard.verification_value if creditcard.verification_value?
102:                                 post[:card_exp_date]  = expdate(creditcard)
103:                         end
add_invoice(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 83
83:                         def add_invoice(post, options)
84:                                 if options.has_key? :order_id
85:                                         post[:invoice_number] = options[:order_id].to_s.gsub(/[^\w.]/, '')
86:                                 end
87:                         end
add_payment_source(post, creditcard_or_card_id, options) click to toggle source
    # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 89
89:                         def add_payment_source(post, creditcard_or_card_id, options) 
90:                                 if creditcard_or_card_id.is_a?(String)  
91:                                         # using stored card
92:                                         post[:card_id] = creditcard_or_card_id
93:                                 else
94:                                         # card info is provided
95:                                         add_creditcard(post, creditcard_or_card_id, options)
96:                                 end
97:                         end
commit(action, money, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 114
114:                         def commit(action, money, parameters)
115:           
116:                                 url = test? ? TEST_URL : LIVE_URL
117:                                 parameters[:transaction_amount]  = amount(money) if money unless action == 'V'
118:                 
119:                                 response = parse( ssl_post(url, post_data(action,parameters)) )
120: 
121:                                 Response.new(response["error_code"] == "000", message_from(response), response, 
122:                                         :authorization => response["transaction_id"],
123:                                         :test => test?,
124:                                         :cvv_result => response["cvv2_result"],
125:                                         :avs_result => { :code => response["avs_result"] }
126:                                 )
127: 
128:                         end
expdate(creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 130
130:                         def expdate(creditcard)
131:                                 year  = sprintf("%.4i", creditcard.year)
132:                                 month = sprintf("%.2i", creditcard.month)
133:                                 "#{month}#{year[-2..-1]}"
134:                         end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 136
136:                         def message_from(response)
137:                                 if response["error_code"] == "000"
138:                                         "This transaction has been approved"
139:                                 else
140:                                         response["auth_response_text"]
141:                                 end
142:                         end
parse(body) click to toggle source
     # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 105
105:                         def parse(body)
106:                                 results = {}
107:                                 body.split(/&/).each do |pair|
108:                                         key,val = pair.split(/=/)
109:                                         results[key] = val
110:                                 end
111:                                 results
112:                         end
post_data(action, parameters = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/merchant_e_solutions.rb, line 144
144:                         def post_data(action, parameters = {})
145:                                 post = {}
146:                                 post[:profile_id] = @options[:login]
147:                                 post[:profile_key] = @options[:password]
148:                                 post[:transaction_type] = action if action
149: 
150:                                 request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
151:                                 request
152:                         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.