# File lib/active_merchant/billing/gateways/netbilling.rb, line 52 52: def capture(money, authorization, options = {}) 53: post = {} 54: add_reference(post, authorization) 55: commit(:capture, money, post) 56: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 41 41: def purchase(money, credit_card, options = {}) 42: post = {} 43: add_amount(post, money) 44: add_invoice(post, options) 45: add_credit_card(post, credit_card) 46: add_address(post, credit_card, options) 47: add_customer_data(post, options) 48: 49: commit(:purchase, money, post) 50: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 76 76: def add_address(post, credit_card, options) 77: if billing_address = options[:billing_address] || options[:address] 78: post[:bill_street] = billing_address[:address1] 79: post[:cust_phone] = billing_address[:phone] 80: post[:bill_zip] = billing_address[:zip] 81: post[:bill_city] = billing_address[:city] 82: post[:bill_country] = billing_address[:country] 83: post[:bill_state] = billing_address[:state] 84: end 85: 86: if shipping_address = options[:shipping_address] 87: first_name, last_name = parse_first_and_last_name(shipping_address[:name]) 88: 89: post[:ship_name1] = first_name 90: post[:ship_name2] = last_name 91: post[:ship_street] = shipping_address[:address1] 92: post[:ship_zip] = shipping_address[:zip] 93: post[:ship_city] = shipping_address[:city] 94: post[:ship_country] = shipping_address[:country] 95: post[:ship_state] = shipping_address[:state] 96: end 97: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 63 63: def add_amount(post, money) 64: post[:amount] = amount(money) 65: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 103 103: def add_credit_card(post, credit_card) 104: post[:bill_name1] = credit_card.first_name 105: post[:bill_name2] = credit_card.last_name 106: post[:card_number] = credit_card.number 107: post[:card_expire] = expdate(credit_card) 108: post[:card_cvv2] = credit_card.verification_value 109: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 71 71: def add_customer_data(post, options) 72: post[:cust_email] = options[:email] 73: post[:cust_ip] = options[:ip] 74: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 99 99: def add_invoice(post, options) 100: post[:description] = options[:description] 101: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 67 67: def add_reference(post, reference) 68: post[:orig_id] = reference 69: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 120 120: def commit(action, money, parameters) 121: response = parse(ssl_post(URL, post_data(action, parameters))) 122: 123: Response.new(success?(response), message_from(response), response, 124: :test => test_response?(response), 125: :authorization => response[:trans_id], 126: :avs_result => { :code => response[:avs_code]}, 127: :cvv_result => response[:cvv2_code] 128: ) 129: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 143 143: def expdate(credit_card) 144: year = sprintf("%.4i", credit_card.year) 145: month = sprintf("%.2i", credit_card.month) 146: 147: "#{month}#{year[-2..-1]}" 148: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 139 139: def message_from(response) 140: success?(response) ? SUCCESS_MESSAGE : (response[:auth_msg] || FAILURE_MESSAGE) 141: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 111 111: def parse(body) 112: results = {} 113: body.split(/&/).each do |pair| 114: key,val = pair.split(/=/) 115: results[key.to_sym] = CGI.unescape(val) 116: end 117: results 118: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 158 158: def parse_first_and_last_name(value) 159: name = value.to_s.split(' ') 160: 161: last_name = name.pop || '' 162: first_name = name.join(' ') 163: [ first_name, last_name ] 164: end
# File lib/active_merchant/billing/gateways/netbilling.rb, line 150 150: def post_data(action, parameters = {}) 151: parameters[:account_id] = @options[:login] 152: parameters[:pay_type] = 'C' 153: parameters[:tran_type] = TRANSACTIONS[action] 154: 155: parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") 156: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.