<commit_before>module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class ViaklixGateway < Gateway
      TEST_URL = 'https://demo.viaklix.com/process.asp'
      LIVE_URL = 'https://www.viaklix.com/process.asp'
      
      APPROVED = '0'
      
      self.supported_cardtypes = [:visa, :master, :american_express]
      self.supported_countries = ['US']
      self.display_name = 'ViaKlix'
      self.homepage_url = 'http://viaklix.com'
      
      # Initialize the Gateway
      #
      # The gateway requires that a valid login and password be passed
      # in the +options+ hash.
      # 
      # ==== Options
      #
      # * <tt>:login</tt> -- Merchant ID
      # * <tt>:password</tt> -- PIN
      # * <tt>:user</tt> -- Specify a subuser of the account (optional)
      # * <tt>:test => +true+ or +false+</tt> -- Force test transactions
      def initialize(options = {})
        requires!(options, :login, :password)
        @options = options
        super
      end
      
      # Make a purchase  
      def purchase(money, creditcard, options = {})
        form = {}
        add_invoice(form, options)
        add_creditcard(form, creditcard)        
        add_address(form, options)   
        add_customer_data(form, options)
        commit('SALE', money, form)
      end
      
      # Make a credit to a card (Void can only be done from the virtual terminal)
      # Viaklix does not support credits by reference. You must pass in the credit card
      def credit(money, creditcard, options = {})
        if creditcard.is_a?(String)
          raise ArgumentError, "Reference credits are not supported.  Please supply the original credit card"
        end
        
        form = {}
        add_invoice(form, options)
        add_creditcard(form, creditcard)        
        add_address(form, options)   
        add_customer_data(form, options)
        commit('CREDIT', money, form)
      end
      
      private
      def add_customer_data(form, options)
        form[:email] = options[:email] unless options[:email].blank?
        form[:customer_code] = options[:customer] unless options[:customer].blank?
      end
      
      def add_invoice(form,options)
        form[:invoice_number] = options[:order_id] || options[:invoice]
      end
      
      def add_address(form,options)
        billing_address = options[:billing_address] || options[:address] 
        
        if billing_address
          form[:avs_address]    = billing_address[:address1]
          form[:avs_zip]        = billing_address[:zip]<commit_msg>Limit length of customer field<commit_after>module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class ViaklixGateway < Gateway
      TEST_URL = 'https://demo.viaklix.com/process.asp'
      LIVE_URL = 'https://www.viaklix.com/process.asp'
      
      APPROVED = '0'
      
      self.supported_cardtypes = [:visa, :master, :american_express]
      self.supported_countries = ['US']
      self.display_name = 'ViaKLIX'
      self.homepage_url = 'http://viaklix.com'
      
      # Initialize the Gateway
      #
      # The gateway requires that a valid login and password be passed
      # in the +options+ hash.
      # 
      # ==== Options
      #
      # * <tt>:login</tt> -- Merchant ID
      # * <tt>:password</tt> -- PIN
      # * <tt>:user</tt> -- Specify a subuser of the account (optional)
      # * <tt>:test => +true+ or +false+</tt> -- Force test transactions
      def initialize(options = {})
        requires!(options, :login, :password)
        @options = options
        super
      end
      
      # Make a purchase  
      def purchase(money, creditcard, options = {})
        form = {}
        add_invoice(form, options)
        add_creditcard(form, creditcard)        
        add_address(form, options)   
        add_customer_data(form, options)
        commit('SALE', money, form)
      end
      
      # Make a credit to a card (Void can only be done from the virtual terminal)
      # Viaklix does not support credits by reference. You must pass in the credit card
      def credit(money, creditcard, options = {})
        if creditcard.is_a?(String)
          raise ArgumentError, "Reference credits are not supported.  Please supply the original credit card"
        end
        
        form = {}
        add_invoice(form, options)
        add_creditcard(form, creditcard)        
        add_address(form, options)   
        add_customer_data(form, options)
        commit('CREDIT', money, form)
      end
      
      private
      def add_customer_data(form, options)
        form[:email] = options[:email] unless options[:email].blank?
        form[:customer_code] = options[:customer].to_s.slice(0, 17) unless options[:customer].blank?
      end
      
      def add_invoice(form,options)
        form[:invoice_number] = options[:order_id] || options[:invoice]
      end
      
      def add_address(form,options)
        billing_address = options[:billing_address] || options[:address] 
        
        if billing_address
          form[:avs_address]    = billing_address[:address1]
          form[:avs_zip]        = billing_address[:zip]
{'fraction_non_alphanumeric': 0.10760848414088343, 'fraction_numerical': 0.0013621327106440942, 'mean_word_length': 2.2245922208281055, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4884397', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1501, 'n_words': 374}