Class Index [+]

Quicksearch

ActiveMerchant::Billing::QbmsGateway

Constants

API_VERSION
TYPES

Public Class Methods

new(options = {}) click to toggle source

Creates a new QbmsGateway

The gateway requires that a valid app id, app login, and ticket be passed in the options hash.

Options

  • :login — The App Login (REQUIRED)

  • :ticket — The Connection Ticket. (REQUIRED)

  • :pem — The PEM-encoded SSL client key and certificate. (REQUIRED)

  • :testtrue 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

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source

Performs an authorization, which reserves the funds on the customer’s credit card, but does not charge the card.

Parameters

  • money — The amount to be authorized 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 55
55:       def authorize(money, creditcard, options = {})
56:         commit(:authorize, money, options.merge(:credit_card => creditcard))
57:       end
capture(money, authorization, options = {}) click to toggle source

Captures the funds from an authorized transaction.

Parameters

  • 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(money, identification, options = {}) click to toggle source

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.

Parameters

  • 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
purchase(money, creditcard, options = {}) click to toggle source

Perform a purchase, which is essentially an authorization and capture in a single operation.

Parameters

  • 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() click to toggle source

Query the merchant account status

     # File lib/active_merchant/billing/gateways/qbms.rb, line 114
114:       def query
115:         commit(:query, nil, {})
116:       end
refund(money, identification, options = {}) click to toggle source
     # 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
test?() click to toggle source
     # File lib/active_merchant/billing/gateways/qbms.rb, line 118
118:       def test?
119:         @options[:test] || super  
120:       end
void(authorization, options = {}) click to toggle source

Void a previous transaction

Parameters

  • 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

Private Instance Methods

add_address(xml, parameters) click to toggle source
     # 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
avs_result(response) click to toggle source
     # 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
build_CustomerCreditCardAuth(xml, money, parameters) click to toggle source
     # 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
build_CustomerCreditCardCapture(xml, money, parameters) click to toggle source
     # 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
build_CustomerCreditCardCharge(xml, money, parameters) click to toggle source
     # 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
build_CustomerCreditCardTxnVoid(xml, money, parameters) click to toggle source
     # 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
build_CustomerCreditCardTxnVoidOrRefund(xml, money, parameters) click to toggle source
     # 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
build_MerchantAccountQuery(xml, money, parameters) click to toggle source

Called reflectively by build_request

     # File lib/active_merchant/billing/gateways/qbms.rb, line 264
264:       def build_MerchantAccountQuery(xml, money, parameters)
265:       end
build_request(type, money, parameters = {}) click to toggle source
     # 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
commit(action, money, parameters) click to toggle source
     # 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
cvv_result(response) click to toggle source
     # 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
fraud_review?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/qbms.rb, line 152
152:       def fraud_review?(response)
153:         [10100, 10101].member? response[:status_code]
154:       end
hosted?() click to toggle source
     # File lib/active_merchant/billing/gateways/qbms.rb, line 124
124:       def hosted?
125:         @options[:pem]
126:       end
parse(type, body) click to toggle source
     # 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
success?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/qbms.rb, line 148
148:       def success?(response)
149:         response[:status_code] == 0
150:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.