# File lib/active_merchant/billing/gateways/secure_net.rb, line 73 73: def capture(money, creditcard, authorization, options = {}) 74: commit(build_capture_request(authorization, creditcard, options, :prior_auth_capture), money) 75: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 81 81: def credit(money, creditcard, authorization, options = {}) 82: commit(build_credit_request(authorization, creditcard, options, :credit), money) 83: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 235 235: def add_address(xml, creditcard, options) 236: 237: if address = options[:billing_address] || options[:address] 238: xml.tag!("CUSTOMER_BILL") do 239: xml.tag! 'ADDRESS', address[:address1].to_s 240: xml.tag! 'CITY', address[:city].to_s 241: xml.tag! 'COMPANY', address[:company].to_s 242: xml.tag! 'COUNTRY', address[:country].to_s 243: if options.has_key? :email 244: xml.tag! 'EMAIL', options[:email] 245: # xml.tag! 'EMAIL', 'myemail@yahoo.com' 246: xml.tag! 'EMAILRECEIPT', 'FALSE' 247: end 248: xml.tag! 'FIRSTNAME', creditcard.first_name 249: xml.tag! 'LASTNAME', creditcard.last_name 250: xml.tag! 'PHONE', address[:phone].to_s 251: xml.tag! 'STATE', address[:state].blank? ? 'n/a' : address[:state] 252: xml.tag! 'ZIP', address[:zip].to_s 253: end 254: end 255: 256: if address = options[:shipping_address] 257: xml.tag!("CUSTOMER_SHIP") do 258: xml.tag! 'ADDRESS', address[:address1].to_s 259: xml.tag! 'CITY', address[:city].to_s 260: xml.tag! 'COMPANY', address[:company].to_s 261: xml.tag! 'COUNTRY', address[:country].to_s 262: xml.tag! 'FIRSTNAME', address[:first_name].to_s 263: xml.tag! 'LASTNAME', address[:last_name].to_s 264: xml.tag! 'STATE', address[:state].blank? ? 'n/a' : address[:state] 265: xml.tag! 'ZIP', address[:zip].to_s 266: end 267: else 268: xml.tag!('CUSTOMER_SHIP', NIL_ATTRIBUTE) do 269: end 270: end 271: 272: end
FUNCTIONS RELATED TO BUILDING THE XML
# File lib/active_merchant/billing/gateways/secure_net.rb, line 210 210: def add_credit_card(xml, creditcard) 211: xml.tag!("CARD") do 212: xml.tag! 'CARDCODE', creditcard.verification_value if creditcard.verification_value? 213: xml.tag! 'CARDNUMBER', creditcard.number 214: xml.tag! 'EXPDATE', expdate(creditcard) 215: end 216: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 225 225: def add_customer_data(xml, options) 226: if options.has_key? :customer 227: xml.tag! 'CUSTOMERID', options[:customer] 228: end 229: 230: if options.has_key? :ip 231: xml.tag! 'CUSTOMERIP', options[:ip] 232: end 233: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 274 274: def add_invoice(xml, options) 275: xml.tag! 'INVOICEDESC', options[:description] 276: xml.tag! 'INVOICENUM', 'inv-8' 277: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 279 279: def add_merchant_key(xml, options) 280: xml.tag!("MERCHANT_KEY") do 281: xml.tag! 'GROUPID', 0 282: xml.tag! 'SECUREKEY', @options[:password] 283: xml.tag! 'SECURENETID', @options[:login] 284: end 285: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 134 134: def build_capture_or_credit_request(identification, options) 135: xml = Builder::XmlMarkup.new 136: 137: add_identification(xml, identification) 138: add_customer_data(xml, options) 139: 140: xml.target! 141: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 143 143: def build_capture_request(authorization, creditcard, options, action) 144: xml = Builder::XmlMarkup.new 145: 146: add_credit_card(xml, creditcard) 147: xml.tag! 'CODE', TRANSACTIONS[action] 148: add_customer_data(xml, options) 149: xml.tag! 'DCI', 0 # No duplicate checking will be done, except for ORDERID 150: xml.tag! 'INSTALLMENT_SEQUENCENUM', 1 151: add_merchant_key(xml, options) 152: xml.tag! 'METHOD', 'CC' 153: xml.tag! 'ORDERID', options[:order_id]#'30'.to_i.to_s#'22'# @options[:order_id] 154: xml.tag! 'OVERRIDE_FROM', 0 # Docs say not required, but doesn't work without it 155: xml.tag! 'REF_TRANSID', authorization 156: xml.tag! 'RETAIL_LANENUM', '0' # Docs say string, but it's an integer!? 157: xml.tag! 'TEST', 'TRUE' 158: xml.tag! 'TOTAL_INSTALLMENTCOUNT', 0 159: xml.tag! 'TRANSACTION_SERVICE', 0 160: 161: xml.target! 162: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 164 164: def build_credit_request(authorization, creditcard, options, action) 165: # requires!(options, :card_number) 166: xml = Builder::XmlMarkup.new 167: 168: add_credit_card(xml, creditcard) 169: xml.tag! 'CODE', TRANSACTIONS[action] 170: add_customer_data(xml, options) 171: xml.tag! 'DCI', 0 # No duplicate checking will be done, except for ORDERID 172: xml.tag! 'INSTALLMENT_SEQUENCENUM', 1 173: add_merchant_key(xml, options) 174: xml.tag! 'METHOD', 'CC' 175: xml.tag! 'ORDERID', options[:order_id]#'30'.to_i.to_s#'22'# @options[:order_id] 176: xml.tag! 'OVERRIDE_FROM', 0 # Docs say not required, but doesn't work without it 177: xml.tag! 'REF_TRANSID', authorization 178: xml.tag! 'RETAIL_LANENUM', '0' # Docs say string, but it's an integer!? 179: xml.tag! 'TEST', 'TRUE' 180: xml.tag! 'TOTAL_INSTALLMENTCOUNT', 0 181: xml.tag! 'TRANSACTION_SERVICE', 0 182: 183: xml.target! 184: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 100 100: def build_request(request, money) 101: xml = Builder::XmlMarkup.new 102: 103: xml.instruct! 104: xml.tag!("TRANSACTION", XML_ATTRIBUTES) do 105: xml.tag! 'AMOUNT', amount(money) 106: xml << request 107: end 108: 109: xml.target! 110: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 186 186: def build_void_request(authorization, creditcard, options, action) 187: xml = Builder::XmlMarkup.new 188: 189: add_credit_card(xml, creditcard) 190: xml.tag! 'CODE', TRANSACTIONS[action] 191: add_customer_data(xml, options) 192: xml.tag! 'DCI', 0 # No duplicate checking will be done, except for ORDERID 193: xml.tag! 'INSTALLMENT_SEQUENCENUM', 1 194: add_merchant_key(xml, options) 195: xml.tag! 'METHOD', 'CC' 196: xml.tag! 'ORDERID', options[:order_id]#'30'.to_i.to_s#'22'# @options[:order_id] 197: xml.tag! 'OVERRIDE_FROM', 0 # Docs say not required, but doesn't work without it 198: xml.tag! 'REF_TRANSID', authorization 199: xml.tag! 'RETAIL_LANENUM', '0' # Docs say string, but it's an integer!? 200: xml.tag! 'TEST', 'TRUE' 201: xml.tag! 'TOTAL_INSTALLMENTCOUNT', 0 202: xml.tag! 'TRANSACTION_SERVICE', 0 203: 204: xml.target! 205: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 86 86: def commit(request, money) 87: xml = build_request(request, money) 88: data = ssl_post(TEST_URL, xml, "Content-Type" => "text/xml") 89: response = parse(data) 90: 91: test_mode = test? 92: Response.new(success?(response), message_from(response), response, 93: :test => test_mode, 94: :authorization => response[:transactionid], 95: :avs_result => { :code => response[:avs_result_code] }, 96: :cvv_result => response[:card_code_response_code] 97: ) 98: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 218 218: def expdate(creditcard) 219: year = sprintf("%.4i", creditcard.year) 220: month = sprintf("%.2i", creditcard.month) 221: 222: "#{month}#{year[-2..-1]}" 223: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 294 294: def message_from(response) 295: if response[:response_code].to_i == DECLINED 296: return CVVResult.messages[ response[:card_code_response_code] ] if CARD_CODE_ERRORS.include?(response[:card_code_response_code]) 297: return AVSResult.messages[ response[:avs_result_code] ] if AVS_ERRORS.include?(response[:avs_result_code]) 298: end 299: 300: return response[:response_reason_text].nil? ? '' : response[:response_reason_text][0..1] 301: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 303 303: def parse(xml) 304: response = {} 305: xml = REXML::Document.new(xml) 306: root = REXML::XPath.first(xml, "//GATEWAYRESPONSE")# || 307: # root = REXML::XPath.first(xml, "//ProcessTransactionResponse")# || 308: # REXML::XPath.first(xml, "//ErrorResponse") 309: if root 310: root.elements.to_a.each do |node| 311: recurring_parse_element(response, node) 312: end 313: end 314: 315: response 316: end
# File lib/active_merchant/billing/gateways/secure_net.rb, line 318 318: def recurring_parse_element(response, node) 319: if node.has_elements? 320: node.elements.each{|e| recurring_parse_element(response, e) } 321: else 322: response[node.name.underscore.to_sym] = node.text 323: end 324: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.