def customer_profile(user)
      resp = Caboose::StdClass.new('success' => true)    
      options = { :profile => { :merchant_customer_id => user.id, :email => user.email }}
      
      if user.authnet_customer_profile_id.nil? || user.authnet_customer_profile_id.strip.length == 0 # No customer profile, so create it 
        response = self.gateway.create_customer_profile(options)
        if response.success?
          user.authnet_customer_profile_id = response.params['customer_profile_id']
          user.save
        elsif response.message.starts_with?("A duplicate record with ID ")
          user.authnet_customer_profile_id = response.message.gsub("A duplicate record with ID ", '').gsub(" already exists.", '')
          user.save
        else
          resp.success = false
          resp.error = "A fatal error occured, the web administrator has been notified. Please try again later."        
        end        	
      else # Update the profile
        options[:profile][:customer_profile_id] = user.authnet_customer_profile_id      
        response = self.gateway.update_customer_profile(options)    
        if !response.success?
          resp.success = false
          resp.error = "A fatal error occured, the web administrator has been notified. Please try again later."        
        end
      end
      return resp 
    end
def customer_profile(user)
      resp = Caboose::StdClass.new('success' => true)    
      options = { :profile => { :merchant_customer_id => user.id, :email => user.email }}
      
      if user.authnet_customer_profile_id.nil? || user.authnet_customer_profile_id.strip.length == 0 # No customer profile, so create it 
        response = self.gateway.create_customer_profile(options)
        if response.success?
          user.authnet_customer_profile_id = response.params['customer_profile_id']
          user.save
        elsif response.message.starts_with?("A duplicate record with ID ")
          user.authnet_customer_profile_id = response.message.gsub("A duplicate record with ID ", '').gsub(" already exists.", '')
          user.save
        else
          resp.success = false
          resp.error = "A fatal error occured, the web administrator has been notified. Please try again later."        
        end        	
      else # Update the profile
        options[:profile][:customer_profile_id] = user.authnet_customer_profile_id      
        response = self.gateway.update_customer_profile(options)    
        if !response.success?
          resp.success = false
          resp.error = "A fatal error occured, the web administrator has been notified. Please try again later."        
        end
      end
      return resp 
    end
=============================================================================
 Create or update the CIM record in authorize.net for the given user.