Class Index [+]

Quicksearch

ActiveMerchant::Billing::EfsnetGateway

Constants

TEST_URL
LIVE_URL
CREDIT_CARD_FIELDS
ACTIONS

Public Class Methods

new(options = {}) click to toggle source

login is your Store ID password is your Store Key

    # File lib/active_merchant/billing/gateways/efsnet.rb, line 17
17:       def initialize(options = {})
18:         requires!(options, :login, :password)
19:         @options = options
20:         super      
21:       end

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 27
27:       def authorize(money, creditcard, options = {})
28:         request = build_credit_card_request(money, creditcard, options)
29:         commit(:credit_card_authorize, request)
30:       end
capture(money, identification, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 37
37:       def capture(money, identification, options = {})
38:         request = build_refund_or_settle_request(money, identification, options)
39:         commit(:credit_card_settle, request)
40:       end
credit(money, identification_or_credit_card, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 42
42:       def credit(money, identification_or_credit_card, options = {})
43:         if identification_or_credit_card.is_a?(String)
44:           deprecated CREDIT_DEPRECATION_MESSAGE
45:           # Perform authorization reversal
46:           refund(money, identification_or_credit_card, options)
47:         else
48:           # Perform credit
49:           request = build_credit_card_request(money, identification_or_credit_card, options)
50:           commit(:credit_card_credit, request)
51:         end
52:       end
force(money, authorization_code, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 72
72:       def force(money, authorization_code, creditcard, options = {})
73:         options[:authorization_number] = authorization_code
74:         request = build_credit_card_request(money, creditcard, options)
75:         commit(:credit_card_capture, request)
76:       end
purchase(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 32
32:       def purchase(money, creditcard, options = {})
33:         request = build_credit_card_request(money, creditcard, options)
34:         commit(:credit_card_charge, request)
35:       end
refund(money, reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 54
54:       def refund(money, reference, options = {})
55:         # Perform authorization reversal
56:         request = build_refund_or_settle_request(money, reference, options)
57:         commit(:credit_card_refund, request)
58:       end
system_check() click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 78
78:       def system_check
79:         commit(:system_check, {})      
80:       end
test?() click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 23
23:       def test?
24:         @options[:test] || super
25:       end
voice_authorize(money, authorization_code, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 66
66:       def voice_authorize(money, authorization_code, creditcard, options = {})
67:         options[:authorization_number] = authorization_code
68:         request = build_credit_card_request(money, creditcard, options)
69:         commit(:credit_card_voice_authorize, request)
70:       end
void(identification, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 60
60:       def void(identification, options = {})
61:         requires!(options, :order_id)
62:         original_transaction_id, original_transaction_amount = identification.split(";")
63:         commit(:void_transaction, {:reference_number => format_reference_number(options[:order_id]), :transaction_ID => original_transaction_id})
64:       end

Private Instance Methods

actions() click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 216
216:       def actions
217:         ACTIONS
218:       end
add_address(post,options) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 117
117:       def add_address(post,options)
118:         if address = options[:billing_address] || options[:address]
119:           if address[:address2]
120:             post[:billing_address]    = address[:address1].to_s << ' ' <<  address[:address2].to_s
121:           else
122:             post[:billing_address]    = address[:address1].to_s
123:           end
124:           post[:billing_city]         = address[:city].to_s
125:           post[:billing_state]        = address[:state].blank?  ? 'n/a' : address[:state]
126:           post[:billing_postal_code]  = address[:zip].to_s       
127:           post[:billing_country]      = address[:country].to_s
128:         end
129: 
130:         if address = options[:shipping_address]
131:           if address[:address2]
132:             post[:shipping_address]   = address[:address1].to_s << ' ' <<  address[:address2].to_s
133:           else
134:             post[:shipping_address]   = address[:address1].to_s
135:           end
136:           post[:shipping_city]        = address[:city].to_s
137:           post[:shipping_state]       = address[:state].blank?  ? 'n/a' : address[:state]
138:           post[:shipping_postal_code] = address[:zip].to_s       
139:           post[:shipping_country]     = address[:country].to_s
140:         end
141:       end
add_creditcard(post, creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 143
143:       def add_creditcard(post, creditcard)      
144:         post[:billing_name]  = creditcard.name if creditcard.name
145:         post[:account_number]  = creditcard.number
146:         post[:card_verification_value] = creditcard.verification_value if creditcard.verification_value?
147:         post[:expiration_month]  = sprintf("%.2i", creditcard.month)
148:         post[:expiration_year]  = sprintf("%.4i", creditcard.year)[2..1]
149:       end
authorization_from(response, params) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 167
167:       def authorization_from(response, params)
168:         [ response[:transaction_id], params[:transaction_amount] ].compact.join(';')
169:       end
build_credit_card_request(money, creditcard, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 98
 98:       def build_credit_card_request(money, creditcard, options = {})
 99:         requires!(options, :order_id)
100: 
101:         post = {
102:           :reference_number => format_reference_number(options[:order_id]),
103:           :authorization_number => options[:authorization_number],
104:           :transaction_amount => amount(money),
105:           :client_ip_address => options[:ip]
106:           
107:         }
108:         add_creditcard(post,creditcard)
109:         add_address(post,options)
110:         post
111:       end
build_refund_or_settle_request(money, identification, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/efsnet.rb, line 84
84:       def build_refund_or_settle_request(money, identification, options = {})
85:         original_transaction_id, original_transaction_amount = identification.split(";")
86:         
87:         requires!(options, :order_id)
88: 
89:         post = {
90:           :reference_number => format_reference_number(options[:order_id]),
91:           :transaction_amount => amount(money),
92:           :original_transaction_amount => original_transaction_amount,
93:           :original_transaction_ID => original_transaction_id,
94:           :client_ip_address => options[:ip]
95:         }
96:       end
commit(action, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 152
152:       def commit(action, parameters)  
153:         response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, post_data(action, parameters), 'Content-Type' => 'text/xml'))
154: 
155:         Response.new(success?(response), message_from(response[:result_message]), response,
156:           :test => test?,
157:           :authorization => authorization_from(response, parameters),
158:           :avs_result => { :code => response[:avs_response_code] },
159:           :cvv_result => response[:cvv_response_code]
160:         )
161:       end
format_reference_number(number) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 113
113:       def format_reference_number(number)
114:         number.to_s.slice(0,12)
115:       end
message_from(message) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 200
200:       def message_from(message)
201:         return 'Unspecified error' if message.blank?
202:         message.gsub(/[^\w]/, ' ').split.join(" ").capitalize
203:       end
normalize(field) click to toggle source

Make a ruby type out of the response string

     # File lib/active_merchant/billing/gateways/efsnet.rb, line 206
206:       def normalize(field)
207:         case field
208:         when "true"   then true
209:         when "false"  then false
210:         when ""       then nil
211:         when "null"   then nil
212:         else field
213:         end        
214:       end
parse(xml) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 171
171:       def parse(xml)
172:         response = {}
173: 
174:         xml = REXML::Document.new(xml)          
175: 
176:         xml.elements.each('//Reply//TransactionReply/*') do |node|
177: 
178:           response[node.name.underscore.to_sym] = normalize(node.text)
179: 
180:         end unless xml.root.nil?
181: 
182:         response
183:       end
post_data(action, parameters = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 185
185:       def post_data(action, parameters = {})
186:         xml   = REXML::Document.new("<?xml version='1.0' encoding='UTF-8'?>")
187:         root  = xml.add_element("Request")
188:         root.attributes["StoreID"] = options[:login]
189:         root.attributes["StoreKey"] = options[:password]
190:         root.attributes["ApplicationID"] = 'ot 1.0'
191:         transaction = root.add_element(action.to_s.camelize)
192: 
193:         actions[action].each do |key|
194:           transaction.add_element(key.to_s.camelize).text = parameters[key] unless parameters[key].blank?
195:         end
196: 
197:         xml.to_s
198:       end
success?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/efsnet.rb, line 163
163:       def success?(response)
164:         response[:response_code] == '0'
165:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.