Class Index [+]

Quicksearch

ActiveMerchant::Billing::IridiumGateway

For more information on the Iridium Gateway please download the documentation from their Merchant Management System.

The login and password are not the username and password you use to login to the Iridium Merchant Management System. Instead, you will use the API username and password you were issued separately.

Constants

CURRENCY_CODES

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 35
35:       def initialize(options = {})
36:         requires!(options, :login, :password)
37:         @options = options
38:         @test_url = 'https://gw1.iridiumcorp.net/'
39:         @live_url = 'https://gw1.iridiumcorp.net/'
40:         super
41:       end

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 43
43:       def authorize(money, creditcard, options = {})
44:         commit(build_purchase_request('PREAUTH', money, creditcard, options), options)
45:       end
capture(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 57
57:       def capture(money, authorization, options = {})
58:         commit(build_reference_request('COLLECTION', money, authorization, options), options)
59:       end
credit(money, authorization, options={}) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 61
61:       def credit(money, authorization, options={})
62:         deprecated CREDIT_DEPRECATION_MESSAGE
63:         refund(money, authorization, options)
64:       end
purchase(money, payment_source, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 47
47:       def purchase(money, payment_source, options = {})
48:         setup_address_hash(options)
49:         
50:         if payment_source.respond_to?(:number)
51:           commit(build_purchase_request('SALE', money, payment_source, options), options)
52:         else
53:           commit(build_reference_request('SALE', money, payment_source, options), options)
54:         end
55:       end
refund(money, authorization, options={}) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 66
66:       def refund(money, authorization, options={})
67:         commit(build_reference_request('REFUND', money, authorization, options), options)
68:       end
void(authorization, options={}) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 70
70:       def void(authorization, options={})
71:         commit(build_reference_request('VOID', nil, authorization, options), options)
72:       end

Private Instance Methods

add_creditcard(xml, creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 160
160:       def add_creditcard(xml, creditcard)      
161:         xml.tag! 'CardDetails' do
162:           xml.tag! 'CardName', creditcard.name
163:           xml.tag! 'CV2', creditcard.verification_value if creditcard.verification_value
164:           xml.tag! 'CardNumber', creditcard.number
165:           xml.tag! 'ExpiryDate', { 'Month' => creditcard.month.to_s.rjust(2, "0"), 'Year' => creditcard.year.to_s[/\d\d$/] }
166:         end
167:       end
add_customerdetails(xml, creditcard, address, options, shipTo = false) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 138
138:       def add_customerdetails(xml, creditcard, address, options, shipTo = false)
139:         xml.tag! 'CustomerDetails' do
140:           if address
141:             unless address[:country].blank?
142:               country_code = Country.find(address[:country]).code(:numeric)
143:             end
144:             xml.tag! 'BillingAddress' do
145:               xml.tag! 'Address1', address[:address1]
146:               xml.tag! 'Address2', address[:address2]
147:               xml.tag! 'City', address[:city]
148:               xml.tag! 'State', address[:state]
149:               xml.tag! 'PostCode', address[:zip]
150:               xml.tag! 'CountryCode', country_code if country_code
151:             end
152:             xml.tag! 'PhoneNumber', address[:phone]
153:           end
154:           
155:           xml.tag! 'EmailAddress', options[:email]
156:           xml.tag! 'CustomerIPAddress', options[:ip] || "127.0.0.1"
157:         end   
158:       end
add_merchant_data(xml, options) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 169
169:       def add_merchant_data(xml, options)
170:         xml.tag! 'MerchantAuthentication', {"MerchantID" => @options[:login], "Password" => @options[:password]}
171:       end
add_purchase_data(xml, type, money, options) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 125
125:       def add_purchase_data(xml, type, money, options)
126:         requires!(options, :order_id)
127:         xml.tag! 'TransactionDetails', {'Amount' => amount(money), 'CurrencyCode' => currency_code(options[:currency] || currency(money))} do
128:           xml.tag! 'MessageDetails', {'TransactionType' => type}
129:           xml.tag! 'OrderID', options[:order_id]
130:           xml.tag! 'TransactionControl' do
131:             xml.tag! 'ThreeDSecureOverridePolicy', 'FALSE'
132:             xml.tag! 'EchoAVSCheckResult', 'TRUE'
133:             xml.tag! 'EchoCV2CheckResult', 'TRUE'
134:           end
135:         end
136:       end
build_purchase_request(type, money, creditcard, options) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 76
76:       def build_purchase_request(type, money, creditcard, options)
77:         options.merge!(:action => 'CardDetailsTransaction')
78:         build_request(options) do |xml|
79:           add_purchase_data(xml, type, money, options)
80:           add_creditcard(xml, creditcard)
81:           add_customerdetails(xml, creditcard, options[:billing_address], options)
82:         end
83:       end
build_reference_request(type, money, authorization, options) click to toggle source
    # File lib/active_merchant/billing/gateways/iridium.rb, line 85
85:       def build_reference_request(type, money, authorization, options)
86:         options.merge!(:action => 'CrossReferenceTransaction')
87:         order_id, cross_reference, auth_id = authorization.split(";")
88:         build_request(options) do |xml|
89:           if money
90:             details = {'CurrencyCode' => currency_code(options[:currency] || default_currency), 'Amount' => amount(money)}
91:           else
92:             details = {'CurrencyCode' => currency_code(default_currency), 'Amount' => '0'}
93:           end
94:           xml.tag! 'TransactionDetails', details do
95:             xml.tag! 'MessageDetails', {'TransactionType' => type, 'CrossReference' => cross_reference}
96:             xml.tag! 'OrderID', (options[:order_id] || order_id)
97:           end
98:         end
99:       end
build_request(options) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 101
101:       def build_request(options)
102:         requires!(options, :action)
103:         xml = Builder::XmlMarkup.new :indent => 2
104:         xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
105:         xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/', 
106:                                     'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 
107:                                     'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
108:           xml.tag! 'soap:Body' do
109:             xml.tag! options[:action], {'xmlns' => "https://www.thepaymentgateway.net/"} do
110:               xml.tag! 'PaymentMessage' do
111:                 add_merchant_data(xml, options)
112:                 yield(xml)
113:               end
114:             end
115:           end
116:         end
117:         xml.target!
118:       end
commit(request, options) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 173
173:       def commit(request, options)
174:         requires!(options, :action)
175:         response = parse(ssl_post(test? ? @test_url : @live_url, request,
176:                               {"SOAPAction" => "https://www.thepaymentgateway.net/#{options[:action]}",
177:                                "Content-Type" => "text/xml; charset=utf-8" }))
178:   
179:         success = response[:transaction_result][:status_code] == "0"
180:         message = response[:transaction_result][:message]
181:         authorization = success ? [ options[:order_id], response[:transaction_output_data][:cross_reference], response[:transaction_output_data][:auth_code] ].compact.join(";") : nil
182:         
183:         Response.new(success, message, response, 
184:           :test => test?, 
185:           :authorization => authorization)
186:       end
currency_code(currency) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 253
253:       def currency_code(currency)
254:         CURRENCY_CODES[currency]
255:       end
parse(xml) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 188
188:       def parse(xml)
189:         reply = {}
190:         xml = REXML::Document.new(xml)
191:         if (root = REXML::XPath.first(xml, "//CardDetailsTransactionResponse")) or
192:               (root = REXML::XPath.first(xml, "//CrossReferenceTransactionResponse"))
193:           root.elements.to_a.each do |node|
194:             case node.name  
195:             when 'Message'
196:               reply[:message] = reply(node.text)
197:             else
198:               parse_element(reply, node)
199:             end
200:           end
201:         elsif root = REXML::XPath.first(xml, "//soap:Fault") 
202:           parse_element(reply, root)
203:           reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}"
204:         end
205:         reply
206:       end
parse_element(reply, node) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 208
208:       def parse_element(reply, node)
209:         case node.name
210:         when "CrossReferenceTransactionResult"
211:           reply[:transaction_result] = {}
212:           node.attributes.each do |a,b|
213:             reply[:transaction_result][a.underscore.to_sym] = b
214:           end
215:           node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
216: 
217:         when "CardDetailsTransactionResult"
218:           reply[:transaction_result] = {}
219:           node.attributes.each do |a,b|
220:             reply[:transaction_result][a.underscore.to_sym] = b
221:           end
222:           node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
223: 
224:         when "TransactionOutputData"
225:           reply[:transaction_output_data] = {}
226:           node.attributes.each{|a,b| reply[:transaction_output_data][a.underscore.to_sym] = b }
227:           node.elements.each{|e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
228:         when "CustomVariables"
229:           reply[:custom_variables] = {}
230:           node.attributes.each{|a,b| reply[:custom_variables][a.underscore.to_sym] = b }
231:           node.elements.each{|e| parse_element(reply[:custom_variables], e) } if node.has_elements?
232:         when "GatewayEntryPoints"
233:           reply[:gateway_entry_points] = {}
234:           node.attributes.each{|a,b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
235:           node.elements.each{|e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
236:         else
237:           k = node.name.underscore.to_sym
238:           if node.has_elements?
239:             reply[k] = {}
240:             node.elements.each{|e| parse_element(reply[k], e) } 
241:           else
242:             if node.has_attributes?
243:               reply[k] = {}
244:               node.attributes.each{|a,b| reply[k][a.underscore.to_sym] = b }
245:             else
246:               reply[k] = node.text
247:             end
248:           end
249:         end
250:         reply
251:       end
setup_address_hash(options) click to toggle source
     # File lib/active_merchant/billing/gateways/iridium.rb, line 120
120:       def setup_address_hash(options)
121:         options[:billing_address] = options[:billing_address] || options[:address] || {}
122:         options[:shipping_address] = options[:shipping_address] || {}
123:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.