Class Index [+]

Quicksearch

ActiveMerchant::Billing::ExactGateway

Constants

URL
API_VERSION
TEST_LOGINS
TRANSACTIONS
ENVELOPE_NAMESPACES
SEND_AND_COMMIT_ATTRIBUTES
SEND_AND_COMMIT_SOURCE_ATTRIBUTES
POST_HEADERS
SUCCESS
SENSITIVE_FIELDS

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/exact.rb, line 43
43:       def initialize(options = {})
44:         requires!(options, :login, :password)
45:         @options = options
46:         
47:         if TEST_LOGINS.include?( { :login => options[:login], :password => options[:password] } )
48:           @test_mode = true
49:         end
50:       
51:         super
52:       end

Public Instance Methods

authorize(money, credit_card, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/exact.rb, line 58
58:       def authorize(money, credit_card, options = {})
59:         commit(:authorization, build_sale_or_authorization_request(money, credit_card, options))
60:       end
capture(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/exact.rb, line 66
66:       def capture(money, authorization, options = {})
67:         commit(:capture, build_capture_or_credit_request(money, authorization, options))
68:       end
credit(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/exact.rb, line 70
70:       def credit(money, authorization, options = {})
71:         deprecated CREDIT_DEPRECATION_MESSAGE
72:         refund(money, authorization, options)
73:       end
purchase(money, credit_card, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/exact.rb, line 62
62:       def purchase(money, credit_card, options = {})
63:         commit(:sale, build_sale_or_authorization_request(money, credit_card, options))
64:       end
refund(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/exact.rb, line 75
75:       def refund(money, authorization, options = {})
76:         commit(:credit, build_capture_or_credit_request(money, authorization, options))
77:       end
test?() click to toggle source
    # File lib/active_merchant/billing/gateways/exact.rb, line 54
54:       def test?
55:         @test_mode || Base.gateway_mode == :test
56:       end

Private Instance Methods

add_address(xml, options) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 156
156:       def add_address(xml, options)
157:         if address = options[:billing_address] || options[:address]
158:           xml.tag! 'ZipCode', address[:zip]       
159:         end    
160:       end
add_amount(xml, money) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 135
135:       def add_amount(xml, money)
136:         xml.tag! 'DollarAmount', amount(money)
137:       end
add_credentials(xml) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 119
119:       def add_credentials(xml)
120:         xml.tag! 'ExactID', @options[:login]
121:         xml.tag! 'Password', @options[:password]
122:       end
add_credit_card(xml, credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 139
139:       def add_credit_card(xml, credit_card)
140:         xml.tag! 'Card_Number', credit_card.number
141:         xml.tag! 'Expiry_Date', expdate(credit_card)
142:         xml.tag! 'CardHoldersName', credit_card.name
143:         
144:         if credit_card.verification_value?
145:           xml.tag! 'CVD_Presence_Ind', '1'
146:           xml.tag! 'VerificationStr2', credit_card.verification_value
147:         end
148:       end
add_customer_data(xml, options) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 150
150:       def add_customer_data(xml, options)
151:         xml.tag! 'Customer_Ref', options[:customer]
152:         xml.tag! 'Client_IP', options[:ip]
153:         xml.tag! 'Client_Email', options[:email]
154:       end
add_identification(xml, identification) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 128
128:       def add_identification(xml, identification)
129:         authorization_num, transaction_tag = identification.split(';')
130:  
131:         xml.tag! 'Authorization_Num', authorization_num
132:         xml.tag! 'Transaction_Tag', transaction_tag
133:       end
add_invoice(xml, options) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 162
162:       def add_invoice(xml, options)
163:         xml.tag! 'Reference_No', options[:order_id]
164:         xml.tag! 'Reference_3',  options[:description]
165:       end
add_transaction_type(xml, action) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 124
124:       def add_transaction_type(xml, action)
125:         xml.tag! 'Transaction_Type', TRANSACTIONS[action]
126:       end
authorization_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 186
186:       def authorization_from(response)
187:         if response[:authorization_num] && response[:transaction_tag]
188:            "#{response[:authorization_num]};#{response[:transaction_tag]}"        
189:         else
190:            ''
191:         end
192:       end
build_capture_or_credit_request(money, identification, options) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 109
109:       def build_capture_or_credit_request(money, identification, options)
110:         xml = Builder::XmlMarkup.new
111:   
112:         add_identification(xml, identification)
113:         add_amount(xml, money)
114:         add_customer_data(xml, options)
115:     
116:         xml.target!
117:       end
build_request(action, body) click to toggle source
    # File lib/active_merchant/billing/gateways/exact.rb, line 80
80:       def build_request(action, body)
81:         xml = Builder::XmlMarkup.new
82:         
83:         xml.instruct!
84:         xml.tag! 'env:Envelope', ENVELOPE_NAMESPACES do
85:           xml.tag! 'env:Body' do
86:             xml.tag! 'n1:SendAndCommit', SEND_AND_COMMIT_ATTRIBUTES do
87:               xml.tag! 'SendAndCommitSource', SEND_AND_COMMIT_SOURCE_ATTRIBUTES do
88:                 add_credentials(xml)
89:                 add_transaction_type(xml, action)
90:                 xml << body
91:               end
92:             end
93:           end
94:         end
95:         xml.target!
96:       end
build_sale_or_authorization_request(money, credit_card, options) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 98
 98:       def build_sale_or_authorization_request(money, credit_card, options)
 99:         xml = Builder::XmlMarkup.new
100:  
101:         add_amount(xml, money)
102:         add_credit_card(xml, credit_card)
103:         add_customer_data(xml, options)
104:         add_invoice(xml, options)
105:         
106:         xml.target!        
107:       end
commit(action, request) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 171
171:       def commit(action, request)
172:          response = parse(ssl_post(URL, build_request(action, request), POST_HEADERS))
173:       
174:          Response.new(successful?(response), message_from(response), response,
175:            :test => test?,
176:            :authorization => authorization_from(response),
177:            :avs_result => { :code => response[:avs] },
178:            :cvv_result => response[:cvv2]
179:          )
180:       end
expdate(credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 167
167:       def expdate(credit_card)
168:         "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
169:       end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 194
194:       def message_from(response)
195:         if response[:faultcode] && response[:faultstring]
196:           response[:faultstring]
197:         elsif response[:error_number] != '0'
198:           response[:error_description]
199:         else
200:           result = response[:exact_message] || ''
201:           result << " - #{response[:bank_message]}" unless response[:bank_message].blank?
202:           result
203:         end
204:       end
parse(xml) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 206
206:       def parse(xml)
207:         response = {}
208:         xml = REXML::Document.new(xml)
209:         
210:         if root = REXML::XPath.first(xml, "//types:TransactionResult")
211:           parse_elements(response, root)
212:         elsif root = REXML::XPath.first(xml, "//soap:Fault")
213:           parse_elements(response, root)
214:         end
215: 
216:         response.delete_if{ |k,v| SENSITIVE_FIELDS.include?(k) }
217:       end
parse_elements(response, root) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 219
219:       def parse_elements(response, root)
220:         root.elements.to_a.each do |node|
221:           response[node.name.gsub(/EXact/, 'Exact').underscore.to_sym] = (node.text || '').strip
222:         end
223:       end
successful?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/exact.rb, line 182
182:       def successful?(response)
183:         response[:transaction_approved] == SUCCESS
184:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.