Creates a new QbmsGateway
The gateway requires that a valid app id, app login, and ticket be passed in the options hash.
:login — The App Login (REQUIRED)
:ticket — The Connection Ticket. (REQUIRED)
:pem — The PEM-encoded SSL client key and certificate. (REQUIRED)
:test — true or false. If true, perform transactions against the test server. Otherwise, perform transactions against the production server.
# File lib/active_merchant/billing/gateways/qbms.rb, line 39 39: def initialize(options = {}) 40: requires!(options, :login, :ticket) 41: test_mode = options[:test] || false 42: @options = options 43: super 44: end
Captures the funds from an authorized transaction.
money — The amount to be captured as an Integer value in cents.
authorization — The authorization returned from the previous authorize request.
# File lib/active_merchant/billing/gateways/qbms.rb, line 78 78: def capture(money, authorization, options = {}) 79: commit(:capture, money, options.merge(:transaction_id => authorization)) 80: end
Credit an account.
This transaction is also referred to as a Refund and indicates to the gateway that money should flow from the merchant to the customer.
money — The amount to be credited to the customer as an Integer value in cents.
identification — The ID of the original transaction against which the credit is being issued.
options — A hash of parameters.
# File lib/active_merchant/billing/gateways/qbms.rb, line 104 104: def credit(money, identification, options = {}) 105: deprecated CREDIT_DEPRECATION_MESSAGE 106: refund(money, identification, options = {}) 107: end
Perform a purchase, which is essentially an authorization and capture in a single operation.
money — The amount to be purchased as an Integer value in cents.
creditcard — The CreditCard details for the transaction.
options — A hash of optional parameters.
# File lib/active_merchant/billing/gateways/qbms.rb, line 67 67: def purchase(money, creditcard, options = {}) 68: commit(:purchase, money, options.merge(:credit_card => creditcard)) 69: end
Query the merchant account status
# File lib/active_merchant/billing/gateways/qbms.rb, line 114 114: def query 115: commit(:query, nil, {}) 116: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 109 109: def refund(money, identification, options = {}) 110: commit(:refund, money, options.merge(:transaction_id => identification)) 111: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 118 118: def test? 119: @options[:test] || super 120: end
Void a previous transaction
authorization - The authorization returned from the previous authorize request.
# File lib/active_merchant/billing/gateways/qbms.rb, line 88 88: def void(authorization, options = {}) 89: commit(:void, nil, options.merge(:transaction_id => authorization)) 90: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 267 267: def add_address(xml, parameters) 268: if address = parameters[:billing_address] || parameters[:address] 269: xml.tag!("CreditCardAddress", address[:address1][0...30]) 270: xml.tag!("CreditCardPostalCode", address[:zip][0...9]) 271: end 272: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 282 282: def avs_result(response) 283: case "#{response[:avs_street]}|#{response[:avs_zip]}" 284: when "Pass|Pass" then "D" 285: when "Pass|Fail" then "A" 286: when "Pass|NotAvailable" then "B" 287: when "Fail|Pass" then "Z" 288: when "Fail|Fail" then "C" 289: when "Fail|NotAvailable" then "N" 290: when "NotAvailable|Pass" then "P" 291: when "NotAvailable|Fail" then "N" 292: when "NotAvailable|NotAvailable" then "U" 293: end 294: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 216 216: def build_CustomerCreditCardAuth(xml, money, parameters) 217: cc = parameters[:credit_card] 218: name = "#{cc.first_name} #{cc.last_name}"[0...30] 219: 220: xml.tag!("TransRequestID", parameters[:trans_request_id]) 221: xml.tag!("CreditCardNumber", cc.number) 222: xml.tag!("ExpirationMonth", cc.month) 223: xml.tag!("ExpirationYear", cc.year) 224: xml.tag!("IsECommerce", "true") 225: xml.tag!("Amount", amount(money)) 226: xml.tag!("NameOnCard", name) 227: add_address(xml, parameters) 228: xml.tag!("CardSecurityCode", cc.verification_value) if cc.verification_value? 229: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 231 231: def build_CustomerCreditCardCapture(xml, money, parameters) 232: xml.tag!("TransRequestID", parameters[:trans_request_id]) 233: xml.tag!("CreditCardTransID", parameters[:transaction_id]) 234: xml.tag!("Amount", amount(money)) 235: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 237 237: def build_CustomerCreditCardCharge(xml, money, parameters) 238: cc = parameters[:credit_card] 239: name = "#{cc.first_name} #{cc.last_name}"[0...30] 240: 241: xml.tag!("TransRequestID", parameters[:trans_request_id]) 242: xml.tag!("CreditCardNumber", cc.number) 243: xml.tag!("ExpirationMonth", cc.month) 244: xml.tag!("ExpirationYear", cc.year) 245: xml.tag!("IsECommerce", "true") 246: xml.tag!("Amount", amount(money)) 247: xml.tag!("NameOnCard", name) 248: add_address(xml, parameters) 249: xml.tag!("CardSecurityCode", cc.verification_value) if cc.verification_value? 250: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 258 258: def build_CustomerCreditCardTxnVoid(xml, money, parameters) 259: xml.tag!("TransRequestID", parameters[:trans_request_id]) 260: xml.tag!("CreditCardTransID", parameters[:transaction_id]) 261: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 252 252: def build_CustomerCreditCardTxnVoidOrRefund(xml, money, parameters) 253: xml.tag!("TransRequestID", parameters[:trans_request_id]) 254: xml.tag!("CreditCardTransID", parameters[:transaction_id]) 255: xml.tag!("Amount", amount(money)) 256: end
Called reflectively by build_request
# File lib/active_merchant/billing/gateways/qbms.rb, line 264 264: def build_MerchantAccountQuery(xml, money, parameters) 265: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 191 191: def build_request(type, money, parameters = {}) 192: xml = Builder::XmlMarkup.new(:indent => 0) 193: 194: xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8') 195: xml.instruct!(:qbmsxml, :version => API_VERSION) 196: 197: xml.tag!("QBMSXML") do 198: xml.tag!("SignonMsgsRq") do 199: xml.tag!(hosted? ? "SignonAppCertRq" : "SignonDesktopRq") do 200: xml.tag!("ClientDateTime", Time.now.xmlschema) 201: xml.tag!("ApplicationLogin", @options[:login]) 202: xml.tag!("ConnectionTicket", @options[:ticket]) 203: end 204: end 205: 206: xml.tag!("QBMSXMLMsgsRq") do 207: xml.tag!("#{type}Rq") do 208: method("build_#{type}").call(xml, money, parameters) 209: end 210: end 211: end 212: 213: xml.target! 214: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 128 128: def commit(action, money, parameters) 129: url = test? ? self.test_url : self.live_url 130: 131: type = TYPES[action] 132: parameters[:trans_request_id] ||= SecureRandom.hex(10) 133: 134: req = build_request(type, money, parameters) 135: data = ssl_post(url, req, "Content-Type" => "application/x-qbmsxml") 136: response = parse(type, data) 137: message = (response[:status_message] || '').strip 138: 139: Response.new(success?(response), message, response, 140: :test => test?, 141: :authorization => response[:credit_card_trans_id], 142: :fraud_review => fraud_review?(response), 143: :avs_result => { :code => avs_result(response) }, 144: :cvv_result => cvv_result(response) 145: ) 146: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 274 274: def cvv_result(response) 275: case response[:card_security_code_match] 276: when "Pass" then 'M' 277: when "Fail" then 'N' 278: when "NotAvailable" then 'P' 279: end 280: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 152 152: def fraud_review?(response) 153: [10100, 10101].member? response[:status_code] 154: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 124 124: def hosted? 125: @options[:pem] 126: end
# File lib/active_merchant/billing/gateways/qbms.rb, line 156 156: def parse(type, body) 157: xml = REXML::Document.new(body) 158: 159: signon = REXML::XPath.first(xml, "//SignonMsgsRs/#{hosted? ? 'SignonAppCertRs' : 'SignonDesktopRs'}") 160: status_code = signon.attributes["statusCode"].to_i 161: 162: if status_code != 0 163: return { 164: :status_code => status_code, 165: :status_message => signon.attributes["statusMessage"], 166: } 167: end 168: 169: response = REXML::XPath.first(xml, "//QBMSXMLMsgsRs/#{type}Rs") 170: 171: results = { 172: :status_code => response.attributes["statusCode"].to_i, 173: :status_message => response.attributes["statusMessage"], 174: } 175: 176: response.elements.each do |e| 177: name = e.name.underscore.to_sym 178: value = e.text() 179: 180: if old_value = results[name] 181: results[name] = [old_value] if !old_value.kind_of?(Array) 182: results[name] << value 183: else 184: results[name] = value 185: end 186: end 187: 188: results 189: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.