Class Index [+]

Quicksearch

ActiveMerchant::Billing::NetaxeptGateway

Constants

TEST_URL
LIVE_URL
CARD_TYPE_PREFIXES

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 25
25:       def initialize(options = {})
26:         requires!(options, :login, :password)
27:         @options = options
28:         super
29:       end

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 42
42:       def authorize(money, creditcard, options = {})
43:         requires!(options, :order_id)
44: 
45:         post = {}
46:         add_credentials(post, options)
47:         add_transaction(post, options)
48:         add_order(post, money, options)
49:         add_creditcard(post, creditcard)
50:         commit('Auth', post)
51:       end
capture(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 53
53:       def capture(money, authorization, options = {})
54:         post = {}
55:         add_credentials(post, options)
56:         add_authorization(post, authorization, money)
57:         commit('Capture', post, false)
58:       end
credit(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 67
67:       def credit(money, authorization, options = {})
68:         deprecated CREDIT_DEPRECATION_MESSAGE
69:         refund(money, authorization, options)
70:       end
purchase(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 31
31:       def purchase(money, creditcard, options = {})
32:         requires!(options, :order_id)
33: 
34:         post = {}
35:         add_credentials(post, options)
36:         add_transaction(post, options)
37:         add_order(post, money, options)
38:         add_creditcard(post, creditcard)
39:         commit('Sale', post)
40:       end
refund(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 60
60:       def refund(money, authorization, options = {})
61:         post = {}
62:         add_credentials(post, options)
63:         add_authorization(post, authorization, money)
64:         commit('Credit', post, false)
65:       end
test?() click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 79
79:       def test?
80:         @options[:test] || Base.gateway_mode == :test
81:       end
void(authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 72
72:       def void(authorization, options = {})
73:         post = {}
74:         add_credentials(post, options)
75:         add_authorization(post, authorization)
76:         commit('Annul', post, false)
77:       end

Private Instance Methods

add_authorization(post, authorization, money=nil) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 91
91:       def add_authorization(post, authorization, money=nil)
92:         post[:transactionId] = authorization
93:         post[:transactionAmount] = amount(money) if money
94:       end
add_credentials(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/netaxept.rb, line 86
86:       def add_credentials(post, options)
87:         post[:merchantId] = @options[:login]
88:         post[:token] = @options[:password]
89:       end
add_creditcard(post, creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 113
113:       def add_creditcard(post, creditcard)
114:         brand = Gateway.card_brand(creditcard)
115:         prefix = CARD_TYPE_PREFIXES[brand]
116:         unless prefix
117:           raise ArgumentError.new("Card type #{brand} not supported.")
118:         end
119: 
120:         post[:creditcard] = {}
121:         post[:creditcard][:"#{prefix}a"] = creditcard.number
122:         post[:creditcard][:"#{prefix}m"] = format(creditcard.month, :two_digits)
123:         post[:creditcard][:"#{prefix}y"] = format(creditcard.year, :two_digits)
124:         post[:creditcard][:"#{prefix}c"] = creditcard.verification_value
125:       end
add_order(post, money, options) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 102
102:       def add_order(post, money, options)
103:         post[:orderNumber] = options[:order_id]
104:         post[:amount] = amount(money)
105:         post[:currencyCode] = (options[:currency] || currency(money))
106:       end
add_transaction(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 96
 96:       def add_transaction(post, options)
 97:         post[:transactionId] = generate_transaction_id(options)
 98:         post[:serviceType] = 'M'
 99:         post[:redirectUrl] = 'http://example.com'
100:       end
build_url(base, parameters=nil) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 213
213:       def build_url(base, parameters=nil)
214:         url = "#{test? ? TEST_URL : LIVE_URL}"
215:         url << base
216:         if parameters
217:           url << '?'
218:           url << encode(parameters)
219:         end
220:         url
221:       end
commit(action, parameters, setup=true) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 127
127:       def commit(action, parameters, setup=true)
128:         parameters[:action] = action
129: 
130:         response = {:success => false}
131: 
132:         catch(:exception) do
133:           if setup
134:             commit_transaction_setup(response, parameters)
135:             commit_payment_details(response, parameters)
136:             commit_process_setup(response, parameters)
137:           end
138:           commit_transaction(response, parameters)
139:           response[:success] = true
140:         end
141:         
142:         Response.new(response[:success], response[:message], response, :test => test?, :authorization => response[:authorization])
143:       end
commit_payment_details(response, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 150
150:       def commit_payment_details(response, parameters)
151:         data = encode(parameters[:creditcard].merge(:BBSePay_transaction => response[:setup]['SetupString']))
152:         response[:paymentDetails] = parse(ssl_post(build_url("terminal/default.aspx"), data), false)
153:         process(response, :paymentDetails)
154:       end
commit_process_setup(response, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 156
156:       def commit_process_setup(response, parameters)
157:         result = ssl_get(build_url("REST/ProcessSetup.aspx", pick(parameters, :merchantId, :token, :transactionId).merge(:transactionString => response[:paymentDetails][:result])))
158:         response[:processSetup] = parse(result)
159:         process(response, :processSetup)
160:       end
commit_transaction(response, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 162
162:       def commit_transaction(response, parameters)
163:         result = ssl_get(build_url("REST/#{parameters[:action]}.aspx", pick(parameters, :merchantId, :token, :transactionId, :transactionAmount)))
164:         response[:action] = parse(result)
165:         process(response, :action)
166:       end
commit_transaction_setup(response, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 145
145:       def commit_transaction_setup(response, parameters)
146:         response[:setup] = parse(ssl_get(build_url("REST/Setup.aspx", pick(parameters, :merchantId, :token, :serviceType, :amount, :currencyCode, :redirectUrl, :orderNumber, :transactionId))))
147:         process(response, :setup)
148:       end
encode(hash) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 223
223:       def encode(hash)
224:         hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
225:       end
extract_xml(element) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 189
189:       def extract_xml(element)
190:         if element.has_elements?
191:           hash = {}
192:           element.elements.each do |e|
193:             hash[e.name] = extract_xml(e)
194:           end
195:           hash
196:         else
197:           element.text
198:         end
199:       end
generate_transaction_id(options) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 205
205:       def generate_transaction_id(options)
206:         Digest::MD5.hexdigest("#{options.inspect}+#{Time.now}+#{rand}")
207:       end
parse(result, expects_xml=true) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 180
180:       def parse(result, expects_xml=true)
181:         if expects_xml || /^</ =~ result
182:           doc = REXML::Document.new(result)
183:           extract_xml(doc.root).merge(:container => doc.root.name)
184:         else
185:           {:result => result}
186:         end
187:       end
pick(hash, *keys) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 209
209:       def pick(hash, *keys)
210:         keys.inject({}){|h,key| h[key] = hash[key] if hash[key]; h}
211:       end
process(response, step) click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 168
168:       def process(response, step)
169:         if response[step][:container] =~ /Exception|Error/
170:           response[:message] = response[step]['Message']
171:           throw :exception
172:         else
173:           message = (response[step]['ResponseText'] || response[step]['ResponseCode'])
174:           response[:message] = (message || response[:message])
175:           
176:           response[:authorization] = response[step]['TransactionId']
177:         end
178:       end
url() click to toggle source
     # File lib/active_merchant/billing/gateways/netaxept.rb, line 201
201:       def url
202:         (test? ? TEST_URL : LIVE_URL)
203:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.