Class Index [+]

Quicksearch

ActiveMerchant::Billing::SkipJackGateway

Constants

API_VERSION
LIVE_HOST
TEST_HOST
BASIC_PATH
ADVANCED_PATH
ACTIONS
SUCCESS_MESSAGE
MONETARY_CHANGE_STATUSES
CARD_CODE_ERRORS
CARD_CODE_MESSAGES
AVS_ERRORS
AVS_MESSAGES
CHANGE_STATUS_ERROR_MESSAGES
TRANSACTION_CURRENT_STATUS
TRANSACTION_PENDING_STATUS
RETURN_CODE_MESSAGES

Public Class Methods

new(options = {}) click to toggle source

Creates a new SkipJackGateway

The gateway requires that a valid login and password be passed in the options hash.

Options

  • :login — The SkipJack Merchant Serial Number.

  • :password — The SkipJack Developer Serial Number.

  • :test => true or false — Use the test or live SkipJack url.

  • :advanced => true or false — Set to true if you’re using an advanced processor

See the SkipJack Integration Guide for details. (default: false)

     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 182
182:       def initialize(options = {})
183:         requires!(options, :login, :password)
184:         @options = options
185:         super
186:       end

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 192
192:       def authorize(money, creditcard, options = {})
193:         requires!(options, :order_id, :email)
194:         post = {}
195:         add_invoice(post, options)
196:         add_creditcard(post, creditcard)
197:         add_address(post, options)
198:         add_customer_data(post, options)
199:         commit(:authorization, money, post)
200:       end
capture(money, authorization, options = {}) click to toggle source

Captures the funds from an authorized transaction.

Parameters

  • money — The amount to be capture as an Integer in cents.

  • authorization — The authorization returned from the previous authorize request.

  • options — A hash of optional parameters.

Options

  • :force_settlement — Force the settlement to occur as soon as possible. This option is not supported by other gateways. See the SkipJack API reference for more details

     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 223
223:       def capture(money, authorization, options = {})
224:         post = { }
225:         add_status_action(post, 'SETTLE')
226:         add_forced_settlement(post, options)
227:         add_transaction_id(post, authorization)
228:         commit(:change_status, money, post)
229:       end
credit(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 247
247:       def credit(money, identification, options = {})
248:         deprecated CREDIT_DEPRECATION_MESSAGE
249:         refund(money, identification, options)
250:       end
purchase(money, creditcard, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 202
202:       def purchase(money, creditcard, options = {})
203:         post = {}
204:         authorization = authorize(money, creditcard, options)
205:         if authorization.success?
206:           capture(money, authorization.authorization)
207:         else
208:           authorization
209:         end
210:       end
refund(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 239
239:       def refund(money, identification, options = {})
240:         post = {}
241:         add_status_action(post, 'CREDIT')
242:         add_forced_settlement(post, options)
243:         add_transaction_id(post, identification)
244:         commit(:change_status, money, post)
245:       end
status(order_id) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 252
252:       def status(order_id)
253:         commit(:get_status, nil, :szOrderNumber => order_id)
254:       end
test?() click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 188
188:       def test?
189:         @options[:test] || super
190:       end
void(authorization, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 231
231:       def void(authorization, options = {})
232:         post = {}
233:         add_status_action(post, 'DELETE')
234:         add_forced_settlement(post, options)
235:         add_transaction_id(post, authorization)
236:         commit(:change_status, nil, post)
237:       end

Private Instance Methods

add_address(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 397
397:       def add_address(post, options)
398:         if address = options[:billing_address] || options[:address]
399:           post[:StreetAddress]  = address[:address1]
400:           post[:StreetAddress2] = address[:address2]
401:           post[:City]           = address[:city]
402:           post[:State]          = address[:state]
403:           post[:ZipCode]        = address[:zip]
404:           post[:Country]        = address[:country]
405:           post[:Phone]          = address[:phone]
406:           post[:Fax]            = address[:fax]
407:         end
408:         
409:         if address = options[:shipping_address]
410:           post[:ShipToName]           = address[:name]
411:           post[:ShipToStreetAddress]  = address[:address1]
412:           post[:ShipToStreetAddress2] = address[:address2]
413:           post[:ShipToCity]           = address[:city]
414:           post[:ShipToState]          = address[:state]
415:           post[:ShipToZipCode]        = address[:zip]
416:           post[:ShipToCountry]        = address[:country]
417:           post[:ShipToPhone]          = address[:phone]
418:           post[:ShipToFax]            = address[:fax]
419:         end
420:         
421:         # The phone number for the shipping address is required
422:         # Use the billing address phone number if a shipping address
423:         # phone number wasn't provided
424:         post[:ShipToPhone] = post[:Phone] if post[:ShipToPhone].blank?
425:       end
add_amount(params, action, money) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 298
298:       def add_amount(params, action, money)
299:         if action == :authorization
300:           params[:TransactionAmount] = amount(money)
301:         else
302:           params[:szAmount] = amount(money) if MONETARY_CHANGE_STATUSES.include?(params[:szDesiredStatus])
303:         end
304:       end
add_credentials(params, action) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 288
288:       def add_credentials(params, action)
289:         if action == :authorization
290:           params[:SerialNumber] = @options[:login]
291:           params[:DeveloperSerialNumber] = @options[:password]
292:         else
293:           params[:szSerialNumber] = @options[:login]
294:           params[:szDeveloperSerialNumber] = @options[:password]
295:         end
296:       end
add_creditcard(post, creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 385
385:       def add_creditcard(post, creditcard)
386:         post[:AccountNumber]  = creditcard.number
387:         post[:Month] = creditcard.month
388:         post[:Year] = creditcard.year
389:         post[:CVV2] = creditcard.verification_value if creditcard.verification_value?
390:         post[:SJName] = creditcard.name
391:       end
add_customer_data(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 393
393:       def add_customer_data(post, options)
394:         post[:Email] = options[:email]
395:       end
add_forced_settlement(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 262
262:       def add_forced_settlement(post, options)
263:         post[:szForceSettlement] = options[:force_settlment] ? 1 : 0
264:       end
add_invoice(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 372
372:       def add_invoice(post, options)
373:         post[:OrderNumber] = sanitize_order_id(options[:order_id])
374:         post[:CustomerCode] = options[:customer].to_s.slice(0, 17)
375:         post[:InvoiceNumber] = options[:invoice]
376:         post[:OrderDescription] = options[:description]
377:         
378:         if order_items = options[:items]
379:           post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~','-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join
380:         else
381:           post[:OrderString] = '1~None~0.00~0~N~||'
382:         end
383:       end
add_status_action(post, action) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 266
266:       def add_status_action(post, action)
267:         post[:szDesiredStatus] = action
268:       end
add_transaction_id(post, transaction_id) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 368
368:       def add_transaction_id(post, transaction_id)
369:         post[:szTransactionId] = transaction_id
370:       end
advanced?() click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 258
258:       def advanced?
259:         @options[:advanced]
260:       end
authorize_response_map(body) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 325
325:       def authorize_response_map(body)
326:         lines = split_lines(body)
327:         keys, values = split_line(lines[0]), split_line(lines[1])
328:         Hash[*(keys.zip(values).flatten)].symbolize_keys
329:       end
commit(action, money, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 270
270:       def commit(action, money, parameters)
271:         response = parse( ssl_post( url_for(action), post_data(action, money, parameters) ), action )
272:         
273:         # Pass along the original transaction id in the case an update transaction
274:         Response.new(response[:success], message_from(response, action), response,
275:           :test => test?,
276:           :authorization => response[:szTransactionFileName] || parameters[:szTransactionId],
277:           :avs_result => { :code => response[:szAVSResponseCode] },
278:           :cvv_result => response[:szCVV2ResponseCode]
279:         )
280:       end
message_from(response, action) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 427
427:       def message_from(response, action)
428:         case action
429:         when :authorization
430:           message_from_authorization(response)
431:         when :get_status
432:           message_from_status(response)
433:         else
434:           message_from_status(response)
435:         end
436:       end
message_from_authorization(response) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 438
438:       def message_from_authorization(response)
439:         if response[:success]
440:           return SUCCESS_MESSAGE
441:         else
442:           return CARD_CODE_MESSAGES[response[:szCVV2ResponseCode]] if CARD_CODE_ERRORS.include?(response[:szCVV2ResponseCode])
443:           return AVS_MESSAGES[response[:szAVSResponseMessage]] if AVS_ERRORS.include?(response[:szAVSResponseCode])
444:           return RETURN_CODE_MESSAGES[response[:szReturnCode]] if response[:szReturnCode] != '1'
445:           return response[:szAuthorizationDeclinedMessage]
446:         end
447:       end
message_from_status(response) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 449
449:       def message_from_status(response)
450:         response[:success] ? SUCCESS_MESSAGE : response[:szErrorMessage]
451:       end
parse(body, action) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 306
306:       def parse(body, action)
307:         case action
308:         when :authorization
309:           parse_authorization_response(body)
310:         when :get_status
311:           parse_status_response(body, [ :SerialNumber, :TransactionAmount, :TransactionStatusCode, :TransactionStatusMessage, :OrderNumber, :TransactionDateTime, :TransactionID, :ApprovalCode, :BatchNumber ])
312:         else
313:           parse_status_response(body, [ :SerialNumber, :TransactionAmount, :DesiredStatus, :StatusResponse, :StatusResponseMessage, :OrderNumber, :AuditID ])
314:         end
315:       end
parse_authorization_response(body) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 331
331:       def parse_authorization_response(body)
332:         result = authorize_response_map(body)
333:         result[:success] = (result[:szIsApproved] == '1')
334:         result
335:       end
parse_status_response(body, response_keys) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 337
337:       def parse_status_response(body, response_keys)
338:         lines = split_lines(body)
339: 
340:         keys = [ :szSerialNumber, :szErrorCode, :szNumberRecords]
341:         values = split_line(lines[0])[0..2]
342: 
343:         result = Hash[*(keys.zip(values).flatten)]
344: 
345:         result[:szErrorMessage] = ''
346:         result[:success] = (result[:szErrorCode] == '0')
347: 
348:         if result[:success]
349:           lines[1..1].each do |line|
350:             values = split_line(line)
351:             response_keys.each_with_index do |key, index|
352:               result[key] = values[index]
353:             end
354:           end
355:         else
356:           result[:szErrorMessage] = lines[1]
357:         end
358:         result
359:       end
post_data(action, money, params = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 361
361:       def post_data(action, money, params = {})
362:         add_credentials(params, action)
363:         add_amount(params, action, money)
364:         sorted_params = params.to_a.sort{|a,b| a.to_s <=> b.to_s}.reverse
365:         sorted_params.collect { |key, value| "#{key.to_s}=#{CGI.escape(value.to_s)}" }.join("&")
366:       end
sanitize_order_id(value) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 453
453:       def sanitize_order_id(value)
454:         value.to_s.gsub(/[^\w.]/, '')
455:       end
split_line(line) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 321
321:       def split_line(line)
322:         line.split(/","/).collect { |key| key.sub(/"*([^"]*)"*/, '\1').strip; }
323:       end
split_lines(body) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 317
317:       def split_lines(body)
318:         body.split(/[\r\n]+/)
319:       end
url_for(action) click to toggle source
     # File lib/active_merchant/billing/gateways/skip_jack.rb, line 282
282:       def url_for(action)
283:         result = test? ? TEST_HOST : LIVE_HOST
284:         result += advanced? && action == :authorization ? ADVANCED_PATH : BASIC_PATH
285:         result += "?#{ACTIONS[action]}"
286:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.