# File lib/active_merchant/billing/gateways/trans_first.rb, line 21 21: def purchase(money, credit_card, options = {}) 22: post = {} 23: 24: add_amount(post, money) 25: add_invoice(post, options) 26: add_credit_card(post, credit_card) 27: add_address(post, options) 28: 29: commit(post) 30: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 37 37: def add_address(post, options) 38: address = options[:billing_address] || options[:address] 39: 40: if address 41: add_pair(post, :Address, address[:address1]) 42: add_pair(post, :ZipCode, address[:zip]) 43: end 44: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 33 33: def add_amount(post, money) 34: add_pair(post, :Amount, amount(money), :required => true) 35: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 54 54: def add_credit_card(post, credit_card) 55: add_pair(post, :CardHolderName, credit_card.name, :required => true) 56: add_pair(post, :CardNumber, credit_card.number, :required => true) 57: 58: add_pair(post, :Expiration, expdate(credit_card), :required => true) 59: add_pair(post, :CVV2, credit_card.verification_value) 60: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 46 46: def add_invoice(post, options) 47: add_pair(post, :RefID, options[:order_id], :required => true) 48: add_pair(post, :PONumber, options[:invoice], :required => true) 49: add_pair(post, :SaleTaxAmount, amount(options[:tax] || 0)) 50: add_pair(post, :PaymentDesc, options[:description], :required => true) 51: add_pair(post, :TaxIndicator, 0) 52: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 121 121: def add_pair(post, key, value, options = {}) 122: post[key] = value if !value.blank? || options[:required] 123: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 62 62: def add_unused_fields(post) 63: UNUSED_FIELDS.each do |f| 64: post[f] = "" 65: end 66: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 92 92: def commit(params) 93: response = parse( ssl_post(URL, post_data(params)) ) 94: 95: Response.new(response[:status] == "Authorized", message_from(response), response, 96: :test => test?, 97: :authorization => response[:trans_id], 98: :avs_result => { :code => response[:avs_code] }, 99: :cvv_result => response[:cvv2_code] 100: ) 101: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 68 68: def expdate(credit_card) 69: year = format(credit_card.year, :two_digits) 70: month = format(credit_card.month, :two_digits) 71: 72: "#{month}#{year}" 73: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 103 103: def message_from(response) 104: case response[:message] 105: when 'Call Voice Center' 106: DECLINED 107: else 108: response[:message] 109: end 110: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 75 75: def parse(data) 76: response = {} 77: 78: xml = REXML::Document.new(data) 79: root = REXML::XPath.first(xml, "//CCSaleDebitResponse") 80: 81: if root.nil? 82: response[:message] = data.to_s.strip 83: else 84: root.elements.to_a.each do |node| 85: response[node.name.underscore.to_sym] = node.text 86: end 87: end 88: 89: response 90: end
# File lib/active_merchant/billing/gateways/trans_first.rb, line 112 112: def post_data(params = {}) 113: add_unused_fields(params) 114: params[:MerchantID] = @options[:login] 115: params[:RegKey] = @options[:password] 116: 117: request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") 118: request 119: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.