class 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
- AVS_CODE
- CURRENCY_CODES
- CVV_CODE
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/iridium.rb, line 225 def initialize(options = {}) requires!(options, :login, :password) super end
Public Instance Methods
capture(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 250 def capture(money, authorization, options = {}) commit(build_reference_request('COLLECTION', money, authorization, options), options) end
credit(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 254 def credit(money, authorization, options = {}) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE refund(money, authorization, options) end
purchase(money, payment_source, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 240 def purchase(money, payment_source, options = {}) setup_address_hash(options) if payment_source.respond_to?(:number) commit(build_purchase_request('SALE', money, payment_source, options), options) else commit(build_reference_request('SALE', money, payment_source, options), options) end end
refund(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 259 def refund(money, authorization, options = {}) commit(build_reference_request('REFUND', money, authorization, options), options) end
scrub(transcript)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 271 def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(%r((<CardNumber>)\d+(</CardNumber>)), '\1[FILTERED]\2'). gsub(%r((<CV2>)\d+(</CV2>)), '\1[FILTERED]\2') end
supports_scrubbing()
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 267 def supports_scrubbing true end
void(authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 263 def void(authorization, options = {}) commit(build_reference_request('VOID', nil, authorization, options), options) end
Private Instance Methods
add_creditcard(xml, creditcard)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 364 def add_creditcard(xml, creditcard) xml.tag! 'CardDetails' do xml.tag! 'CardName', creditcard.name xml.tag! 'CV2', creditcard.verification_value if creditcard.verification_value xml.tag! 'CardNumber', creditcard.number xml.tag! 'ExpiryDate', { 'Month' => creditcard.month.to_s.rjust(2, '0'), 'Year' => creditcard.year.to_s[/\d\d$/] } end end
add_customerdetails(xml, creditcard, address, options, shipTo = false)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 344 def add_customerdetails(xml, creditcard, address, options, shipTo = false) xml.tag! 'CustomerDetails' do if address country_code = Country.find(address[:country]).code(:numeric) unless address[:country].blank? xml.tag! 'BillingAddress' do xml.tag! 'Address1', address[:address1] xml.tag! 'Address2', address[:address2] xml.tag! 'City', address[:city] xml.tag! 'State', address[:state] xml.tag! 'PostCode', address[:zip] xml.tag! 'CountryCode', country_code if country_code end xml.tag! 'PhoneNumber', address[:phone] end xml.tag! 'EmailAddress', options[:email] xml.tag! 'CustomerIPAddress', options[:ip] || '127.0.0.1' end end
add_merchant_data(xml, options)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 373 def add_merchant_data(xml, options) xml.tag! 'MerchantAuthentication', { 'MerchantID' => @options[:login], 'Password' => @options[:password] } end
add_purchase_data(xml, type, money, options)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 330 def add_purchase_data(xml, type, money, options) currency = options[:currency] || currency(money) requires!(options, :order_id) xml.tag! 'TransactionDetails', { 'Amount' => localized_amount(money, currency), 'CurrencyCode' => currency_code(currency) } do xml.tag! 'MessageDetails', { 'TransactionType' => type } xml.tag! 'OrderID', options[:order_id] xml.tag! 'TransactionControl' do xml.tag! 'ThreeDSecureOverridePolicy', 'FALSE' xml.tag! 'EchoAVSCheckResult', 'TRUE' xml.tag! 'EchoCV2CheckResult', 'TRUE' end end end
build_purchase_request(type, money, creditcard, options)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 280 def build_purchase_request(type, money, creditcard, options) options[:action] = 'CardDetailsTransaction' build_request(options) do |xml| add_purchase_data(xml, type, money, options) add_creditcard(xml, creditcard) add_customerdetails(xml, creditcard, options[:billing_address], options) end end
build_reference_request(type, money, authorization, options)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 289 def build_reference_request(type, money, authorization, options) options[:action] = 'CrossReferenceTransaction' order_id, cross_reference, = authorization.split(';') build_request(options) do |xml| if money currency = options[:currency] || currency(money) details = { 'CurrencyCode' => currency_code(currency), 'Amount' => localized_amount(money, currency) } else details = { 'CurrencyCode' => currency_code(default_currency), 'Amount' => '0' } end xml.tag! 'TransactionDetails', details do xml.tag! 'MessageDetails', { 'TransactionType' => type, 'CrossReference' => cross_reference } xml.tag! 'OrderID', (options[:order_id] || order_id) end end end
build_request(options) { |xml| ... }
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 306 def build_request(options) requires!(options, :action) xml = Builder::XmlMarkup.new indent: 2 xml.instruct!(:xml, version: '1.0', encoding: 'utf-8') xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' } do xml.tag! 'soap:Body' do xml.tag! options[:action], { 'xmlns' => 'https://www.thepaymentgateway.net/' } do xml.tag! 'PaymentMessage' do add_merchant_data(xml, options) yield(xml) end end end end xml.target! end
commit(request, options)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 377 def commit(request, options) requires!(options, :action) response = parse( ssl_post( test? ? self.test_url : self.live_url, request, { 'SOAPAction' => 'https://www.thepaymentgateway.net/' + options[:action], 'Content-Type' => 'text/xml; charset=utf-8' } ) ) success = response[:transaction_result][:status_code] == '0' message = response[:transaction_result][:message] authorization = success ? [options[:order_id], response[:transaction_output_data][:cross_reference], response[:transaction_output_data][:auth_code]].compact.join(';') : nil Response.new( success, message, response, test: test?, authorization: authorization, avs_result: { street_match: AVS_CODE[ response[:transaction_output_data][:address_numeric_check_result] ], postal_match: AVS_CODE[ response[:transaction_output_data][:post_code_check_result] ] }, cvv_result: CVV_CODE[ response[:transaction_output_data][:cv2_check_result] ] ) end
currency_code(currency)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 472 def currency_code(currency) CURRENCY_CODES[currency] end
parse(xml)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 407 def parse(xml) reply = {} xml = REXML::Document.new(xml) if (root = REXML::XPath.first(xml, '//CardDetailsTransactionResponse')) || (root = REXML::XPath.first(xml, '//CrossReferenceTransactionResponse')) root.elements.to_a.each do |node| case node.name when 'Message' reply[:message] = reply(node.text) else parse_element(reply, node) end end elsif root = REXML::XPath.first(xml, '//soap:Fault') parse_element(reply, root) reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}" end reply end
parse_element(reply, node)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 427 def parse_element(reply, node) case node.name when 'CrossReferenceTransactionResult' reply[:transaction_result] = {} node.attributes.each do |a, b| reply[:transaction_result][a.underscore.to_sym] = b end node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements? when 'CardDetailsTransactionResult' reply[:transaction_result] = {} node.attributes.each do |a, b| reply[:transaction_result][a.underscore.to_sym] = b end node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements? when 'TransactionOutputData' reply[:transaction_output_data] = {} node.attributes.each { |a, b| reply[:transaction_output_data][a.underscore.to_sym] = b } node.elements.each { |e| parse_element(reply[:transaction_output_data], e) } if node.has_elements? when 'CustomVariables' reply[:custom_variables] = {} node.attributes.each { |a, b| reply[:custom_variables][a.underscore.to_sym] = b } node.elements.each { |e| parse_element(reply[:custom_variables], e) } if node.has_elements? when 'GatewayEntryPoints' reply[:gateway_entry_points] = {} node.attributes.each { |a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b } node.elements.each { |e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements? else k = node.name.underscore.to_sym if node.has_elements? reply[k] = {} node.elements.each { |e| parse_element(reply[k], e) } else if node.has_attributes? reply[k] = {} node.attributes.each { |a, b| reply[k][a.underscore.to_sym] = b } else reply[k] = node.text end end end reply end
setup_address_hash(options)
click to toggle source
# File lib/active_merchant/billing/gateways/iridium.rb, line 325 def setup_address_hash(options) options[:billing_address] = options[:billing_address] || options[:address] || {} options[:shipping_address] = options[:shipping_address] || {} end