lib/active_merchant/billing/gateways/qbms.rb in activemerchant-1.79.2 vs lib/active_merchant/billing/gateways/qbms.rb in activemerchant-1.80.0
- old
+ new
@@ -3,12 +3,12 @@
class QbmsGateway < Gateway
API_VERSION = '4.0'
class_attribute :test_url, :live_url
- self.test_url = "https://webmerchantaccount.ptc.quickbooks.com/j/AppGateway"
- self.live_url = "https://webmerchantaccount.quickbooks.com/j/AppGateway"
+ self.test_url = 'https://webmerchantaccount.ptc.quickbooks.com/j/AppGateway'
+ self.live_url = 'https://webmerchantaccount.quickbooks.com/j/AppGateway'
self.homepage_url = 'http://payments.intuit.com/'
self.display_name = 'QuickBooks Merchant Services'
self.default_currency = 'USD'
self.supported_cardtypes = [ :visa, :master, :discover, :american_express, :diners_club, :jcb ]
@@ -136,11 +136,11 @@
type = TYPES[action]
parameters[:trans_request_id] ||= SecureRandom.hex(10)
req = build_request(type, money, parameters)
- data = ssl_post(url, req, "Content-Type" => "application/x-qbmsxml")
+ data = ssl_post(url, req, 'Content-Type' => 'application/x-qbmsxml')
response = parse(type, data)
message = (response[:status_message] || '').strip
Response.new(success?(response), message, response,
:test => test?,
@@ -161,24 +161,24 @@
def parse(type, body)
xml = REXML::Document.new(body)
signon = REXML::XPath.first(xml, "//SignonMsgsRs/#{hosted? ? 'SignonAppCertRs' : 'SignonDesktopRs'}")
- status_code = signon.attributes["statusCode"].to_i
+ status_code = signon.attributes['statusCode'].to_i
if status_code != 0
return {
:status_code => status_code,
- :status_message => signon.attributes["statusMessage"],
+ :status_message => signon.attributes['statusMessage'],
}
end
response = REXML::XPath.first(xml, "//QBMSXMLMsgsRs/#{type}Rs")
results = {
- :status_code => response.attributes["statusCode"].to_i,
- :status_message => response.attributes["statusMessage"],
+ :status_code => response.attributes['statusCode'].to_i,
+ :status_message => response.attributes['statusMessage'],
}
response.elements.each do |e|
name = e.name.underscore.to_sym
value = e.text()
@@ -198,20 +198,20 @@
xml = Builder::XmlMarkup.new(:indent => 0)
xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
xml.instruct!(:qbmsxml, :version => API_VERSION)
- xml.tag!("QBMSXML") do
- xml.tag!("SignonMsgsRq") do
- xml.tag!(hosted? ? "SignonAppCertRq" : "SignonDesktopRq") do
- xml.tag!("ClientDateTime", Time.now.xmlschema)
- xml.tag!("ApplicationLogin", @options[:login])
- xml.tag!("ConnectionTicket", @options[:ticket])
+ xml.tag!('QBMSXML') do
+ xml.tag!('SignonMsgsRq') do
+ xml.tag!(hosted? ? 'SignonAppCertRq' : 'SignonDesktopRq') do
+ xml.tag!('ClientDateTime', Time.now.xmlschema)
+ xml.tag!('ApplicationLogin', @options[:login])
+ xml.tag!('ConnectionTicket', @options[:ticket])
end
end
- xml.tag!("QBMSXMLMsgsRq") do
+ xml.tag!('QBMSXMLMsgsRq') do
xml.tag!("#{type}Rq") do
method("build_#{type}").call(xml, money, parameters)
end
end
end
@@ -221,82 +221,82 @@
def build_CustomerCreditCardAuth(xml, money, parameters)
cc = parameters[:credit_card]
name = "#{cc.first_name} #{cc.last_name}"[0...30]
- xml.tag!("TransRequestID", parameters[:trans_request_id])
- xml.tag!("CreditCardNumber", cc.number)
- xml.tag!("ExpirationMonth", cc.month)
- xml.tag!("ExpirationYear", cc.year)
- xml.tag!("IsECommerce", "true")
- xml.tag!("Amount", amount(money))
- xml.tag!("NameOnCard", name)
+ xml.tag!('TransRequestID', parameters[:trans_request_id])
+ xml.tag!('CreditCardNumber', cc.number)
+ xml.tag!('ExpirationMonth', cc.month)
+ xml.tag!('ExpirationYear', cc.year)
+ xml.tag!('IsECommerce', 'true')
+ xml.tag!('Amount', amount(money))
+ xml.tag!('NameOnCard', name)
add_address(xml, parameters)
- xml.tag!("CardSecurityCode", cc.verification_value) if cc.verification_value?
+ xml.tag!('CardSecurityCode', cc.verification_value) if cc.verification_value?
end
def build_CustomerCreditCardCapture(xml, money, parameters)
- xml.tag!("TransRequestID", parameters[:trans_request_id])
- xml.tag!("CreditCardTransID", parameters[:transaction_id])
- xml.tag!("Amount", amount(money))
+ xml.tag!('TransRequestID', parameters[:trans_request_id])
+ xml.tag!('CreditCardTransID', parameters[:transaction_id])
+ xml.tag!('Amount', amount(money))
end
def build_CustomerCreditCardCharge(xml, money, parameters)
cc = parameters[:credit_card]
name = "#{cc.first_name} #{cc.last_name}"[0...30]
- xml.tag!("TransRequestID", parameters[:trans_request_id])
- xml.tag!("CreditCardNumber", cc.number)
- xml.tag!("ExpirationMonth", cc.month)
- xml.tag!("ExpirationYear", cc.year)
- xml.tag!("IsECommerce", "true")
- xml.tag!("Amount", amount(money))
- xml.tag!("NameOnCard", name)
+ xml.tag!('TransRequestID', parameters[:trans_request_id])
+ xml.tag!('CreditCardNumber', cc.number)
+ xml.tag!('ExpirationMonth', cc.month)
+ xml.tag!('ExpirationYear', cc.year)
+ xml.tag!('IsECommerce', 'true')
+ xml.tag!('Amount', amount(money))
+ xml.tag!('NameOnCard', name)
add_address(xml, parameters)
- xml.tag!("CardSecurityCode", cc.verification_value) if cc.verification_value?
+ xml.tag!('CardSecurityCode', cc.verification_value) if cc.verification_value?
end
def build_CustomerCreditCardTxnVoidOrRefund(xml, money, parameters)
- xml.tag!("TransRequestID", parameters[:trans_request_id])
- xml.tag!("CreditCardTransID", parameters[:transaction_id])
- xml.tag!("Amount", amount(money))
+ xml.tag!('TransRequestID', parameters[:trans_request_id])
+ xml.tag!('CreditCardTransID', parameters[:transaction_id])
+ xml.tag!('Amount', amount(money))
end
def build_CustomerCreditCardTxnVoid(xml, money, parameters)
- xml.tag!("TransRequestID", parameters[:trans_request_id])
- xml.tag!("CreditCardTransID", parameters[:transaction_id])
+ xml.tag!('TransRequestID', parameters[:trans_request_id])
+ xml.tag!('CreditCardTransID', parameters[:transaction_id])
end
# Called reflectively by build_request
def build_MerchantAccountQuery(xml, money, parameters)
end
def add_address(xml, parameters)
if address = parameters[:billing_address] || parameters[:address]
- xml.tag!("CreditCardAddress", (address[:address1] || "")[0...30])
- xml.tag!("CreditCardPostalCode", (address[:zip] || "")[0...9])
+ xml.tag!('CreditCardAddress', (address[:address1] || '')[0...30])
+ xml.tag!('CreditCardPostalCode', (address[:zip] || '')[0...9])
end
end
def cvv_result(response)
case response[:card_security_code_match]
- when "Pass" then 'M'
- when "Fail" then 'N'
- when "NotAvailable" then 'P'
+ when 'Pass' then 'M'
+ when 'Fail' then 'N'
+ when 'NotAvailable' then 'P'
end
end
def avs_result(response)
case "#{response[:avs_street]}|#{response[:avs_zip]}"
- when "Pass|Pass" then "D"
- when "Pass|Fail" then "A"
- when "Pass|NotAvailable" then "B"
- when "Fail|Pass" then "Z"
- when "Fail|Fail" then "C"
- when "Fail|NotAvailable" then "N"
- when "NotAvailable|Pass" then "P"
- when "NotAvailable|Fail" then "N"
- when "NotAvailable|NotAvailable" then "U"
+ when 'Pass|Pass' then 'D'
+ when 'Pass|Fail' then 'A'
+ when 'Pass|NotAvailable' then 'B'
+ when 'Fail|Pass' then 'Z'
+ when 'Fail|Fail' then 'C'
+ when 'Fail|NotAvailable' then 'N'
+ when 'NotAvailable|Pass' then 'P'
+ when 'NotAvailable|Fail' then 'N'
+ when 'NotAvailable|NotAvailable' then 'U'
end
end
end
end
end